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

Invalid "a constant with a similar name exists: _" suggestion when a const _ is in scope #68719

Closed
ollie27 opened this issue Jan 31, 2020 · 0 comments · Fixed by #68740
Closed
Labels
A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ollie27
Copy link
Member

ollie27 commented Jan 31, 2020

For example (playground):

const _: () = ();

fn main() {
    a
}

Errors with:

error[E0425]: cannot find value `a` in this scope
 --> src/main.rs:4:5
  |
1 | const _: () = ();
  | ----------------- similarly named constant `_` defined here
...
4 |     a
  |     ^ help: a constant with a similar name exists: `_`

The same also happens with use Trait as _ (playground):

pub use Iterator as _;

fn foo<T: A>(x: T) {}
error[E0405]: cannot find trait `A` in this scope
    --> src/lib.rs:3:11
     |
3    |   fn foo<T: A>(x: T) {}
     |             ^ help: a trait with a similar name exists: `_`

The diagnostics shouldn't suggest things named underscore.

@jonas-schievink jonas-schievink added A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 31, 2020
JohnTitor added a commit to JohnTitor/rust that referenced this issue Feb 1, 2020
…=Centril

Do not suggest things named underscore

Fixes rust-lang#68719

r? @estebank
@bors bors closed this as completed in 87bb0c4 Feb 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants