Rollup merge of #134103 - compiler-errors:never-pat-range, r=oli-obk
Don't ICE when encountering never in range pattern Fixes #133947 r? oli-obk
This commit is contained in:
commit
c5a83862a2
3 changed files with 32 additions and 1 deletions
|
@ -403,6 +403,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
})
|
})
|
||||||
| hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Const(..), .. }) => true,
|
| hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Const(..), .. }) => true,
|
||||||
|
|
||||||
|
hir::Node::Pat(_) => {
|
||||||
|
self.dcx().span_delayed_bug(expr.span, "place expr not allowed in pattern");
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
// These nodes do not have direct sub-exprs.
|
// These nodes do not have direct sub-exprs.
|
||||||
hir::Node::Param(_)
|
hir::Node::Param(_)
|
||||||
| hir::Node::Item(_)
|
| hir::Node::Item(_)
|
||||||
|
@ -415,7 +420,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
| hir::Node::Ty(_)
|
| hir::Node::Ty(_)
|
||||||
| hir::Node::AssocItemConstraint(_)
|
| hir::Node::AssocItemConstraint(_)
|
||||||
| hir::Node::TraitRef(_)
|
| hir::Node::TraitRef(_)
|
||||||
| hir::Node::Pat(_)
|
|
||||||
| hir::Node::PatField(_)
|
| hir::Node::PatField(_)
|
||||||
| hir::Node::LetStmt(_)
|
| hir::Node::LetStmt(_)
|
||||||
| hir::Node::Synthetic
|
| hir::Node::Synthetic
|
||||||
|
|
16
tests/ui/never_type/never-in-range-pat.rs
Normal file
16
tests/ui/never_type/never-in-range-pat.rs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
// Regression test for <https://github.com/rust-lang/rust/issues/133947>.
|
||||||
|
|
||||||
|
// Make sure we don't ICE when there's `!` in a range pattern.
|
||||||
|
//
|
||||||
|
// This shouldn't be allowed anyways, but we only deny it during MIR
|
||||||
|
// building, so make sure we handle it semi-gracefully during typeck.
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let x: !;
|
||||||
|
match 1 {
|
||||||
|
0..x => {}
|
||||||
|
//~^ ERROR only `char` and numeric types are allowed in range patterns
|
||||||
|
}
|
||||||
|
}
|
11
tests/ui/never_type/never-in-range-pat.stderr
Normal file
11
tests/ui/never_type/never-in-range-pat.stderr
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
error[E0029]: only `char` and numeric types are allowed in range patterns
|
||||||
|
--> $DIR/never-in-range-pat.rs:13:12
|
||||||
|
|
|
||||||
|
LL | 0..x => {}
|
||||||
|
| - ^ this is of type `!` but it should be `char` or numeric
|
||||||
|
| |
|
||||||
|
| this is of type `{integer}`
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0029`.
|
Loading…
Add table
Reference in a new issue