@@ -2,16 +2,12 @@ use rustc_data_structures::fx::FxHashSet;
22use rustc_hir:: intravisit:: Visitor ;
33use rustc_hir:: { def:: DefKind , def_id:: LocalDefId } ;
44use rustc_hir:: { intravisit, CRATE_HIR_ID } ;
5- use rustc_infer:: infer:: TyCtxtInferExt ;
65use rustc_middle:: query:: Providers ;
7- use rustc_middle:: traits:: ObligationCause ;
86use rustc_middle:: ty:: util:: { CheckRegions , NotUniqueParam } ;
9- use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeVisitableExt } ;
7+ use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
108use rustc_middle:: ty:: { TypeSuperVisitable , TypeVisitable , TypeVisitor } ;
11- use rustc_span:: def_id:: CRATE_DEF_ID ;
129use rustc_span:: Span ;
1310use rustc_trait_selection:: traits:: check_substs_compatible;
14- use rustc_trait_selection:: traits:: ObligationCtxt ;
1511use std:: ops:: ControlFlow ;
1612
1713use crate :: errors:: { DuplicateArg , NotParam } ;
@@ -139,20 +135,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> {
139135 rustc_hir:: OpaqueTyOrigin :: FnReturn ( _)
140136 | rustc_hir:: OpaqueTyOrigin :: AsyncFn ( _) => { }
141137 rustc_hir:: OpaqueTyOrigin :: TyAlias { in_assoc_ty } => {
142- if in_assoc_ty {
143- // Only associated items can be defining for opaque types in associated types.
144- if let Some ( parent) = self . parent ( ) {
145- let mut current = alias_ty. def_id . expect_local ( ) ;
146- while current != parent && current != CRATE_DEF_ID {
147- current = self . tcx . local_parent ( current) ;
148- }
149- if current != parent {
150- return ControlFlow :: Continue ( ( ) ) ;
151- }
152- } else {
153- return ControlFlow :: Continue ( ( ) ) ;
154- }
155- } else {
138+ if !in_assoc_ty {
156139 if !self . check_tait_defining_scope ( alias_ty. def_id . expect_local ( ) ) {
157140 return ControlFlow :: Continue ( ( ) ) ;
158141 }
@@ -246,28 +229,6 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> {
246229 }
247230 }
248231 }
249-
250- // Normalize trivial projections.
251- let mut infcx = self . tcx . infer_ctxt ( ) ;
252- let infcx = infcx. build ( ) ;
253- let t = if t. has_escaping_bound_vars ( ) {
254- let ( t, _mapped_regions, _mapped_types, _mapped_consts) =
255- rustc_trait_selection:: traits:: project:: BoundVarReplacer :: replace_bound_vars (
256- & infcx,
257- & mut self . universes ,
258- t,
259- ) ;
260- t
261- } else {
262- t
263- } ;
264- let ocx = ObligationCtxt :: new ( & infcx) ;
265- let cause = ObligationCause :: dummy_with_span ( self . span ( ) ) ;
266- let normalized = ocx. normalize ( & cause, self . tcx . param_env ( self . item ) , t) ;
267- trace ! ( ?normalized) ;
268- if normalized != t {
269- normalized. visit_with ( self ) ?;
270- }
271232 }
272233 ty:: Adt ( def, _) if def. did ( ) . is_local ( ) => {
273234 if !self . seen . insert ( def. did ( ) . expect_local ( ) ) {
0 commit comments