Skip to content

Commit 42c7df9

Browse files
committed
Get rid of infer vars in inherent assoc types selection by using EagerResolver folder
1 parent 13cb8dc commit 42c7df9

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ use rustc_hir::def::{CtorOf, DefKind, Namespace, Res};
2626
use rustc_hir::def_id::{DefId, LocalDefId};
2727
use rustc_hir::intravisit::{walk_generics, Visitor as _};
2828
use rustc_hir::{GenericArg, GenericArgs, OpaqueTyOrigin};
29+
use rustc_infer::infer::resolve::EagerResolver;
2930
use rustc_infer::infer::{InferCtxt, InferOk, TyCtxtInferExt};
3031
use rustc_infer::traits::{Obligation, ObligationCause};
3132
use rustc_middle::middle::stability::AllowUnstable;
3233
use rustc_middle::ty::GenericParamDefKind;
3334
use rustc_middle::ty::{
3435
self, Const, GenericArgKind, GenericArgsRef, IsSuggestable, ParamEnv, Predicate, Ty, TyCtxt,
35-
TypeVisitableExt,
36+
TypeFoldable, TypeVisitableExt,
3637
};
3738
use rustc_session::lint::builtin::AMBIGUOUS_ASSOCIATED_ITEMS;
3839
use rustc_span::edit_distance::find_best_match_for_name;
@@ -1648,6 +1649,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
16481649
);
16491650

16501651
let ty = Ty::new_alias(tcx, ty::Inherent, ty::AliasTy::new(tcx, assoc_item, args));
1652+
let ty = ty.fold_with(&mut EagerResolver::new(infcx));
16511653

16521654
Ok(Some((ty, assoc_item)))
16531655
},

compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use super::{search_graph, GoalEvaluationKind};
3333
use super::{search_graph::SearchGraph, Goal};
3434
pub use select::InferCtxtSelectExt;
3535

36-
mod canonical;
36+
pub mod canonical;
3737
mod commit_if_ok;
3838
mod probe;
3939
mod select;

compiler/rustc_trait_selection/src/solve/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use rustc_middle::ty::{
3131
mod alias_relate;
3232
mod assembly;
3333
mod canonicalize;
34-
mod eval_ctxt;
34+
pub mod eval_ctxt;
3535
mod fulfill;
3636
pub mod inspect;
3737
mod normalize;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// check-pass
2+
3+
#![feature(inherent_associated_types)]
4+
#![allow(incomplete_features)]
5+
6+
struct Foo<T>(T);
7+
8+
impl<'a> Foo<fn(&'a ())> {
9+
type Assoc = &'a ();
10+
}
11+
12+
fn bar(_: for<'a> fn(Foo<fn(Foo<fn(&'static ())>::Assoc)>::Assoc)) {}
13+
14+
fn main() {}

0 commit comments

Comments
 (0)