diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2023-09-08 14:10:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-08 14:10:52 +0200 |
| commit | 60327bb8b084a5d4b85bde71d6c7066804b6d2e2 (patch) | |
| tree | dd3650f2dcdb99e49faa58f6a986fc886cd9f96f | |
| parent | 575c3633f8bd4694d62ba47305f2b8818f5f7a9c (diff) | |
| parent | 967410c64031002500534863b8d945b9f21bb1c8 (diff) | |
Rollup merge of #115643 - bvanjoi:fix-115203, r=RalfJung,oli-obk
fix: return early when has tainted in mir-lint Fixes #115203 `a[..]` is of indeterminate size, it had been reported error during borrow check, therefore we skip the mir lint process.
| -rw-r--r-- | compiler/rustc_mir_transform/src/const_prop_lint.rs | 4 | ||||
| -rw-r--r-- | tests/ui/unsized/issue-115203.rs | 11 | ||||
| -rw-r--r-- | tests/ui/unsized/issue-115203.stderr | 19 |
3 files changed, 34 insertions, 0 deletions
diff --git a/compiler/rustc_mir_transform/src/const_prop_lint.rs b/compiler/rustc_mir_transform/src/const_prop_lint.rs index 4b51beed095..b52827a1e88 100644 --- a/compiler/rustc_mir_transform/src/const_prop_lint.rs +++ b/compiler/rustc_mir_transform/src/const_prop_lint.rs @@ -39,6 +39,10 @@ pub struct ConstProp; impl<'tcx> MirLint<'tcx> for ConstProp { fn run_lint(&self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>) { + if body.tainted_by_errors.is_some() { + return; + } + // will be evaluated by miri and produce its errors there if body.source.promoted.is_some() { return; diff --git a/tests/ui/unsized/issue-115203.rs b/tests/ui/unsized/issue-115203.rs new file mode 100644 index 00000000000..5fe7bd64288 --- /dev/null +++ b/tests/ui/unsized/issue-115203.rs @@ -0,0 +1,11 @@ +// compile-flags: --emit link + +fn main() { + let a: [i32; 0] = []; + match [a[..]] { + //~^ ERROR cannot move a value of type `[i32] + //~| ERROR cannot move out of type `[i32]`, a non-copy slice + [[]] => (), + _ => (), + } +} diff --git a/tests/ui/unsized/issue-115203.stderr b/tests/ui/unsized/issue-115203.stderr new file mode 100644 index 00000000000..3ee734988c5 --- /dev/null +++ b/tests/ui/unsized/issue-115203.stderr @@ -0,0 +1,19 @@ +error[E0161]: cannot move a value of type `[i32]` + --> $DIR/issue-115203.rs:5:12 + | +LL | match [a[..]] { + | ^^^^^ the size of `[i32]` cannot be statically determined + +error[E0508]: cannot move out of type `[i32]`, a non-copy slice + --> $DIR/issue-115203.rs:5:12 + | +LL | match [a[..]] { + | ^^^^^ + | | + | cannot move out of here + | move occurs because value has type `[i32]`, which does not implement the `Copy` trait + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0161, E0508. +For more information about an error, try `rustc --explain E0161`. |
