-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add diagnostics for specific cases for const/type mismatch err #82055
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#![crate_type="lib"] | ||
#![feature(const_generics)] | ||
#![allow(incomplete_features)] | ||
|
||
struct A<const N: u8>; | ||
trait Foo {} | ||
impl Foo for A<N> {} | ||
//~^ ERROR type provided when a constant | ||
//~| ERROR cannot find type | ||
|
||
struct B<const N: u8>; | ||
impl<N> Foo for B<N> {} | ||
//~^ ERROR type provided when a constant |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
error[E0412]: cannot find type `N` in this scope | ||
--> $DIR/diagnostics.rs:7:16 | ||
| | ||
LL | struct A<const N: u8>; | ||
| ---------------------- similarly named struct `A` defined here | ||
LL | trait Foo {} | ||
LL | impl Foo for A<N> {} | ||
| ^ help: a struct with a similar name exists: `A` | ||
Comment on lines
+7
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally this would suggest "you meant to add a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's hard to tell if a |
||
|
||
error[E0747]: type provided when a constant was expected | ||
--> $DIR/diagnostics.rs:7:16 | ||
| | ||
LL | impl Foo for A<N> {} | ||
| ^ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one should probably be silenced when the one above is emitted. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know how to detect when the above is emitted, as from the path resolution alone I cannot tell, but I've changed the message to be more pertinent. |
||
|
||
error[E0747]: type provided when a constant was expected | ||
--> $DIR/diagnostics.rs:12:19 | ||
| | ||
LL | impl<N> Foo for B<N> {} | ||
| - ^ | ||
| | | ||
| help: try changing to a const-generic parameter:: `const N: u8` | ||
JulianKnodt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0412, E0747. | ||
For more information about an error, try `rustc --explain E0412`. |
Uh oh!
There was an error while loading. Please reload this page.