forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#127409 - gurry:127332-ice-with-expr-not-struct, r=oli-obk Emit a wrap expr span_bug only if context is not tainted Fixes rust-lang#127332 The ICE occurs because of this `span_bug`: https://github.com/rust-lang/rust/blob/51917e2e69702e5752bce6a4f3bfd285d0f4ae39/compiler/rustc_hir_typeck/src/expr_use_visitor.rs#L732-L738 which is triggered by the fact that we're trying to use an `enum` in a `with` expression instead of a `struct`. The issue originates in commit rust-lang@814bfe9 from PR rust-lang#127202. As per the title of that commit the ICEing code should not be reachable any more, but looks like it still is. This PR changes the code so that the `span_bug` will be emitted only if the context is not tainted by a previous error.
- Loading branch information
Showing
4 changed files
with
27 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |