-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #82009 - BoxyUwU:idontknooow, r=varkor
const_generics: Dont evaluate array length const when handling errors Fixes #79518 Fixes #78246 cc ````@lcnr```` This was ICE'ing because we dont pass in the correct ``ParamEnv`` which meant that there was no ``Self: Foo`` predicate to make ``Self::Assoc`` well formed which caused an ICE when trying to normalize ``Self::Assoc`` in the mir interpreter r? ````@varkor````
- Loading branch information
Showing
4 changed files
with
45 additions
and
5 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
src/test/ui/const-generics/issue-79518-default_trait_method_normalization.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 @@ | ||
#![feature(const_generics, const_evaluatable_checked)] | ||
#![allow(incomplete_features)] | ||
|
||
// This test is a minimized reproduction for #79518 where | ||
// during error handling for the type mismatch we would try | ||
// to evaluate std::mem::size_of::<Self::Assoc> causing an ICE | ||
|
||
trait Foo { | ||
type Assoc: PartialEq; | ||
const AssocInstance: Self::Assoc; | ||
|
||
fn foo() | ||
where | ||
[(); std::mem::size_of::<Self::Assoc>()]: , | ||
{ | ||
Self::AssocInstance == [(); std::mem::size_of::<Self::Assoc>()]; | ||
//~^ Error: mismatched types | ||
} | ||
} | ||
|
||
fn main() {} |
14 changes: 14 additions & 0 deletions
14
src/test/ui/const-generics/issue-79518-default_trait_method_normalization.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,14 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/issue-79518-default_trait_method_normalization.rs:16:32 | ||
| | ||
LL | Self::AssocInstance == [(); std::mem::size_of::<Self::Assoc>()]; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found array `[(); _]` | ||
| | ||
= note: expected associated type `<Self as Foo>::Assoc` | ||
found array `[(); _]` | ||
= help: consider constraining the associated type `<Self as Foo>::Assoc` to `[(); _]` or calling a method that returns `<Self as Foo>::Assoc` | ||
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |