mirror of
https://github.com/rust-lang/rust.git
synced 2025-11-25 13:27:08 +00:00
fix: Do not ICE when missing match arm with ill-formed subty is met
This commit is contained in:
parent
95aeb46965
commit
dae003b04b
@ -191,7 +191,18 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
|
||||
variant.fields.iter().map(move |field| {
|
||||
let ty = field.ty(self.tcx, args);
|
||||
// `field.ty()` doesn't normalize after instantiating.
|
||||
let ty = self.tcx.normalize_erasing_regions(self.typing_env, ty);
|
||||
let ty =
|
||||
self.tcx.try_normalize_erasing_regions(self.typing_env, ty).unwrap_or_else(|e| {
|
||||
self.tcx.dcx().span_delayed_bug(
|
||||
self.scrut_span,
|
||||
format!(
|
||||
"Failed to normalize {:?} in typing_env={:?} while getting variant sub tys for {ty:?}",
|
||||
e.get_type_for_failure(),
|
||||
self.typing_env,
|
||||
),
|
||||
);
|
||||
ty
|
||||
});
|
||||
let ty = self.reveal_opaque_ty(ty);
|
||||
(field, ty)
|
||||
})
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
trait WhereTrait {
|
||||
type Type;
|
||||
}
|
||||
|
||||
fn foo(e: Enum) {
|
||||
if let Enum::Map(_) = e {}
|
||||
|
||||
match e {
|
||||
//~^ ERROR: non-exhaustive patterns: `Enum::Map2(_)` not covered
|
||||
Enum::Map(_) => (),
|
||||
}
|
||||
}
|
||||
|
||||
enum Enum {
|
||||
Map(()),
|
||||
Map2(<() as WhereTrait>::Type),
|
||||
//~^ ERROR: the trait bound `(): WhereTrait` is not satisfied
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@ -0,0 +1,37 @@
|
||||
error[E0277]: the trait bound `(): WhereTrait` is not satisfied
|
||||
--> $DIR/missing-ctor-with-ill-formed-inner-ty-issue-148192.rs:16:10
|
||||
|
|
||||
LL | Map2(<() as WhereTrait>::Type),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `WhereTrait` is not implemented for `()`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/missing-ctor-with-ill-formed-inner-ty-issue-148192.rs:1:1
|
||||
|
|
||||
LL | trait WhereTrait {
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `Enum::Map2(_)` not covered
|
||||
--> $DIR/missing-ctor-with-ill-formed-inner-ty-issue-148192.rs:8:11
|
||||
|
|
||||
LL | match e {
|
||||
| ^ pattern `Enum::Map2(_)` not covered
|
||||
|
|
||||
note: `Enum` defined here
|
||||
--> $DIR/missing-ctor-with-ill-formed-inner-ty-issue-148192.rs:14:6
|
||||
|
|
||||
LL | enum Enum {
|
||||
| ^^^^
|
||||
LL | Map(()),
|
||||
LL | Map2(<() as WhereTrait>::Type),
|
||||
| ---- not covered
|
||||
= note: the matched value is of type `Enum`
|
||||
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
||||
|
|
||||
LL ~ Enum::Map(_) => (),
|
||||
LL ~ Enum::Map2(_) => todo!(),
|
||||
|
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0004, E0277.
|
||||
For more information about an error, try `rustc --explain E0004`.
|
||||
Loading…
x
Reference in New Issue
Block a user