Move a span_bug under a condition that cx is tainted
Fixes an ICE caused when a with expression is not a struct
This commit is contained in:
parent
5c08cc765a
commit
9da3638c6a
@ -734,7 +734,9 @@ fn walk_struct_expr<'hir>(
|
||||
// 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() {
|
||||
span_bug!(with_expr.span, "with expression doesn't evaluate to a struct");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
//@ known-bug: rust-lang/rust #127332
|
||||
|
||||
async fn fun() {
|
||||
enum Foo {
|
||||
A { x: u32 },
|
||||
}
|
||||
let orig = Foo::A { x: 5 };
|
||||
Foo::A { x: 6, ..orig };
|
||||
}
|
15
tests/ui/typeck/ice-with-expr-not-struct-127332.rs
Normal file
15
tests/ui/typeck/ice-with-expr-not-struct-127332.rs
Normal file
@ -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
tests/ui/typeck/ice-with-expr-not-struct-127332.stderr
Normal file
9
tests/ui/typeck/ice-with-expr-not-struct-127332.stderr
Normal file
@ -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…
Reference in New Issue
Block a user