loop match: handle opaque patterns
fixes issue 143203
This commit is contained in:
parent
aa7cc5d2f4
commit
8fdf0ef0ae
4 changed files with 30 additions and 5 deletions
|
|
@ -2970,6 +2970,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
Constructor::Wildcard => true,
|
||||
|
||||
// Opaque patterns must not be matched on structurally.
|
||||
Constructor::Opaque(_) => false,
|
||||
|
||||
// These we may eventually support:
|
||||
Constructor::Struct
|
||||
| Constructor::Ref
|
||||
|
|
@ -2980,8 +2983,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
| Constructor::Str(_) => bug!("unsupported pattern constructor {:?}", pat.ctor()),
|
||||
|
||||
// These should never occur here:
|
||||
Constructor::Opaque(_)
|
||||
| Constructor::Never
|
||||
Constructor::Never
|
||||
| Constructor::NonExhaustive
|
||||
| Constructor::Hidden
|
||||
| Constructor::Missing
|
||||
|
|
|
|||
|
|
@ -1230,7 +1230,6 @@ pub(crate) struct ConstContinueMissingValue {
|
|||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(mir_build_const_continue_unknown_jump_target)]
|
||||
#[note]
|
||||
pub(crate) struct ConstContinueUnknownJumpTarget {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
|
|
|
|||
|
|
@ -172,3 +172,21 @@ fn non_exhaustive() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn invalid_range_pattern(state: f32) {
|
||||
#[loop_match]
|
||||
loop {
|
||||
state = 'blk: {
|
||||
match state {
|
||||
1.0 => {
|
||||
#[const_continue]
|
||||
break 'blk 2.5;
|
||||
}
|
||||
4.0..3.0 => {
|
||||
//~^ ERROR lower range bound must be less than upper
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,7 +109,13 @@ LL ~ State::A => State::B,
|
|||
LL ~ State::B | State::C => todo!(),
|
||||
|
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
error[E0579]: lower range bound must be less than upper
|
||||
--> $DIR/invalid.rs:185:17
|
||||
|
|
||||
LL | 4.0..3.0 => {
|
||||
| ^^^^^^^^
|
||||
|
||||
Some errors have detailed explanations: E0004, E0308.
|
||||
error: aborting due to 14 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0004, E0308, E0579.
|
||||
For more information about an error, try `rustc --explain E0004`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue