File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,27 @@ fn test_trait_obj() {
66
66
assert_eq ! ( location. column( ) , 28 ) ;
67
67
}
68
68
69
+ fn test_trait_obj2 ( ) {
70
+ // track_caller on the impl but not the trait.
71
+ pub trait Foo {
72
+ fn foo ( & self ) -> & ' static Location < ' static > ;
73
+ }
74
+
75
+ struct Bar ;
76
+ impl Foo for Bar {
77
+ #[ track_caller]
78
+ fn foo ( & self ) -> & ' static Location < ' static > {
79
+ std:: panic:: Location :: caller ( )
80
+ }
81
+ }
82
+ let expected_line = line ! ( ) - 4 ; // the `fn` signature above
83
+
84
+ let f = & Bar as & dyn Foo ;
85
+ let loc = f. foo ( ) ; // trait doesn't track, so we don't point at this call site
86
+ assert_eq ! ( loc. file( ) , file!( ) ) ;
87
+ assert_eq ! ( loc. line( ) , expected_line) ;
88
+ }
89
+
69
90
fn main ( ) {
70
91
let location = Location :: caller ( ) ;
71
92
let expected_line = line ! ( ) - 1 ;
@@ -105,4 +126,5 @@ fn main() {
105
126
106
127
test_fn_ptr ( ) ;
107
128
test_trait_obj ( ) ;
129
+ test_trait_obj2 ( ) ;
108
130
}
You can’t perform that action at this time.
0 commit comments