Skip to content

Commit 0477588

Browse files
committed
use normalize_erasing_regions and fix other issue
1 parent 7d17d04 commit 0477588

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

compiler/rustc_const_eval/src/transform/validate.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,8 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
680680
let ty = self.tcx.type_of(def_id).instantiate(self.tcx, args);
681681
// If the type we get is opaque, we want to normalize it.
682682
if ty.is_impl_trait() {
683-
let inner_ty = self.tcx.expand_opaque_types(ty).kind();
683+
let inner_ty =
684+
self.tcx.normalize_erasing_regions(self.param_env, ty).kind();
684685
inner_ty
685686
} else {
686687
ty.kind()

compiler/rustc_mir_dataflow/src/impls/initialized.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
use rustc_index::bit_set::{BitSet, ChunkedBitSet};
2-
use rustc_index::Idx;
3-
use rustc_middle::mir::{self, Body, CallReturnPlaces, Location, TerminatorEdges};
4-
use rustc_middle::ty::{self, TyCtxt};
5-
61
use crate::drop_flag_effects_for_function_entry;
72
use crate::drop_flag_effects_for_location;
83
use crate::elaborate_drops::DropFlagState;
@@ -12,6 +7,11 @@ use crate::on_lookup_result_bits;
127
use crate::MoveDataParamEnv;
138
use crate::{drop_flag_effects, on_all_children_bits, on_all_drop_children_bits};
149
use crate::{lattice, AnalysisDomain, GenKill, GenKillAnalysis, MaybeReachable};
10+
use rustc_index::bit_set::{BitSet, ChunkedBitSet};
11+
use rustc_index::Idx;
12+
use rustc_middle::mir::{self, Body, CallReturnPlaces, Location, TerminatorEdges};
13+
use rustc_middle::ty::ParamEnv;
14+
use rustc_middle::ty::{self, TyCtxt};
1515

1616
/// `MaybeInitializedPlaces` tracks all places that might be
1717
/// initialized upon reaching a particular point in the control flow
@@ -759,7 +759,15 @@ fn switch_on_enum_discriminant<'mir, 'tcx>(
759759
mir::StatementKind::Assign(box (lhs, mir::Rvalue::Discriminant(discriminated)))
760760
if *lhs == switch_on =>
761761
{
762-
match discriminated.ty(body, tcx).ty.kind() {
762+
let mut kind = discriminated.ty(body, tcx).ty.kind();
763+
if discriminated.ty(body, tcx).ty.is_impl_trait() {
764+
let ty = tcx.normalize_erasing_regions(
765+
ParamEnv::reveal_all(),
766+
discriminated.ty(body, tcx).ty,
767+
);
768+
kind = ty.kind();
769+
}
770+
match kind {
763771
ty::Adt(def, _) => return Some((*discriminated, *def)),
764772

765773
// `Rvalue::Discriminant` is also used to get the active yield point for a
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// check-pass
2+
3+
#![feature(type_alias_impl_trait)]
4+
5+
fn enum_upvar() {
6+
type T = impl Copy;
7+
let foo: T = Some((1u32, 2u32));
8+
let x = move || match foo {
9+
None => (),
10+
Some((a, b)) => (),
11+
};
12+
}
13+
14+
fn main(){}

0 commit comments

Comments
 (0)