Use helpers
This commit is contained in:
parent
1e9dda77b5
commit
0eb85ff03f
1 changed files with 10 additions and 10 deletions
|
@ -282,7 +282,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
|
||||||
/// from at least one local module, and returns `true`. If the crate defining `def_id` is
|
/// from at least one local module, and returns `true`. If the crate defining `def_id` is
|
||||||
/// declared with an `extern crate`, the path is guaranteed to use the `extern crate`.
|
/// declared with an `extern crate`, the path is guaranteed to use the `extern crate`.
|
||||||
fn try_print_visible_def_path(&mut self, def_id: DefId) -> Result<bool, PrintError> {
|
fn try_print_visible_def_path(&mut self, def_id: DefId) -> Result<bool, PrintError> {
|
||||||
if NO_VISIBLE_PATH.with(|flag| flag.get()) {
|
if with_no_visible_paths() {
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,7 +366,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
|
||||||
|
|
||||||
/// Try to see if this path can be trimmed to a unique symbol name.
|
/// Try to see if this path can be trimmed to a unique symbol name.
|
||||||
fn try_print_trimmed_def_path(&mut self, def_id: DefId) -> Result<bool, PrintError> {
|
fn try_print_trimmed_def_path(&mut self, def_id: DefId) -> Result<bool, PrintError> {
|
||||||
if FORCE_TRIMMED_PATH.with(|flag| flag.get()) {
|
if with_forced_trimmed_paths() {
|
||||||
let trimmed = self.force_print_trimmed_def_path(def_id)?;
|
let trimmed = self.force_print_trimmed_def_path(def_id)?;
|
||||||
if trimmed {
|
if trimmed {
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
|
@ -374,8 +374,8 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
|
||||||
}
|
}
|
||||||
if !self.tcx().sess.opts.unstable_opts.trim_diagnostic_paths
|
if !self.tcx().sess.opts.unstable_opts.trim_diagnostic_paths
|
||||||
|| matches!(self.tcx().sess.opts.trimmed_def_paths, TrimmedDefPaths::Never)
|
|| matches!(self.tcx().sess.opts.trimmed_def_paths, TrimmedDefPaths::Never)
|
||||||
|| NO_TRIMMED_PATH.with(|flag| flag.get())
|
|| with_no_trimmed_paths()
|
||||||
|| SHOULD_PREFIX_WITH_CRATE.with(|flag| flag.get())
|
|| with_crate_prefix()
|
||||||
{
|
{
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
@ -860,7 +860,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
|
||||||
p!("@", print_def_path(did.to_def_id(), args));
|
p!("@", print_def_path(did.to_def_id(), args));
|
||||||
} else {
|
} else {
|
||||||
let span = self.tcx().def_span(did);
|
let span = self.tcx().def_span(did);
|
||||||
let preference = if FORCE_TRIMMED_PATH.with(|flag| flag.get()) {
|
let preference = if with_forced_trimmed_paths() {
|
||||||
FileNameDisplayPreference::Short
|
FileNameDisplayPreference::Short
|
||||||
} else {
|
} else {
|
||||||
FileNameDisplayPreference::Remapped
|
FileNameDisplayPreference::Remapped
|
||||||
|
@ -1101,7 +1101,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
|
||||||
write!(self, "Sized")?;
|
write!(self, "Sized")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !FORCE_TRIMMED_PATH.with(|flag| flag.get()) {
|
if !with_forced_trimmed_paths() {
|
||||||
for re in lifetimes {
|
for re in lifetimes {
|
||||||
write!(self, " + ")?;
|
write!(self, " + ")?;
|
||||||
self.print_region(re)?;
|
self.print_region(re)?;
|
||||||
|
@ -1883,7 +1883,7 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> {
|
||||||
// available, and filename/line-number is mostly uninteresting.
|
// available, and filename/line-number is mostly uninteresting.
|
||||||
let use_types = !def_id.is_local() || {
|
let use_types = !def_id.is_local() || {
|
||||||
// Otherwise, use filename/line-number if forced.
|
// Otherwise, use filename/line-number if forced.
|
||||||
let force_no_types = FORCE_IMPL_FILENAME_LINE.with(|f| f.get());
|
let force_no_types = with_forced_impl_filename_line();
|
||||||
!force_no_types
|
!force_no_types
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1948,7 +1948,7 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> {
|
||||||
if cnum == LOCAL_CRATE {
|
if cnum == LOCAL_CRATE {
|
||||||
if self.tcx.sess.at_least_rust_2018() {
|
if self.tcx.sess.at_least_rust_2018() {
|
||||||
// We add the `crate::` keyword on Rust 2018, only when desired.
|
// We add the `crate::` keyword on Rust 2018, only when desired.
|
||||||
if SHOULD_PREFIX_WITH_CRATE.with(|flag| flag.get()) {
|
if with_crate_prefix() {
|
||||||
write!(self, "{}", kw::Crate)?;
|
write!(self, "{}", kw::Crate)?;
|
||||||
self.empty_path = false;
|
self.empty_path = false;
|
||||||
}
|
}
|
||||||
|
@ -2151,7 +2151,7 @@ impl<'tcx> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if FORCE_TRIMMED_PATH.with(|flag| flag.get()) {
|
if with_forced_trimmed_paths() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2434,7 +2434,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
|
||||||
} else {
|
} else {
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
|
|
||||||
let trim_path = FORCE_TRIMMED_PATH.with(|flag| flag.get());
|
let trim_path = with_forced_trimmed_paths();
|
||||||
// Closure used in `RegionFolder` to create names for anonymous late-bound
|
// Closure used in `RegionFolder` to create names for anonymous late-bound
|
||||||
// regions. We use two `DebruijnIndex`es (one for the currently folded
|
// regions. We use two `DebruijnIndex`es (one for the currently folded
|
||||||
// late-bound region and the other for the binder level) to determine
|
// late-bound region and the other for the binder level) to determine
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue