-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle infer vars in anon consts on stable
- Loading branch information
Showing
4 changed files
with
76 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/ui/const-generics/failing_goal_with_repeat_expr_anon_const.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Regression test for #132955 checking that we handle anon consts with | ||
// inference variables in their generic arguments correctly. | ||
// | ||
// This arose via diagnostics where we would have some failing goal such | ||
// as `[u8; AnonConst<Self>]: PartialEq<Self::A>`, then as part of diagnostics | ||
// we would replace all generic parameters with inference vars which would yield | ||
// a self type of `[u8; AnonConst<?x>]` and then attempt to normalize `AnonConst<?x>`. | ||
|
||
pub trait T { | ||
type A; | ||
const P: Self::A; | ||
|
||
fn a() { | ||
[0u8; std::mem::size_of::<Self::A>()] == Self::P; | ||
//~^ ERROR: can't compare | ||
//~| ERROR: constant expression depends on a generic parameter | ||
//~| ERROR: constant expression depends on a generic parameter | ||
} | ||
} | ||
|
||
fn main() {} |
31 changes: 31 additions & 0 deletions
31
tests/ui/const-generics/failing_goal_with_repeat_expr_anon_const.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
error: constant expression depends on a generic parameter | ||
--> $DIR/failing_goal_with_repeat_expr_anon_const.rs:14:15 | ||
| | ||
LL | [0u8; std::mem::size_of::<Self::A>()] == Self::P; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this may fail depending on what value the parameter takes | ||
|
||
error: constant expression depends on a generic parameter | ||
--> $DIR/failing_goal_with_repeat_expr_anon_const.rs:14:47 | ||
| | ||
LL | [0u8; std::mem::size_of::<Self::A>()] == Self::P; | ||
| ^^ | ||
| | ||
= note: this may fail depending on what value the parameter takes | ||
|
||
error[E0277]: can't compare `[u8; std::mem::size_of::<Self::A>()]` with `<Self as T>::A` | ||
--> $DIR/failing_goal_with_repeat_expr_anon_const.rs:14:47 | ||
| | ||
LL | [0u8; std::mem::size_of::<Self::A>()] == Self::P; | ||
| ^^ no implementation for `[u8; std::mem::size_of::<Self::A>()] == <Self as T>::A` | ||
| | ||
= help: the trait `PartialEq<<Self as T>::A>` is not implemented for `[u8; std::mem::size_of::<Self::A>()]` | ||
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement | ||
| | ||
LL | pub trait T where [u8; std::mem::size_of::<Self::A>()]: PartialEq<<Self as T>::A> { | ||
| +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |