File tree 3 files changed +18
-9
lines changed
compiler/rustc_middle/src
3 files changed +18
-9
lines changed Original file line number Diff line number Diff line change 31
31
#![ feature( array_windows) ]
32
32
#![ feature( assert_matches) ]
33
33
#![ feature( box_patterns) ]
34
+ #![ feature( closure_track_caller) ]
34
35
#![ feature( core_intrinsics) ]
35
36
#![ feature( const_type_name) ]
36
37
#![ feature( discriminant_kind) ]
Original file line number Diff line number Diff line change 85
85
86
86
/// Allows access to the current `ImplicitCtxt` in a closure if one is available.
87
87
#[ inline]
88
+ #[ track_caller]
88
89
pub fn with_context_opt < F , R > ( f : F ) -> R
89
90
where
90
91
F : for <' a , ' tcx > FnOnce ( Option < & ImplicitCtxt < ' a , ' tcx > > ) -> R ,
@@ -147,9 +148,13 @@ where
147
148
/// Allows access to the `TyCtxt` in the current `ImplicitCtxt`.
148
149
/// The closure is passed None if there is no `ImplicitCtxt` available.
149
150
#[ inline]
151
+ #[ track_caller]
150
152
pub fn with_opt < F , R > ( f : F ) -> R
151
153
where
152
154
F : for < ' tcx > FnOnce ( Option < TyCtxt < ' tcx > > ) -> R ,
153
155
{
154
- with_context_opt ( |opt_context| f ( opt_context. map ( |context| context. tcx ) ) )
156
+ with_context_opt (
157
+ #[ track_caller]
158
+ |opt_context| f ( opt_context. map ( |context| context. tcx ) ) ,
159
+ )
155
160
}
Original file line number Diff line number Diff line change @@ -28,14 +28,17 @@ fn opt_span_bug_fmt<S: Into<MultiSpan>>(
28
28
args : fmt:: Arguments < ' _ > ,
29
29
location : & Location < ' _ > ,
30
30
) -> ! {
31
- tls:: with_opt ( move |tcx| {
32
- let msg = format ! ( "{location}: {args}" ) ;
33
- match ( tcx, span) {
34
- ( Some ( tcx) , Some ( span) ) => tcx. dcx ( ) . span_bug ( span, msg) ,
35
- ( Some ( tcx) , None ) => tcx. dcx ( ) . bug ( msg) ,
36
- ( None , _) => panic_any ( msg) ,
37
- }
38
- } )
31
+ tls:: with_opt (
32
+ #[ track_caller]
33
+ move |tcx| {
34
+ let msg = format ! ( "{location}: {args}" ) ;
35
+ match ( tcx, span) {
36
+ ( Some ( tcx) , Some ( span) ) => tcx. dcx ( ) . span_bug ( span, msg) ,
37
+ ( Some ( tcx) , None ) => tcx. dcx ( ) . bug ( msg) ,
38
+ ( None , _) => panic_any ( msg) ,
39
+ }
40
+ } ,
41
+ )
39
42
}
40
43
41
44
/// A query to trigger a delayed bug. Clearly, if one has a `tcx` one can already trigger a
You can’t perform that action at this time.
0 commit comments