@@ -2,16 +2,12 @@ use rustc_data_structures::fx::FxHashSet;
2
2
use rustc_hir:: intravisit:: Visitor ;
3
3
use rustc_hir:: { def:: DefKind , def_id:: LocalDefId } ;
4
4
use rustc_hir:: { intravisit, CRATE_HIR_ID } ;
5
- use rustc_infer:: infer:: TyCtxtInferExt ;
6
5
use rustc_middle:: query:: Providers ;
7
- use rustc_middle:: traits:: ObligationCause ;
8
6
use rustc_middle:: ty:: util:: { CheckRegions , NotUniqueParam } ;
9
- use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeVisitableExt } ;
7
+ use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
10
8
use rustc_middle:: ty:: { TypeSuperVisitable , TypeVisitable , TypeVisitor } ;
11
- use rustc_span:: def_id:: CRATE_DEF_ID ;
12
9
use rustc_span:: Span ;
13
10
use rustc_trait_selection:: traits:: check_substs_compatible;
14
- use rustc_trait_selection:: traits:: ObligationCtxt ;
15
11
use std:: ops:: ControlFlow ;
16
12
17
13
use crate :: errors:: { DuplicateArg , NotParam } ;
@@ -139,20 +135,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> {
139
135
rustc_hir:: OpaqueTyOrigin :: FnReturn ( _)
140
136
| rustc_hir:: OpaqueTyOrigin :: AsyncFn ( _) => { }
141
137
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 {
156
139
if !self . check_tait_defining_scope ( alias_ty. def_id . expect_local ( ) ) {
157
140
return ControlFlow :: Continue ( ( ) ) ;
158
141
}
@@ -246,28 +229,6 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> {
246
229
}
247
230
}
248
231
}
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
- }
271
232
}
272
233
ty:: Adt ( def, _) if def. did ( ) . is_local ( ) => {
273
234
if !self . seen . insert ( def. did ( ) . expect_local ( ) ) {
0 commit comments