Skip to content

Commit

Permalink
Get rid of infer vars in inherent assoc types selection by using Eage…
Browse files Browse the repository at this point in the history
…rResolver folder
  • Loading branch information
spastorino committed Nov 24, 2023
1 parent 13cb8dc commit 42c7df9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
4 changes: 3 additions & 1 deletion compiler/rustc_hir_analysis/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ use rustc_hir::def::{CtorOf, DefKind, Namespace, Res};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::intravisit::{walk_generics, Visitor as _};
use rustc_hir::{GenericArg, GenericArgs, OpaqueTyOrigin};
use rustc_infer::infer::resolve::EagerResolver;
use rustc_infer::infer::{InferCtxt, InferOk, TyCtxtInferExt};
use rustc_infer::traits::{Obligation, ObligationCause};
use rustc_middle::middle::stability::AllowUnstable;
use rustc_middle::ty::GenericParamDefKind;
use rustc_middle::ty::{
self, Const, GenericArgKind, GenericArgsRef, IsSuggestable, ParamEnv, Predicate, Ty, TyCtxt,
TypeVisitableExt,
TypeFoldable, TypeVisitableExt,
};
use rustc_session::lint::builtin::AMBIGUOUS_ASSOCIATED_ITEMS;
use rustc_span::edit_distance::find_best_match_for_name;
Expand Down Expand Up @@ -1648,6 +1649,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
);

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

Ok(Some((ty, assoc_item)))
},
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use super::{search_graph, GoalEvaluationKind};
use super::{search_graph::SearchGraph, Goal};
pub use select::InferCtxtSelectExt;

mod canonical;
pub mod canonical;
mod commit_if_ok;
mod probe;
mod select;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/solve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use rustc_middle::ty::{
mod alias_relate;
mod assembly;
mod canonicalize;
mod eval_ctxt;
pub mod eval_ctxt;
mod fulfill;
pub mod inspect;
mod normalize;
Expand Down
14 changes: 14 additions & 0 deletions tests/ui/associated-inherent-types/assoc-inherent-late-bound.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// check-pass

#![feature(inherent_associated_types)]
#![allow(incomplete_features)]

struct Foo<T>(T);

impl<'a> Foo<fn(&'a ())> {
type Assoc = &'a ();
}

fn bar(_: for<'a> fn(Foo<fn(Foo<fn(&'static ())>::Assoc)>::Assoc)) {}

fn main() {}

0 comments on commit 42c7df9

Please sign in to comment.