@@ -60,7 +60,7 @@ impl<'tcx> InferCtxt<'tcx> {
60
60
let replace_opaque_type = |def_id : DefId | {
61
61
def_id
62
62
. as_local ( )
63
- . map_or ( false , |def_id| self . opaque_type_origin ( def_id, span, param_env ) . is_some ( ) )
63
+ . map_or ( false , |def_id| self . opaque_type_origin ( def_id, span) . is_some ( ) )
64
64
} ;
65
65
let value = value. fold_with ( & mut BottomUpFolder {
66
66
tcx : self . tcx ,
@@ -145,7 +145,7 @@ impl<'tcx> InferCtxt<'tcx> {
145
145
// let x = || foo(); // returns the Opaque assoc with `foo`
146
146
// }
147
147
// ```
148
- self . opaque_type_origin ( def_id, cause. span , param_env ) ?
148
+ self . opaque_type_origin ( def_id, cause. span ) ?
149
149
}
150
150
DefiningAnchor :: Bubble => self . opaque_ty_origin_unchecked ( def_id, cause. span ) ,
151
151
DefiningAnchor :: Error => return None ,
@@ -156,10 +156,9 @@ impl<'tcx> InferCtxt<'tcx> {
156
156
// no one encounters it in practice.
157
157
// It does occur however in `fn fut() -> impl Future<Output = i32> { async { 42 } }`,
158
158
// where it is of no concern, so we only check for TAITs.
159
- if let Some ( OpaqueTyOrigin :: TyAlias ) =
160
- b_def_id. as_local ( ) . and_then ( |b_def_id| {
161
- self . opaque_type_origin ( b_def_id, cause. span , param_env)
162
- } )
159
+ if let Some ( OpaqueTyOrigin :: TyAlias ) = b_def_id
160
+ . as_local ( )
161
+ . and_then ( |b_def_id| self . opaque_type_origin ( b_def_id, cause. span ) )
163
162
{
164
163
self . tcx . sess . emit_err ( OpaqueHiddenTypeDiag {
165
164
span : cause. span ,
@@ -374,12 +373,7 @@ impl<'tcx> InferCtxt<'tcx> {
374
373
}
375
374
376
375
#[ instrument( skip( self ) , level = "trace" , ret) ]
377
- pub fn opaque_type_origin (
378
- & self ,
379
- def_id : LocalDefId ,
380
- span : Span ,
381
- param_env : ty:: ParamEnv < ' tcx > ,
382
- ) -> Option < OpaqueTyOrigin > {
376
+ pub fn opaque_type_origin ( & self , def_id : LocalDefId , span : Span ) -> Option < OpaqueTyOrigin > {
383
377
let parent_def_id = match self . defining_use_anchor {
384
378
DefiningAnchor :: Bubble | DefiningAnchor :: Error => return None ,
385
379
DefiningAnchor :: Bind ( bind) => bind,
@@ -400,9 +394,7 @@ impl<'tcx> InferCtxt<'tcx> {
400
394
// Anonymous `impl Trait`
401
395
hir:: OpaqueTyOrigin :: FnReturn ( parent) => parent == parent_def_id,
402
396
// Named `type Foo = impl Bar;`
403
- hir:: OpaqueTyOrigin :: TyAlias => {
404
- may_define_opaque_type ( self . tcx , parent_def_id, def_id, param_env)
405
- }
397
+ hir:: OpaqueTyOrigin :: TyAlias => may_define_opaque_type ( self . tcx , parent_def_id, def_id) ,
406
398
} ;
407
399
trace ! ( ?origin) ;
408
400
in_definition_scope. then_some ( * origin)
@@ -650,8 +642,8 @@ fn may_define_opaque_type<'tcx>(
650
642
tcx : TyCtxt < ' tcx > ,
651
643
def_id : LocalDefId ,
652
644
opaque_def_id : LocalDefId ,
653
- param_env : ty:: ParamEnv < ' tcx > ,
654
645
) -> bool {
646
+ let param_env = tcx. param_env ( def_id) ;
655
647
let opaque_hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( opaque_def_id) ;
656
648
let mut hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( def_id) ;
657
649
0 commit comments