Skip to content

improve error message when a cfg-ed out item is resolved#154037

Open
scrabsha wants to merge 1 commit intorust-lang:mainfrom
scrabsha:push-ltqusupltwzm
Open

improve error message when a cfg-ed out item is resolved#154037
scrabsha wants to merge 1 commit intorust-lang:mainfrom
scrabsha:push-ltqusupltwzm

Conversation

@scrabsha
Copy link
Contributor

@scrabsha scrabsha commented Mar 18, 2026

the current note for "cannot find function f in this scope" is:

note: found an item that was configured out
 --> src/main.rs:4:4
  |
3 | #[cfg(foo = "bar")]
  |       ----------- the item is gated behind the `bar` feature
4 | fn f() {}
  |    ^

i think mentioning only bar in the label is misleading. in more complicated setups, this leads to obscure notes such as "the item is gated behind the ptr feature".

this PR improves the situation by naming both the name and value in the label (in the example i linked, target_has_atomic and ptr). while i was at it, i also special-cased #[cfg(false)], #[cfg(any())] and #[cfg(feature = "meow")] (aka Cargo features).

i also tried to use #[derive(SubDiagnostic)] on FoundItemConfigureOut, with no success (the resulting diagnostic was showing multiple help snippets, i couldn't figure out how to merge them). any help would be appreciated.

r? you Esteban, as you added the diagnostic initially - feel free to unassign yourself if necessary :)

r? @estebank

nevermind apparently that's not possible --'

@rustbot
Copy link
Collaborator

rustbot commented Mar 18, 2026

Failed to set assignee to you: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 18, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 18, 2026

Failed to set assignee to estebank~~: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@scrabsha
Copy link
Contributor Author

@rustbot reroll

@Kivooeo
Copy link
Member

Kivooeo commented Mar 18, 2026

nevermind apparently that's not possible

r? estebank

@rustbot rustbot assigned estebank and unassigned petrochenkov Mar 18, 2026
@scrabsha
Copy link
Contributor Author

scrabsha commented Mar 18, 2026

@Kivooeo if you don't mind me asking, why did it fail when i opened the PR? i remember r?ing people in the past, i'm a bit confused :/

edit: oah i did not suspect this would trigger rustbot again, sorry for the noise

edit: i think this is because rustbot looks for the first occurrence of r question mark anywhere in the message and tries to use that (i thought it had to be at the beginning of a line).

@rustbot
Copy link
Collaborator

rustbot commented Mar 18, 2026

Failed to set assignee to ing: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@jdonszelmann
Copy link
Contributor

Might be good to also special case any(), the old way of writing false

@scrabsha scrabsha force-pushed the push-ltqusupltwzm branch from d07ece2 to 995f854 Compare March 18, 2026 10:28
@scrabsha
Copy link
Contributor Author

done, thanks!

@Kivooeo
Copy link
Member

Kivooeo commented Mar 18, 2026

@Kivooeo if you don't mind me asking, why did it fail when i opened the PR? i remember r?ing people in the past, i'm a bit confused :/

The issue is that the r-? command assigns the reviewer based on the word that follows it. In your first attempt, you wrote "r-? you Esteban" -- but "you" isn't a valid reviewer. Then you tried "estebank~~", which is also incorrect

To assign a reviewer correctly, you need to use their exact GitHub username. In this case, it should be "estebank"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants