Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename region_should_not_be_omitted to should_print_region #94280

Merged
merged 1 commit into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
}

impl<'tcx> PrettyPrinter<'tcx> for AbsolutePathPrinter<'tcx> {
fn region_should_not_be_omitted(&self, _region: ty::Region<'_>) -> bool {
fn should_print_region(&self, _region: ty::Region<'_>) -> bool {
false
}
fn comma_sep<T>(mut self, mut elems: impl Iterator<Item = T>) -> Result<Self, Self::Error>
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ pub trait PrettyPrinter<'tcx>:
/// Returns `true` if the region should be printed in
/// optional positions, e.g., `&'a T` or `dyn Tr + 'b`.
/// This is typically the case for all non-`'_` regions.
fn region_should_not_be_omitted(&self, region: ty::Region<'_>) -> bool;
fn should_print_region(&self, region: ty::Region<'_>) -> bool;

// Defaults (should not be overridden):

Expand Down Expand Up @@ -577,7 +577,7 @@ pub trait PrettyPrinter<'tcx>:
}
ty::Ref(r, ty, mutbl) => {
p!("&");
if self.region_should_not_be_omitted(r) {
if self.should_print_region(r) {
p!(print(r), " ");
}
p!(print(ty::TypeAndMut { ty, mutbl }))
Expand Down Expand Up @@ -621,7 +621,7 @@ pub trait PrettyPrinter<'tcx>:
p!(print_def_path(def.did, substs));
}
ty::Dynamic(data, r) => {
let print_r = self.region_should_not_be_omitted(r);
let print_r = self.should_print_region(r);
if print_r {
p!("(");
}
Expand Down Expand Up @@ -1914,7 +1914,7 @@ impl<'tcx, F: fmt::Write> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx, F> {
Ok(inner)
}

fn region_should_not_be_omitted(&self, region: ty::Region<'_>) -> bool {
fn should_print_region(&self, region: ty::Region<'_>) -> bool {
let highlight = self.region_highlight_mode;
if highlight.region_highlighted(region).is_some() {
return true;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_symbol_mangling/src/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolPrinter<'tcx> {
}

impl<'tcx> PrettyPrinter<'tcx> for &mut SymbolPrinter<'tcx> {
fn region_should_not_be_omitted(&self, _region: ty::Region<'_>) -> bool {
fn should_print_region(&self, _region: ty::Region<'_>) -> bool {
false
}
fn comma_sep<T>(mut self, mut elems: impl Iterator<Item = T>) -> Result<Self, Self::Error>
Expand Down