diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2021-02-18 16:57:35 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-18 16:57:35 +0100 |
| commit | 928819a9f7dc0f0a9830f4217021d7d3be6d5936 (patch) | |
| tree | a7ccf2ce834b8b48807ea87180df7cc413f8f47d /src | |
| parent | 66211f6657971bdaf18996400435b6a416aa3343 (diff) | |
| parent | 7e368e57f278b8073193c73001f4efc4af08fdfd (diff) | |
Rollup merge of #82112 - BoxyUwU:tumbleweed, r=varkor
const_generics: Dont evaluate array length const when handling yet another error Same ICE as #82009 except triggered by a different error. cc ``@lcnr`` r? ``@varkor``
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/const-generics/dont-evaluate-array-len-on-err-1.rs | 22 | ||||
| -rw-r--r-- | src/test/ui/const-generics/dont-evaluate-array-len-on-err-1.stderr | 12 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/dont-evaluate-array-len-on-err-1.rs b/src/test/ui/const-generics/dont-evaluate-array-len-on-err-1.rs new file mode 100644 index 00000000000..afef748ff46 --- /dev/null +++ b/src/test/ui/const-generics/dont-evaluate-array-len-on-err-1.rs @@ -0,0 +1,22 @@ +#![feature(const_generics, const_evaluatable_checked)] +#![allow(incomplete_features)] + +// This tests that during error handling for the "trait not implemented" error +// we dont try to evaluate std::mem::size_of::<Self::Assoc> causing an ICE + +struct Adt; + +trait Foo { + type Assoc; + fn foo() + where + [Adt; std::mem::size_of::<Self::Assoc>()]: , + { + <[Adt; std::mem::size_of::<Self::Assoc>()] as Foo>::bar() + //~^ Error: the trait bound + } + + fn bar() {} +} + +fn main() {} diff --git a/src/test/ui/const-generics/dont-evaluate-array-len-on-err-1.stderr b/src/test/ui/const-generics/dont-evaluate-array-len-on-err-1.stderr new file mode 100644 index 00000000000..d894fa90ba9 --- /dev/null +++ b/src/test/ui/const-generics/dont-evaluate-array-len-on-err-1.stderr @@ -0,0 +1,12 @@ +error[E0277]: the trait bound `[Adt; _]: Foo` is not satisfied + --> $DIR/dont-evaluate-array-len-on-err-1.rs:15:9 + | +LL | <[Adt; std::mem::size_of::<Self::Assoc>()] as Foo>::bar() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `[Adt; _]` +... +LL | fn bar() {} + | -------- required by `Foo::bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. |
