forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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#137742 - mu001999-contrib:fix-137708, r=com…
…piler-errors unconditionally lower match arm even if it's unneeded for never pattern in match fixes rust-lang#137708 Lowering arm body is skipped when lowering match arm with never pattern, but we may need the HirId for DefId in the body in later passes. And then we got the ICE `No HirId for DefId`. Fixes this by lowering the arm body even if it's unneeded for never pattern in match, so that we can generate HirId and use it then. r? ``@compiler-errors``
- Loading branch information
Showing
3 changed files
with
53 additions
and
2 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 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,12 @@ | ||
fn a() { | ||
match 0 { | ||
! => || { //~ ERROR `!` patterns are experimental | ||
//~^ ERROR a never pattern is always unreachable | ||
//~^^ ERROR mismatched types | ||
use std::ops::Add; | ||
0.add(1) | ||
}, | ||
} | ||
} | ||
|
||
fn main() {} |
36 changes: 36 additions & 0 deletions
36
tests/ui/never_type/unused_trait_in_never_pattern_body.stderr
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,36 @@ | ||
error[E0658]: `!` patterns are experimental | ||
--> $DIR/unused_trait_in_never_pattern_body.rs:3:9 | ||
| | ||
LL | ! => || { | ||
| ^ | ||
| | ||
= note: see issue #118155 <https://github.com/rust-lang/rust/issues/118155> for more information | ||
= help: add `#![feature(never_patterns)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error: a never pattern is always unreachable | ||
--> $DIR/unused_trait_in_never_pattern_body.rs:3:14 | ||
| | ||
LL | ! => || { | ||
| ______________^ | ||
LL | | | ||
LL | | | ||
LL | | use std::ops::Add; | ||
LL | | 0.add(1) | ||
LL | | }, | ||
| | ^ | ||
| | | | ||
| |_________this will never be executed | ||
| help: remove this expression | ||
|
||
error: mismatched types | ||
--> $DIR/unused_trait_in_never_pattern_body.rs:3:9 | ||
| | ||
LL | ! => || { | ||
| ^ a never pattern must be used on an uninhabited type | ||
| | ||
= note: the matched value is of type `i32` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0658`. |