Skip to content

Commit 8f40e11

Browse files
committed
Use pretty-printer instead of span_to_snippet
1 parent 13076f9 commit 8f40e11

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -4268,6 +4268,7 @@ name = "rustc_passes"
42684268
version = "0.0.0"
42694269
dependencies = [
42704270
"rustc_ast",
4271+
"rustc_ast_pretty",
42714272
"rustc_attr",
42724273
"rustc_data_structures",
42734274
"rustc_errors",

compiler/rustc_passes/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ rustc_serialize = { path = "../rustc_serialize" }
1919
rustc_span = { path = "../rustc_span" }
2020
rustc_trait_selection = { path = "../rustc_trait_selection" }
2121
rustc_lexer = { path = "../rustc_lexer" }
22+
rustc_ast_pretty = { path = "../rustc_ast_pretty" }

compiler/rustc_passes/src/check_attr.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -597,13 +597,10 @@ impl CheckAttrVisitor<'tcx> {
597597
hir_id,
598598
i_meta.span,
599599
|lint| {
600-
let msg = if let Ok(snippet) =
601-
self.tcx.sess.source_map().span_to_snippet(i_meta.path.span)
602-
{
603-
format!("unknown `doc` attribute `{}`", snippet,)
604-
} else {
605-
String::from("unknown `doc` attribute")
606-
};
600+
let msg = format!(
601+
"unknown `doc` attribute `{}`",
602+
rustc_ast_pretty::pprust::path_to_string(&i_meta.path),
603+
);
607604
lint.build(&msg).emit();
608605
},
609606
);

0 commit comments

Comments
 (0)