Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return early when has tainted in mir-lint #115643

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions compiler/rustc_mir_transform/src/const_prop_lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions tests/ui/unsized/issue-115203.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// compile-flags: --emit link
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unsure about how to label this test header. Only run-fail can reproduce the ice of #115203, but it also requires the case to build successfully. Consequently, I have resorted to using --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
[[]] => (),
_ => (),
}
}
19 changes: 19 additions & 0 deletions tests/ui/unsized/issue-115203.stderr
Original file line number Diff line number Diff line change
@@ -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`.
Loading