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" version = "0.0.0"
dependencies = [ dependencies = [
"rustc_ast", "rustc_ast",
"rustc_ast_pretty",
"rustc_attr", "rustc_attr",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",

View File

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

View File

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