Move is_raw_guess check in ty::print::pretty

This commit is contained in:
marmeladema 2020-09-24 10:23:01 +01:00
parent 35bad3edbf
commit 5946c12476
2 changed files with 7 additions and 4 deletions

View File

@ -13,7 +13,7 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stable_hasher::StableHasher;
use rustc_index::vec::IndexVec;
use rustc_span::hygiene::ExpnId;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::symbol::{kw, sym, Symbol};
use std::fmt::{self, Write};
use std::hash::Hash;
@ -159,9 +159,6 @@ impl DisambiguatedDefPathData {
pub fn fmt_maybe_verbose(&self, writer: &mut impl Write, verbose: bool) -> fmt::Result {
match self.data.name() {
DefPathDataName::Named(name) => {
if Ident::with_dummy_span(name).is_raw_guess() {
writer.write_str("r#")?;
}
if verbose && self.disambiguator != 0 {
write!(writer, "{}#{}", name, self.disambiguator)
} else {

View File

@ -1504,6 +1504,12 @@ impl<F: fmt::Write> Printer<'tcx> for FmtPrinter<'_, 'tcx, F> {
write!(self, "::")?;
}
if let DefPathDataName::Named(name) = name {
if Ident::with_dummy_span(name).is_raw_guess() {
write!(self, "r#")?;
}
}
let verbose = self.tcx.sess.verbose();
disambiguated_data.fmt_maybe_verbose(&mut self, verbose)?;