@@ -282,7 +282,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
282
282
/// from at least one local module, and returns `true`. If the crate defining `def_id` is
283
283
/// declared with an `extern crate`, the path is guaranteed to use the `extern crate`.
284
284
fn try_print_visible_def_path ( & mut self , def_id : DefId ) -> Result < bool , PrintError > {
285
- if NO_VISIBLE_PATH . with ( |flag| flag . get ( ) ) {
285
+ if with_no_visible_paths ( ) {
286
286
return Ok ( false ) ;
287
287
}
288
288
@@ -366,16 +366,16 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
366
366
367
367
/// Try to see if this path can be trimmed to a unique symbol name.
368
368
fn try_print_trimmed_def_path ( & mut self , def_id : DefId ) -> Result < bool , PrintError > {
369
- if FORCE_TRIMMED_PATH . with ( |flag| flag . get ( ) ) {
369
+ if with_forced_trimmed_paths ( ) {
370
370
let trimmed = self . force_print_trimmed_def_path ( def_id) ?;
371
371
if trimmed {
372
372
return Ok ( true ) ;
373
373
}
374
374
}
375
375
if !self . tcx ( ) . sess . opts . unstable_opts . trim_diagnostic_paths
376
376
|| matches ! ( self . tcx( ) . sess. opts. trimmed_def_paths, TrimmedDefPaths :: Never )
377
- || NO_TRIMMED_PATH . with ( |flag| flag . get ( ) )
378
- || SHOULD_PREFIX_WITH_CRATE . with ( |flag| flag . get ( ) )
377
+ || with_no_trimmed_paths ( )
378
+ || with_crate_prefix ( )
379
379
{
380
380
return Ok ( false ) ;
381
381
}
@@ -860,7 +860,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
860
860
p ! ( "@" , print_def_path( did. to_def_id( ) , args) ) ;
861
861
} else {
862
862
let span = self . tcx ( ) . def_span ( did) ;
863
- let preference = if FORCE_TRIMMED_PATH . with ( |flag| flag . get ( ) ) {
863
+ let preference = if with_forced_trimmed_paths ( ) {
864
864
FileNameDisplayPreference :: Short
865
865
} else {
866
866
FileNameDisplayPreference :: Remapped
@@ -1101,7 +1101,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
1101
1101
write ! ( self , "Sized" ) ?;
1102
1102
}
1103
1103
1104
- if !FORCE_TRIMMED_PATH . with ( |flag| flag . get ( ) ) {
1104
+ if !with_forced_trimmed_paths ( ) {
1105
1105
for re in lifetimes {
1106
1106
write ! ( self , " + " ) ?;
1107
1107
self . print_region ( re) ?;
@@ -1883,7 +1883,7 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> {
1883
1883
// available, and filename/line-number is mostly uninteresting.
1884
1884
let use_types = !def_id. is_local ( ) || {
1885
1885
// Otherwise, use filename/line-number if forced.
1886
- let force_no_types = FORCE_IMPL_FILENAME_LINE . with ( |f| f . get ( ) ) ;
1886
+ let force_no_types = with_forced_impl_filename_line ( ) ;
1887
1887
!force_no_types
1888
1888
} ;
1889
1889
@@ -1948,7 +1948,7 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> {
1948
1948
if cnum == LOCAL_CRATE {
1949
1949
if self . tcx . sess . at_least_rust_2018 ( ) {
1950
1950
// We add the `crate::` keyword on Rust 2018, only when desired.
1951
- if SHOULD_PREFIX_WITH_CRATE . with ( |flag| flag . get ( ) ) {
1951
+ if with_crate_prefix ( ) {
1952
1952
write ! ( self , "{}" , kw:: Crate ) ?;
1953
1953
self . empty_path = false ;
1954
1954
}
@@ -2151,7 +2151,7 @@ impl<'tcx> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx> {
2151
2151
return true ;
2152
2152
}
2153
2153
2154
- if FORCE_TRIMMED_PATH . with ( |flag| flag . get ( ) ) {
2154
+ if with_forced_trimmed_paths ( ) {
2155
2155
return false ;
2156
2156
}
2157
2157
@@ -2434,7 +2434,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
2434
2434
} else {
2435
2435
let tcx = self . tcx ;
2436
2436
2437
- let trim_path = FORCE_TRIMMED_PATH . with ( |flag| flag . get ( ) ) ;
2437
+ let trim_path = with_forced_trimmed_paths ( ) ;
2438
2438
// Closure used in `RegionFolder` to create names for anonymous late-bound
2439
2439
// regions. We use two `DebruijnIndex`es (one for the currently folded
2440
2440
// late-bound region and the other for the binder level) to determine
0 commit comments