File tree Expand file tree Collapse file tree 3 files changed +18
-9
lines changed
compiler/rustc_middle/src Expand file tree Collapse file tree 3 files changed +18
-9
lines changed Original file line number Diff line number Diff line change 3131#![ feature( array_windows) ]
3232#![ feature( assert_matches) ]
3333#![ feature( box_patterns) ]
34+ #![ feature( closure_track_caller) ]
3435#![ feature( core_intrinsics) ]
3536#![ feature( const_type_name) ]
3637#![ feature( discriminant_kind) ]
Original file line number Diff line number Diff line change 8585
8686/// Allows access to the current `ImplicitCtxt` in a closure if one is available.
8787#[ inline]
88+ #[ track_caller]
8889pub fn with_context_opt < F , R > ( f : F ) -> R
8990where
9091 F : for <' a , ' tcx > FnOnce ( Option < & ImplicitCtxt < ' a , ' tcx > > ) -> R ,
@@ -147,9 +148,13 @@ where
147148/// Allows access to the `TyCtxt` in the current `ImplicitCtxt`.
148149/// The closure is passed None if there is no `ImplicitCtxt` available.
149150#[ inline]
151+ #[ track_caller]
150152pub fn with_opt < F , R > ( f : F ) -> R
151153where
152154 F : for < ' tcx > FnOnce ( Option < TyCtxt < ' tcx > > ) -> R ,
153155{
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+ )
155160}
Original file line number Diff line number Diff line change @@ -28,14 +28,17 @@ fn opt_span_bug_fmt<S: Into<MultiSpan>>(
2828 args : fmt:: Arguments < ' _ > ,
2929 location : & Location < ' _ > ,
3030) -> ! {
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+ )
3942}
4043
4144/// 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