Use pretty-printer instead of `span_to_snippet`

This commit is contained in:
Camelid 2021-03-14 14:39:13 -07:00
parent 13076f90d2
commit 8f40e1180f
3 changed files with 6 additions and 7 deletions

View File

@ -4268,6 +4268,7 @@ name = "rustc_passes"
version = "0.0.0"
dependencies = [
"rustc_ast",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",

View File

@ -19,3 +19,4 @@ rustc_serialize = { path = "../rustc_serialize" }
rustc_span = { path = "../rustc_span" }
rustc_trait_selection = { path = "../rustc_trait_selection" }
rustc_lexer = { path = "../rustc_lexer" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" }

View File

@ -597,13 +597,10 @@ impl CheckAttrVisitor<'tcx> {
hir_id,
i_meta.span,
|lint| {
let msg = if let Ok(snippet) =
self.tcx.sess.source_map().span_to_snippet(i_meta.path.span)
{
format!("unknown `doc` attribute `{}`", snippet,)
} else {
String::from("unknown `doc` attribute")
};
let msg = format!(
"unknown `doc` attribute `{}`",
rustc_ast_pretty::pprust::path_to_string(&i_meta.path),
);
lint.build(&msg).emit();
},
);