@@ -26,12 +26,12 @@ use rustc_hir::def::{CtorOf, DefKind, Namespace, Res};
26
26
use rustc_hir:: def_id:: { DefId , LocalDefId } ;
27
27
use rustc_hir:: intravisit:: { walk_generics, Visitor as _} ;
28
28
use rustc_hir:: { GenericArg , GenericArgs , OpaqueTyOrigin } ;
29
- use rustc_infer:: infer:: { InferCtxt , InferOk , TyCtxtInferExt } ;
30
- use rustc_infer:: traits:: { Obligation , ObligationCause } ;
29
+ use rustc_infer:: infer:: { InferCtxt , TyCtxtInferExt } ;
30
+ use rustc_infer:: traits:: ObligationCause ;
31
31
use rustc_middle:: middle:: stability:: AllowUnstable ;
32
32
use rustc_middle:: ty:: GenericParamDefKind ;
33
33
use rustc_middle:: ty:: {
34
- self , Const , GenericArgKind , GenericArgsRef , IsSuggestable , ParamEnv , Predicate , Ty , TyCtxt ,
34
+ self , Const , GenericArgKind , GenericArgsRef , IsSuggestable , ParamEnv , Ty , TyCtxt ,
35
35
TypeVisitableExt ,
36
36
} ;
37
37
use rustc_session:: lint:: builtin:: AMBIGUOUS_ASSOCIATED_ITEMS ;
@@ -40,7 +40,7 @@ use rustc_span::symbol::{kw, Ident, Symbol};
40
40
use rustc_span:: { sym, BytePos , Span , DUMMY_SP } ;
41
41
use rustc_target:: spec:: abi;
42
42
use rustc_trait_selection:: traits:: wf:: object_region_bounds;
43
- use rustc_trait_selection:: traits:: { self , NormalizeExt , ObligationCtxt } ;
43
+ use rustc_trait_selection:: traits:: { self , ObligationCtxt } ;
44
44
45
45
use std:: fmt:: Display ;
46
46
use std:: slice;
@@ -1606,52 +1606,40 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1606
1606
// FIXME(inherent_associated_types): Acquiring the ParamEnv this early leads to cycle errors
1607
1607
// when inside of an ADT (#108491) or where clause.
1608
1608
let param_env = tcx. param_env ( block. owner ) ;
1609
- let cause = ObligationCause :: misc ( span, block. owner . def_id ) ;
1610
1609
1611
1610
let mut universes = if self_ty. has_escaping_bound_vars ( ) {
1612
1611
vec ! [ None ; self_ty. outer_exclusive_binder( ) . as_usize( ) ]
1613
1612
} else {
1614
1613
vec ! [ ]
1615
1614
} ;
1616
1615
1617
- crate :: traits:: project:: with_replaced_escaping_bound_vars (
1618
- infcx,
1619
- & mut universes,
1620
- self_ty,
1621
- |self_ty| {
1622
- let tcx = self . tcx ( ) ;
1623
- let InferOk { value : self_ty, obligations } =
1624
- infcx. at ( & cause, param_env) . normalize ( self_ty) ;
1625
-
1626
- let ( impl_, ( assoc_item, def_scope) ) = self . select_inherent_assoc_type_candidates (
1627
- infcx,
1628
- name,
1629
- span,
1630
- self_ty,
1631
- cause,
1632
- param_env,
1633
- obligations,
1634
- candidates,
1635
- ) ?;
1636
-
1637
- self . check_assoc_ty ( assoc_item, name, def_scope, block, span) ;
1638
-
1639
- // FIXME(fmease): Currently creating throwaway `parent_args` to please
1640
- // `create_args_for_associated_item`. Modify the latter instead (or sth. similar) to
1641
- // not require the parent args logic.
1642
- let parent_args = ty:: GenericArgs :: identity_for_item ( tcx, impl_) ;
1643
- let args =
1644
- self . create_args_for_associated_item ( span, assoc_item, segment, parent_args) ;
1645
- let args = tcx. mk_args_from_iter (
1646
- std:: iter:: once ( ty:: GenericArg :: from ( self_ty) )
1647
- . chain ( args. into_iter ( ) . skip ( parent_args. len ( ) ) ) ,
1648
- ) ;
1616
+ let ( impl_, ( assoc_item, def_scope) ) =
1617
+ crate :: traits:: project:: with_replaced_escaping_bound_vars (
1618
+ infcx,
1619
+ & mut universes,
1620
+ self_ty,
1621
+ |self_ty| {
1622
+ self . select_inherent_assoc_type_candidates (
1623
+ infcx, name, span, self_ty, param_env, candidates,
1624
+ )
1625
+ } ,
1626
+ ) ?;
1627
+
1628
+ self . check_assoc_ty ( assoc_item, name, def_scope, block, span) ;
1629
+
1630
+ // FIXME(fmease): Currently creating throwaway `parent_args` to please
1631
+ // `create_args_for_associated_item`. Modify the latter instead (or sth. similar) to
1632
+ // not require the parent args logic.
1633
+ let parent_args = ty:: GenericArgs :: identity_for_item ( tcx, impl_) ;
1634
+ let args = self . create_args_for_associated_item ( span, assoc_item, segment, parent_args) ;
1635
+ let args = tcx. mk_args_from_iter (
1636
+ std:: iter:: once ( ty:: GenericArg :: from ( self_ty) )
1637
+ . chain ( args. into_iter ( ) . skip ( parent_args. len ( ) ) ) ,
1638
+ ) ;
1649
1639
1650
- let ty = Ty :: new_alias ( tcx, ty:: Inherent , ty:: AliasTy :: new ( tcx, assoc_item, args) ) ;
1640
+ let ty = Ty :: new_alias ( tcx, ty:: Inherent , ty:: AliasTy :: new ( tcx, assoc_item, args) ) ;
1651
1641
1652
- Ok ( Some ( ( ty, assoc_item) ) )
1653
- } ,
1654
- )
1642
+ Ok ( Some ( ( ty, assoc_item) ) )
1655
1643
}
1656
1644
1657
1645
fn select_inherent_assoc_type_candidates (
@@ -1660,9 +1648,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1660
1648
name : Ident ,
1661
1649
span : Span ,
1662
1650
self_ty : Ty < ' tcx > ,
1663
- cause : ObligationCause < ' tcx > ,
1664
1651
param_env : ParamEnv < ' tcx > ,
1665
- obligations : Vec < Obligation < ' tcx , Predicate < ' tcx > > > ,
1666
1652
candidates : Vec < ( DefId , ( DefId , DefId ) ) > ,
1667
1653
) -> Result < ( DefId , ( DefId , DefId ) ) , ErrorGuaranteed > {
1668
1654
let tcx = self . tcx ( ) ;
@@ -1674,11 +1660,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1674
1660
. filter ( |& ( impl_, _) | {
1675
1661
infcx. probe ( |_| {
1676
1662
let ocx = ObligationCtxt :: new ( infcx) ;
1677
- ocx. register_obligations ( obligations . clone ( ) ) ;
1663
+ let self_ty = ocx. normalize ( & ObligationCause :: dummy ( ) , param_env , self_ty ) ;
1678
1664
1679
1665
let impl_args = infcx. fresh_args_for_item ( span, impl_) ;
1680
1666
let impl_ty = tcx. type_of ( impl_) . instantiate ( tcx, impl_args) ;
1681
- let impl_ty = ocx. normalize ( & cause , param_env, impl_ty) ;
1667
+ let impl_ty = ocx. normalize ( & ObligationCause :: dummy ( ) , param_env, impl_ty) ;
1682
1668
1683
1669
// Check that the self types can be related.
1684
1670
if ocx. eq ( & ObligationCause :: dummy ( ) , param_env, impl_ty, self_ty) . is_err ( ) {
@@ -1687,9 +1673,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1687
1673
1688
1674
// Check whether the impl imposes obligations we have to worry about.
1689
1675
let impl_bounds = tcx. predicates_of ( impl_) . instantiate ( tcx, impl_args) ;
1690
- let impl_bounds = ocx. normalize ( & cause, param_env, impl_bounds) ;
1676
+ let impl_bounds =
1677
+ ocx. normalize ( & ObligationCause :: dummy ( ) , param_env, impl_bounds) ;
1691
1678
let impl_obligations = traits:: predicates_for_generics (
1692
- |_, _| cause . clone ( ) ,
1679
+ |_, _| ObligationCause :: dummy ( ) ,
1693
1680
param_env,
1694
1681
impl_bounds,
1695
1682
) ;
0 commit comments