Skip to content

Commit

Permalink
Use pretty-printer instead of span_to_snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
camelid committed Mar 14, 2021
1 parent 13076f9 commit 8f40e11
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4268,6 +4268,7 @@ name = "rustc_passes"
version = "0.0.0"
dependencies = [
"rustc_ast",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_passes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
11 changes: 4 additions & 7 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
);
Expand Down

0 comments on commit 8f40e11

Please sign in to comment.