Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion compiler/rustc_pattern_analysis/src/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -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() {}
Original file line number Diff line number Diff line change
@@ -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