rust-lang / rust-lang/rust

No diagnostics for `cfg`-ed out methods

Open
#130,319 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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

https://github.com/rust-lang/rust/pull/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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the diagnostic with rustc --target thumbv6m-none-eabi using the AtomicBool example, then study the similar diagnostics added by rust-lang/rust#109005. Trace the method-not-found diagnostic path and make the completed output include the requested note when a cfg predicate disables the method; verify it with a regression test for this example.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.