File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ // Codegen test for #126242
2+
3+ //@ compile-flags: -O
4+ #![ crate_type = "lib" ]
5+ #![ feature( error_generic_member_access) ]
6+ use std:: error:: Request ;
7+ use std:: fmt;
8+
9+ #[ derive( Debug ) ]
10+ struct MyBacktrace1 { }
11+
12+ #[ derive( Debug ) ]
13+ struct MyBacktrace2 { }
14+
15+ #[ derive( Debug ) ]
16+ struct MyBacktrace3 { }
17+
18+ #[ derive( Debug ) ]
19+ struct MyError {
20+ backtrace1 : MyBacktrace1 ,
21+ backtrace2 : MyBacktrace2 ,
22+ backtrace3 : MyBacktrace3 ,
23+ other : MyBacktrace3 ,
24+ }
25+
26+ impl fmt:: Display for MyError {
27+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
28+ write ! ( f, "Example Error" )
29+ }
30+ }
31+
32+ impl std:: error:: Error for MyError {
33+ // CHECK-LABEL: @provide
34+ #[ no_mangle]
35+ fn provide < ' a > ( & ' a self , request : & mut Request < ' a > ) {
36+ // LLVM should be able to optimize multiple .provide_* calls into a switch table
37+ // and eliminate redundant ones, rather than compare one-by-one.
38+
39+ // CHECK: switch i64 %{{.*}}, label %{{.*}} [
40+ // CHECK-COUNT-3: i64 {{.*}}, label %{{.*}}
41+ // CHECK-NEXT: ]
42+ request
43+ . provide_ref :: < MyBacktrace1 > ( & self . backtrace1 )
44+ . provide_ref :: < MyBacktrace3 > ( & self . other )
45+ . provide_ref :: < MyBacktrace2 > ( & self . backtrace2 )
46+ . provide_ref :: < MyBacktrace3 > ( & self . backtrace3 ) ;
47+ }
48+ }
You can’t perform that action at this time.
0 commit comments