rustc_resolve: improve const generic errors#152913
rustc_resolve: improve const generic errors#152913Unique-Usman wants to merge 1 commit intorust-lang:mainfrom
Conversation
|
rustbot has assigned @JonathanBrouwer. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
r? @estebank |
00fa325 to
98d6219
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
98d6219 to
b162b4b
Compare
| LL + impl X<X> {} | ||
| | | ||
| help: you might be missing a type parameter | ||
| help: you might have meant to write a const parameter here |
There was a problem hiding this comment.
| help: you might have meant to write a const parameter here | |
| help: you might have meant to introduce a const parameter on the `impl` |
There was a problem hiding this comment.
the const parameter can be in other place apart from impl, I think we should leave it as here instead of the impl or we can just make it varies based on where it appears.
| --> $DIR/missing-type-parameter2.rs:5:28 | ||
| | | ||
| LL | struct X<const N: u8>(); | ||
| | ----------- const parameter `N` is defined here |
There was a problem hiding this comment.
| | ----------- const parameter `N` is defined here | |
| | ----------- const parameter `N` is defined on the type |
| | | ||
| LL | struct X<const N: u8>(); | ||
| | ------------------------ similarly named struct `X` defined here | ||
| | ----------- const parameter `N` is defined here |
There was a problem hiding this comment.
| | ----------- const parameter `N` is defined here | |
| | ----------- const parameter `N` is defined on the type |
| .struct_constructors | ||
| .insert(local_def_id, (ctor_res, ctor_vis.to_def_id(), ret_fields)); | ||
| } | ||
| self.r.struct_generics.insert(local_def_id, generics.clone()); |
There was a problem hiding this comment.
Let's see if we can struct_generics store references. That should keep mem usage to a minimum.
| if let Some(const_err) = const_err { | ||
| err.cancel(); | ||
| err = const_err; | ||
| } |
There was a problem hiding this comment.
This is currently inactive, right? const_err isn't None anywhere right now?
There was a problem hiding this comment.
const_err is actually always None except in the case of where we add the error we just introduce see it here -> https://github.com/rust-lang/rust/pull/152913/changes#diff-2c81e6d8048a31a3ce43f30181aaa037e0ad0076e7aee67792ca993f28c75ac3R3440-R3441
There was a problem hiding this comment.
it is to prevent the type error from showing up.
| LL - impl<const N: u8> Foo for C<N, T> {} | ||
| LL + impl<const N: u8> Foo for C<N, A> {} | ||
| | | ||
| help: you might be missing a type parameter | ||
| LL + impl<const T: u8> Foo for C<N, T> {} | ||
| | | ||
| LL | impl<const N: u8, T> Foo for C<N, T> {} | ||
| | +++ | ||
|
|
||
| error[E0747]: unresolved item provided when a constant was expected | ||
| --> $DIR/invalid-const-arguments.rs:5:16 | ||
| | | ||
| LL | impl Foo for A<N> {} | ||
| | ^ | ||
| | | ||
| help: if this generic argument was intended as a const parameter, surround it with braces | ||
| | | ||
| LL | impl Foo for A<{ N }> {} | ||
| | + + | ||
|
|
||
| error[E0747]: type provided when a constant was expected | ||
| --> $DIR/invalid-const-arguments.rs:10:19 | ||
| --> $DIR/invalid-const-arguments.rs:9:19 | ||
| | | ||
| LL | impl<N> Foo for B<N> {} |
There was a problem hiding this comment.
We're going to have to account for "there's already an impl generics list" to suggest adding, instead of replacing.
There was a problem hiding this comment.
Yeah, noted. make sense.
|
HIR ty lowering was modified cc @fmease |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
No description provided.