File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed 
compiler/rustc_trait_selection/src/traits Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -748,6 +748,9 @@ fn vtable_trait_first_method_offset<'tcx>(
748748)  -> usize  { 
749749    let  ( trait_to_be_found,  trait_owning_vtable)  = key; 
750750
751+     // #90177 
752+     let  trait_to_be_found_erased = tcx. erase_regions ( trait_to_be_found) ; 
753+ 
751754    let  vtable_segment_callback = { 
752755        let  mut  vtable_base = 0 ; 
753756
@@ -757,7 +760,7 @@ fn vtable_trait_first_method_offset<'tcx>(
757760                    vtable_base += COMMON_VTABLE_ENTRIES . len ( ) ; 
758761                } 
759762                VtblSegment :: TraitOwnEntries  {  trait_ref,  emit_vptr }  => { 
760-                     if  trait_ref == trait_to_be_found  { 
763+                     if  tcx . erase_regions ( trait_ref)  == trait_to_be_found_erased  { 
761764                        return  ControlFlow :: Break ( vtable_base) ; 
762765                    } 
763766                    vtable_base += util:: count_own_vtable_entries ( tcx,  trait_ref) ; 
Original file line number Diff line number Diff line change 1+ // check-pass 
2+ 
3+ trait  Base < ' f >  { 
4+     type  Assoc ; 
5+ 
6+     fn  do_something ( & self ) ; 
7+ } 
8+ 
9+ trait  ForAnyLifetime :  for < ' f >  Base < ' f >  { } 
10+ 
11+ impl < T >  ForAnyLifetime  for  T  where  T :  for < ' f >  Base < ' f >  { } 
12+ 
13+ trait  CanBeDynamic :  ForAnyLifetime  + for < ' f >  Base < ' f ,  Assoc  = ( ) >  { } 
14+ 
15+ fn  foo ( a :  & dyn  CanBeDynamic )  { 
16+     a. do_something ( ) ; 
17+ } 
18+ 
19+ struct  S ; 
20+ 
21+ impl < ' a >  Base < ' a >  for  S  { 
22+     type  Assoc  = ( ) ; 
23+ 
24+     fn  do_something ( & self )  { } 
25+ } 
26+ 
27+ impl  CanBeDynamic  for  S  { } 
28+ 
29+ fn  main ( )  { 
30+     let  s = S ; 
31+     foo ( & s) ; 
32+ } 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments