Skip to content

Commit

Permalink
Change a span_bug to span_delayed_bug
Browse files Browse the repository at this point in the history
to fix an ICE caused when a with expression is not a struct
  • Loading branch information
gurry committed Jul 6, 2024
1 parent 5c08cc7 commit ef01d09
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
5 changes: 4 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,10 @@ 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");
self.cx.tcx().dcx().span_delayed_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.

23 changes: 23 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,23 @@
// 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 in this case
// This ICE occurred only when the enclosing
// function was async


// Using 2018 edition to supporess an irrelevant
// error about async fn's
//@ edition:2018

async fn fun() {
enum Foo {
A { x: u32 },
}
let orig = Foo::A { x: 5 };
Foo::A { x: 6, ..orig };
//~^ ERROR functional record update syntax requires a struct
}

fn main() {}
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:19:22
|
LL | Foo::A { x: 6, ..orig };
| ^^^^

error: aborting due to 1 previous error

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

0 comments on commit ef01d09

Please sign in to comment.