-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Make generic const type mismatches not hide trait impls from the trait solver #120059
Changes from all commits
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 |
---|---|---|
@@ -1,9 +1,23 @@ | ||
error: the constant `13` is not of type `u64` | ||
--> $DIR/bad-subst-const-kind.rs:13:24 | ||
| | ||
LL | pub fn test() -> [u8; <[u8; 13] as Q>::ASSOC] { todo!() } | ||
| ^^^^^^^^ expected `u64`, found `usize` | ||
| | ||
note: required for `[u8; 13]` to implement `Q` | ||
--> $DIR/bad-subst-const-kind.rs:8:20 | ||
| | ||
LL | impl<const N: u64> Q for [u8; N] { | ||
| ------------ ^ ^^^^^^^ | ||
| | | ||
| unsatisfied trait bound introduced here | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/bad-subst-const-kind.rs:8:31 | ||
| | ||
LL | impl<const N: u64> Q for [u8; N] { | ||
| ^ expected `usize`, found `u64` | ||
|
||
Comment on lines
15
to
20
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 is the only diagnostic I would expect to see. But I haven't figured out yet how to poison the impl so it doesn't get picked up |
||
error: aborting due to 1 previous error | ||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,35 @@ LL | const ASSOC: usize; | |
LL | impl<const N: u64> Q for [u8; N] {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `ASSOC` in implementation | ||
|
||
error: aborting due to 1 previous error | ||
error: the constant `13` is not of type `u64` | ||
--> $DIR/type_mismatch.rs:12:26 | ||
| | ||
LL | pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] {} | ||
| ^^^^^^^^ expected `u64`, found `usize` | ||
| | ||
note: required for `[u8; 13]` to implement `Q` | ||
--> $DIR/type_mismatch.rs:8:20 | ||
| | ||
LL | impl<const N: u64> Q for [u8; N] {} | ||
| ------------ ^ ^^^^^^^ | ||
| | | ||
| unsatisfied trait bound introduced here | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/type_mismatch.rs:12:20 | ||
| | ||
LL | pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] {} | ||
| ------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `[u8; <[u8; 13] as Q>::ASSOC]`, found `()` | ||
| | | ||
| implicitly returns `()` as its body has no tail or `return` expression | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/type_mismatch.rs:8:31 | ||
| | ||
LL | impl<const N: u64> Q for [u8; N] {} | ||
| ^ expected `usize`, found `u64` | ||
|
||
Comment on lines
+32
to
+37
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 is good, I want this error. But now we also got a bunch of "follow-up" errors happening before. Maybe we can move whatever causes this error into a query that is guaranteed to be called before impl overlap checking |
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0046`. | ||
Some errors have detailed explanations: E0046, E0308. | ||
For more information about an error, try `rustc --explain E0046`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,29 @@ | ||
error[E0119]: conflicting implementations of trait `Copy` for type `S<_>` | ||
--> $DIR/bad-const-wf-doesnt-specialize.rs:10:1 | ||
| | ||
LL | impl<const N: i32> Copy for S<N> {} | ||
| -------------------------------- first implementation here | ||
LL | | ||
LL | impl<const M: usize> Copy for S<M> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `S<_>` | ||
|
||
error: the constant `N` is not of type `usize` | ||
--> $DIR/bad-const-wf-doesnt-specialize.rs:8:29 | ||
| | ||
LL | impl<const N: i32> Copy for S<N> {} | ||
| ^^^^ expected `usize`, found `i32` | ||
| | ||
note: required by a bound in `S` | ||
--> $DIR/bad-const-wf-doesnt-specialize.rs:6:10 | ||
note: required for `S<N>` to implement `Clone` | ||
--> $DIR/bad-const-wf-doesnt-specialize.rs:5:10 | ||
| | ||
LL | #[derive(Clone)] | ||
| ^^^^^ | ||
LL | struct S<const L: usize>; | ||
| ^^^^^^^^^^^^^^ required by this bound in `S` | ||
| ----- unsatisfied trait bound introduced in this `derive` macro | ||
note: required by a bound in `Copy` | ||
--> $SRC_DIR/core/src/marker.rs:LL:COL | ||
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: aborting due to 1 previous error | ||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0119`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the compiler suggests using a
u64
as an array lengthThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah we have bad spans for this in general