Skip to content

No diagnostics for cfg-ed out methods #130319

Open
@dimpolo

Description

@dimpolo

Code

compile with --target thumbv6m-none-eabi
or see https://godbolt.org/z/nEjfqMP5v

#![no_std]

use core::sync::atomic::{AtomicBool, Ordering};

fn test(){
    AtomicBool::new(false).fetch_not(Ordering::Relaxed);
}

Current output

error[E0599]: no method named `fetch_not` found for struct `AtomicBool` in the current scope
 --> <source>:6:28
  |
6 |     AtomicBool::new(false).fetch_not(Ordering::Relaxed);
  |                            ^^^^^^^^^ method not found in `AtomicBool`

Desired output

Add this:

note: `AtomicBool` has a method named `fetch_not` but it is inactive because its cfg predicate evaluated to false

Rationale and extra context

#109005 added very helpful diagnostics for a similar case

Other cases

No response

Rust Version

rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.1.7
Compiler returned: 0

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions