@@ -2112,50 +2112,68 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
21122112 ) {
21132113 debug ! ( "resolve_implementation" ) ;
21142114 // If applicable, create a rib for the type parameters.
2115- self . with_generic_param_rib ( & generics . params , ItemRibKind ( HasGenericParams :: Yes ) , LifetimeRibKind :: Generics { span : generics . span , binder : item_id , kind : LifetimeBinderKind :: ImplBlock } , |this| {
2116- // Dummy self type for better errors if `Self` is used in the trait path.
2117- this . with_self_rib ( Res :: SelfTy { trait_ : None , alias_to : None } , |this| {
2118- this . with_lifetime_rib ( LifetimeRibKind :: AnonymousCreateParameter ( item_id ) , |this| {
2119- // Resolve the trait reference, if necessary.
2120- this . with_optional_trait_ref ( opt_trait_reference . as_ref ( ) , self_type , |this , trait_id| {
2121- let item_def_id = this . r . local_def_id ( item_id ) ;
2122-
2123- // Register the trait definitions from here.
2124- if let Some ( trait_id ) = trait_id {
2125- this. r . trait_impls . entry ( trait_id ) . or_default ( ) . push ( item_def_id ) ;
2126- }
2127-
2128- let item_def_id = item_def_id . to_def_id ( ) ;
2129- let res =
2130- Res :: SelfTy { trait_ : trait_id , alias_to : Some ( ( item_def_id , false ) ) } ;
2131- this . with_self_rib ( res , |this| {
2132- if let Some ( trait_ref ) = opt_trait_reference . as_ref ( ) {
2133- // Resolve type arguments in the trait path.
2134- visit :: walk_trait_ref ( this , trait_ref ) ;
2135- }
2136- // Resolve the self type .
2137- this . visit_ty ( self_type ) ;
2138- // Resolve the generic parameters.
2139- this . visit_generics ( generics ) ;
2115+ self . with_generic_param_rib (
2116+ & generics . params ,
2117+ ItemRibKind ( HasGenericParams :: Yes ) ,
2118+ LifetimeRibKind :: Generics {
2119+ span : generics . span ,
2120+ binder : item_id ,
2121+ kind : LifetimeBinderKind :: ImplBlock
2122+ } ,
2123+ |this| {
2124+ // Dummy self type for better errors if `Self` is used in the trait path.
2125+ this . with_self_rib ( Res :: SelfTy { trait_ : None , alias_to : None } , | this| {
2126+ this . with_lifetime_rib (
2127+ LifetimeRibKind :: AnonymousCreateParameter ( item_id ) ,
2128+ |this| {
2129+ // Resolve the trait reference, if necessary.
2130+ this . with_optional_trait_ref (
2131+ opt_trait_reference . as_ref ( ) ,
2132+ self_type ,
2133+ |this , trait_id| {
2134+ let item_def_id = this . r . local_def_id ( item_id ) ;
2135+
2136+ // Register the trait definitions from here .
2137+ if let Some ( trait_id ) = trait_id {
2138+ this . r . trait_impls . entry ( trait_id ) . or_default ( ) . push ( item_def_id ) ;
2139+ }
21402140
2141- // Resolve the items within the impl.
2142- this. with_lifetime_rib ( LifetimeRibKind :: AnonymousPassThrough ( item_id, false ) ,
2143- |this| {
2144- this. with_current_self_type ( self_type, |this| {
2145- this. with_self_rib_ns ( ValueNS , Res :: SelfCtor ( item_def_id) , |this| {
2146- debug ! ( "resolve_implementation with_self_rib_ns(ValueNS, ...)" ) ;
2147- for item in impl_items {
2148- this. resolve_impl_item ( & * * item) ;
2149- }
2150- } ) ;
2141+ let item_def_id = item_def_id. to_def_id ( ) ;
2142+ let res = Res :: SelfTy {
2143+ trait_ : trait_id,
2144+ alias_to : Some ( ( item_def_id, false ) ) ,
2145+ } ;
2146+ this. with_self_rib ( res, |this| {
2147+ if let Some ( trait_ref) = opt_trait_reference. as_ref ( ) {
2148+ // Resolve type arguments in the trait path.
2149+ visit:: walk_trait_ref ( this, trait_ref) ;
2150+ }
2151+ // Resolve the self type.
2152+ this. visit_ty ( self_type) ;
2153+ // Resolve the generic parameters.
2154+ this. visit_generics ( generics) ;
2155+
2156+ // Resolve the items within the impl.
2157+ this. with_lifetime_rib ( LifetimeRibKind :: AnonymousPassThrough ( item_id, false ) ,
2158+ |this| {
2159+ this. with_current_self_type ( self_type, |this| {
2160+ this. with_self_rib_ns ( ValueNS , Res :: SelfCtor ( item_def_id) , |this| {
2161+ debug ! ( "resolve_implementation with_self_rib_ns(ValueNS, ...)" ) ;
2162+ for item in impl_items {
2163+ this. resolve_impl_item ( & * * item) ;
2164+ }
2165+ } ) ;
2166+ } ) ;
2167+ } ,
2168+ ) ;
21512169 } ) ;
21522170 } ,
21532171 ) ;
2154- } ) ;
2155- } ) ;
2172+ } ,
2173+ ) ;
21562174 } ) ;
2157- } ) ;
2158- } ) ;
2175+ } ,
2176+ ) ;
21592177 }
21602178
21612179 fn resolve_impl_item ( & mut self , item : & ' ast AssocItem ) {
0 commit comments