File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ fn main() {
1010 replace_vptr ( ) ;
1111 vtable_nop_cast ( ) ;
1212 drop_principal ( ) ;
13+ modulo_binder ( ) ;
14+ modulo_assoc ( ) ;
1315}
1416
1517fn vtable_nop_cast ( ) {
@@ -482,3 +484,53 @@ fn drop_principal() {
482484 println ! ( "before" ) ;
483485 drop ( y) ;
484486}
487+
488+ // Test for <https://github.com/rust-lang/rust/issues/135316>.
489+ fn modulo_binder ( ) {
490+ trait Supertrait < T > {
491+ fn _print_numbers ( & self , mem : & [ usize ; 100 ] ) {
492+ println ! ( "{mem:?}" ) ;
493+ }
494+ }
495+ impl < T > Supertrait < T > for ( ) { }
496+
497+ trait Trait < T , U > : Supertrait < T > + Supertrait < U > {
498+ fn say_hello ( & self , _: & usize ) {
499+ println ! ( "Hello!" ) ;
500+ }
501+ }
502+ impl < T , U > Trait < T , U > for ( ) { }
503+
504+ ( & ( ) as & ' static dyn for < ' a > Trait < & ' static ( ) , & ' a ( ) >
505+ as & ' static dyn Trait < & ' static ( ) , & ' static ( ) > )
506+ . say_hello ( & 0 ) ;
507+ }
508+
509+ // Test for <https://github.com/rust-lang/rust/issues/135315>.
510+ fn modulo_assoc ( ) {
511+ trait Supertrait < T > {
512+ fn _print_numbers ( & self , mem : & [ usize ; 100 ] ) {
513+ println ! ( "{mem:?}" ) ;
514+ }
515+ }
516+ impl < T > Supertrait < T > for ( ) { }
517+
518+ trait Identity {
519+ type Selff ;
520+ }
521+ impl < Selff > Identity for Selff {
522+ type Selff = Selff ;
523+ }
524+
525+ trait Middle < T > : Supertrait < ( ) > + Supertrait < T > {
526+ fn say_hello ( & self , _: & usize ) {
527+ println ! ( "Hello!" ) ;
528+ }
529+ }
530+ impl < T > Middle < T > for ( ) { }
531+
532+ trait Trait : Middle < <( ) as Identity >:: Selff > { }
533+ impl Trait for ( ) { }
534+
535+ ( & ( ) as & dyn Trait as & dyn Middle < ( ) > ) . say_hello ( & 0 ) ;
536+ }
Original file line number Diff line number Diff line change 22goodbye
33before
44goodbye
5+ Hello!
6+ Hello!
You can’t perform that action at this time.
0 commit comments