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

Emit a wrap expr span_bug only if context is not tainted #127409

Merged
merged 1 commit into from
Jul 7, 2024
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: 3 additions & 1 deletion compiler/rustc_hir_typeck/src/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,9 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
// struct; however, when EUV is run during typeck, it
// may not. This will generate an error earlier in typeck,
// so we can just ignore it.
span_bug!(with_expr.span, "with expression doesn't evaluate to a struct");
if self.cx.tainted_by_errors().is_ok() {
gurry marked this conversation as resolved.
Show resolved Hide resolved
span_bug!(with_expr.span, "with expression doesn't evaluate to a struct");
}
}
}

Expand Down
9 changes: 0 additions & 9 deletions tests/crashes/127332.rs

This file was deleted.

15 changes: 15 additions & 0 deletions tests/ui/typeck/ice-with-expr-not-struct-127332.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Regression test for ICE #127332

// Tests that we do not ICE when a with expr is
// not a struct but something else like an enum

fn main() {
let x = || {
enum Foo {
A { x: u32 },
}
let orig = Foo::A { x: 5 };
Foo::A { x: 6, ..orig };
//~^ ERROR functional record update syntax requires a struct
};
}
9 changes: 9 additions & 0 deletions tests/ui/typeck/ice-with-expr-not-struct-127332.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0436]: functional record update syntax requires a struct
--> $DIR/ice-with-expr-not-struct-127332.rs:12:26
|
LL | Foo::A { x: 6, ..orig };
| ^^^^

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0436`.
Loading