This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ // run-pass
2+ // revisions: mir codegen
3+ //[mir] compile-flags: -Zmir-opt-level=3
4+ //[codegen] compile-flags: -Zmir-opt-level=0
5+
6+ // A regression test for #107205
7+ #![ allow( coherence_leak_check) ]
8+ struct Foo < T : ' static > ( T ) ;
9+
10+ fn useful < ' a > ( _: & ' a u8 ) { }
11+
12+ trait GetInner {
13+ type Assoc ;
14+ fn muahaha ( & mut self ) -> Self :: Assoc ;
15+ }
16+
17+ impl GetInner for Foo < fn ( & ' static u8 ) > {
18+ type Assoc = String ;
19+ fn muahaha ( & mut self ) -> String {
20+ String :: from ( "I am a string" )
21+ }
22+ }
23+
24+ impl GetInner for Foo < for <' a > fn ( & ' a u8 ) > {
25+ type Assoc = [ usize ; 3 ] ;
26+ fn muahaha ( & mut self ) -> [ usize ; 3 ] {
27+ [ 100 ; 3 ]
28+ }
29+ }
30+
31+ fn break_me ( hr_fnptr : Box < Foo :: < for <' a > fn ( & ' a u8 ) > > ) -> Box < dyn GetInner < Assoc = String > > {
32+ let lr_fnptr = hr_fnptr as Box < Foo < fn ( & ' static u8 ) > > ;
33+ lr_fnptr as Box < dyn GetInner < Assoc = String > >
34+ }
35+
36+ fn main ( ) {
37+ drop ( Box :: new ( Foo ( useful as fn ( & ' static u8 ) ) ) as Box < dyn GetInner < Assoc = String > > ) ;
38+ drop ( Box :: new ( Foo ( useful as fn ( & u8 ) ) ) as Box < dyn GetInner < Assoc = [ usize ; 3 ] > > ) ;
39+
40+ let mut any = break_me ( Box :: new ( Foo ( useful) ) ) ;
41+
42+ let evil_string = any. muahaha ( ) ;
43+ assert_eq ! ( evil_string, "I am a string" ) ;
44+ }
Original file line number Diff line number Diff line change 1+ // run-pass
2+ // revisions: mir codegen
3+ //[mir] compile-flags: -Zmir-opt-level=3
4+ //[codegen] compile-flags: -Zmir-opt-level=0
5+
6+ // A regression test for #107205
7+
8+ const X : for <' b > fn ( & ' b ( ) ) = |& ( ) | ( ) ;
9+ fn main ( ) {
10+ let dyn_debug = Box :: new ( X ) as Box < fn ( & ' static ( ) ) > as Box < dyn Send > ;
11+ drop ( dyn_debug)
12+ }
You can’t perform that action at this time.
0 commit comments