From f7679d050793304eff9ff2a46a824cc5495e6f93 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Wed, 4 Sep 2024 12:29:44 +0200 Subject: [PATCH] propagate `tainted_by_errors` in `MirBorrowckCtxt::emit_errors` --- compiler/rustc_borrowck/src/lib.rs | 2 +- tests/ui/consts/missing_assoc_const_type.rs | 2 +- tests/ui/consts/missing_assoc_const_type.stderr | 8 +++++++- .../{crashes/124164.rs => ui/static/missing-type.rs} | 3 ++- tests/ui/static/missing-type.stderr | 8 ++++++++ .../126896.rs => ui/type-alias-impl-trait/taint.rs} | 8 ++++---- tests/ui/type-alias-impl-trait/taint.stderr | 12 ++++++++++++ 7 files changed, 35 insertions(+), 8 deletions(-) rename tests/{crashes/124164.rs => ui/static/missing-type.rs} (52%) create mode 100644 tests/ui/static/missing-type.stderr rename tests/{crashes/126896.rs => ui/type-alias-impl-trait/taint.rs} (59%) create mode 100644 tests/ui/type-alias-impl-trait/taint.stderr diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index ffb350b1d1f..d40dcfa5805 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -2522,7 +2522,7 @@ mod diags { } pub(crate) fn emit_errors(&mut self) -> Option { - let mut res = None; + let mut res = self.infcx.tainted_by_errors(); // Buffer any move errors that we collected and de-duplicated. for (_, (_, diag)) in std::mem::take(&mut self.diags.buffered_move_errors) { diff --git a/tests/ui/consts/missing_assoc_const_type.rs b/tests/ui/consts/missing_assoc_const_type.rs index 8d95e3dca63..633998e9bc1 100644 --- a/tests/ui/consts/missing_assoc_const_type.rs +++ b/tests/ui/consts/missing_assoc_const_type.rs @@ -16,7 +16,7 @@ impl Range for TwoDigits { const fn digits(x: u8) -> usize { match x { - TwoDigits::FIRST..=TwoDigits::LAST => 0, + TwoDigits::FIRST..=TwoDigits::LAST => 0, //~ ERROR: could not evaluate constant pattern 0..=9 | 100..=255 => panic!(), } } diff --git a/tests/ui/consts/missing_assoc_const_type.stderr b/tests/ui/consts/missing_assoc_const_type.stderr index 28af1f0f321..ef7ff962d2d 100644 --- a/tests/ui/consts/missing_assoc_const_type.stderr +++ b/tests/ui/consts/missing_assoc_const_type.stderr @@ -4,5 +4,11 @@ error: missing type for `const` item LL | const FIRST: = 10; | ^ help: provide a type for the associated constant: `u8` -error: aborting due to 1 previous error +error: could not evaluate constant pattern + --> $DIR/missing_assoc_const_type.rs:19:9 + | +LL | TwoDigits::FIRST..=TwoDigits::LAST => 0, + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors diff --git a/tests/crashes/124164.rs b/tests/ui/static/missing-type.rs similarity index 52% rename from tests/crashes/124164.rs rename to tests/ui/static/missing-type.rs index 8c9b4bddbe8..2569f47b7c3 100644 --- a/tests/crashes/124164.rs +++ b/tests/ui/static/missing-type.rs @@ -1,4 +1,5 @@ -//@ known-bug: #124164 +// reported as #124164 static S_COUNT: = std::sync::atomic::AtomicUsize::new(0); +//~^ ERROR: missing type for `static` item fn main() {} diff --git a/tests/ui/static/missing-type.stderr b/tests/ui/static/missing-type.stderr new file mode 100644 index 00000000000..6489ceb700a --- /dev/null +++ b/tests/ui/static/missing-type.stderr @@ -0,0 +1,8 @@ +error: missing type for `static` item + --> $DIR/missing-type.rs:2:16 + | +LL | static S_COUNT: = std::sync::atomic::AtomicUsize::new(0); + | ^ help: provide a type for the static variable: `AtomicUsize` + +error: aborting due to 1 previous error + diff --git a/tests/crashes/126896.rs b/tests/ui/type-alias-impl-trait/taint.rs similarity index 59% rename from tests/crashes/126896.rs rename to tests/ui/type-alias-impl-trait/taint.rs index 49c539d7acc..dfb947637c0 100644 --- a/tests/crashes/126896.rs +++ b/tests/ui/type-alias-impl-trait/taint.rs @@ -1,6 +1,7 @@ -//@ known-bug: rust-lang/rust#126896 //@ compile-flags: -Zvalidate-mir -Zinline-mir=yes +// reported as rust-lang/rust#126896 + #![feature(type_alias_impl_trait)] type Two<'a, 'b> = impl std::fmt::Debug; @@ -9,9 +10,8 @@ fn set(x: &mut isize) -> isize { } fn d(x: Two) { - let c1 = || set(x); + let c1 = || set(x); //~ ERROR: expected generic lifetime parameter, found `'_` c1; } -fn main() { -} +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/taint.stderr b/tests/ui/type-alias-impl-trait/taint.stderr new file mode 100644 index 00000000000..17fcd4b7e93 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/taint.stderr @@ -0,0 +1,12 @@ +error[E0792]: expected generic lifetime parameter, found `'_` + --> $DIR/taint.rs:13:17 + | +LL | type Two<'a, 'b> = impl std::fmt::Debug; + | -- this generic parameter must be used with a generic lifetime parameter +... +LL | let c1 = || set(x); + | ^^^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0792`.