Skip to content

Commit 4348b4f

Browse files
More assertions, tests, and miri coverage
1 parent e8a9c01 commit 4348b4f

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

tests/pass/dyn-upcast.rs

+52
Original file line numberDiff line numberDiff 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

1517
fn 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+
}

tests/pass/dyn-upcast.stdout

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ before
22
goodbye
33
before
44
goodbye
5+
Hello!
6+
Hello!

0 commit comments

Comments
 (0)