Skip to content

Commit ef01d09

Browse files
committed
Change a span_bug to span_delayed_bug
to fix an ICE caused when a with expression is not a struct
1 parent 5c08cc7 commit ef01d09

File tree

4 files changed

+36
-10
lines changed

4 files changed

+36
-10
lines changed

compiler/rustc_hir_typeck/src/expr_use_visitor.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,10 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
734734
// struct; however, when EUV is run during typeck, it
735735
// may not. This will generate an error earlier in typeck,
736736
// so we can just ignore it.
737-
span_bug!(with_expr.span, "with expression doesn't evaluate to a struct");
737+
self.cx.tcx().dcx().span_delayed_bug(
738+
with_expr.span,
739+
"with expression doesn't evaluate to a struct",
740+
);
738741
}
739742
}
740743

tests/crashes/127332.rs

-9
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Regression test for ICE #127332
2+
3+
// Tests that we do not ICE when a with expr
4+
// is not a struct but something else like an
5+
// enum in this case
6+
// This ICE occurred only when the enclosing
7+
// function was async
8+
9+
10+
// Using 2018 edition to supporess an irrelevant
11+
// error about async fn's
12+
//@ edition:2018
13+
14+
async fn fun() {
15+
enum Foo {
16+
A { x: u32 },
17+
}
18+
let orig = Foo::A { x: 5 };
19+
Foo::A { x: 6, ..orig };
20+
//~^ ERROR functional record update syntax requires a struct
21+
}
22+
23+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0436]: functional record update syntax requires a struct
2+
--> $DIR/ice-with-expr-not-struct-127332.rs:19:22
3+
|
4+
LL | Foo::A { x: 6, ..orig };
5+
| ^^^^
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0436`.

0 commit comments

Comments
 (0)