Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No diagnostics for cfg-ed out methods #130319

Open
dimpolo opened this issue Sep 13, 2024 · 3 comments
Open

No diagnostics for cfg-ed out methods #130319

dimpolo opened this issue Sep 13, 2024 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dimpolo
Copy link
Contributor

dimpolo commented Sep 13, 2024

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

@dimpolo dimpolo added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 13, 2024
@Noratrieb
Copy link
Member

Noratrieb commented Sep 20, 2024

the cfg stuff does not handle methods at all, and handling them would be a huge nightmare

@dimpolo
Copy link
Contributor Author

dimpolo commented Sep 20, 2024

Hm, even if it's only inherent methods?

@Noratrieb
Copy link
Member

yes, they don't participate in the module hierarchy and are resolved later in the compiler. im not saying it's straight up impossible, but it's really hard, especially to make efficient enough

@dimpolo dimpolo changed the title No diagnostics for cfg-ed out atomic methods No diagnostics for cfg-ed out methods Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants