Skip to content

Commit 0a49057

Browse files
committed
Auto merge of #75443 - lcnr:opaque-normalize, r=nikomatsakis
allow escaping bound vars when normalizing `ty::Opaque` implements #75313 (comment) and fixes #75313 cc @eddyb @RalfJung r? @nikomatsakis
2 parents a0c290f + d2398ee commit 0a49057

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

src/librustc_trait_selection/traits/project.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,7 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> {
324324

325325
let ty = ty.super_fold_with(self);
326326
match ty.kind {
327-
ty::Opaque(def_id, substs) if !substs.has_escaping_bound_vars() => {
328-
// (*)
327+
ty::Opaque(def_id, substs) => {
329328
// Only normalize `impl Trait` after type-checking, usually in codegen.
330329
match self.param_env.reveal() {
331330
Reveal::UserFacing => ty,
@@ -353,9 +352,7 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> {
353352
}
354353

355354
ty::Projection(ref data) if !data.has_escaping_bound_vars() => {
356-
// (*)
357-
358-
// (*) This is kind of hacky -- we need to be able to
355+
// This is kind of hacky -- we need to be able to
359356
// handle normalization within binders because
360357
// otherwise we wind up a need to normalize when doing
361358
// trait matching (since you can have a trait

src/librustc_trait_selection/traits/query/normalize.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
101101

102102
let ty = ty.super_fold_with(self);
103103
match ty.kind {
104-
ty::Opaque(def_id, substs) if !substs.has_escaping_bound_vars() => {
105-
// (*)
104+
ty::Opaque(def_id, substs) => {
106105
// Only normalize `impl Trait` after type-checking, usually in codegen.
107106
match self.param_env.reveal() {
108107
Reveal::UserFacing => ty,
@@ -140,8 +139,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
140139
}
141140

142141
ty::Projection(ref data) if !data.has_escaping_bound_vars() => {
143-
// (*)
144-
// (*) This is kind of hacky -- we need to be able to
142+
// This is kind of hacky -- we need to be able to
145143
// handle normalization within binders because
146144
// otherwise we wind up a need to normalize when doing
147145
// trait matching (since you can have a trait
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// build-pass
2+
3+
// This used to fail MIR validation due to the types on both sides of
4+
// an assignment not being equal.
5+
// The failure doesn't occur with a check-only build.
6+
7+
fn iter_slice<'a, T>(xs: &'a [T]) -> impl Iterator<Item = &'a T> {
8+
xs.iter()
9+
}
10+
11+
fn main() {
12+
iter_slice::<()> as fn(_) -> _;
13+
}

0 commit comments

Comments
 (0)