Skip to content

Commit 73adbd3

Browse files
refactor: use pprust explicitly
implicit pprust dependencies were removed and now require explicit usage rust-lang/rust#65363
1 parent f87fe48 commit 73adbd3

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

rustfmt-core/rustfmt-lib/src/macros.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ fn rewrite_macro_name(
143143
// Avoid using pretty-printer in the common case.
144144
format!("{}!", rewrite_ident(context, path.segments[0].ident))
145145
} else {
146-
format!("{}!", path)
146+
format!("{}!", pprust::path_to_string(path))
147147
};
148148
match extra_ident {
149149
Some(ident) if ident.name != kw::Invalid => format!("{} {}", name, ident),
@@ -1190,7 +1190,8 @@ pub(crate) fn convert_try_mac(mac: &ast::Mac, context: &RewriteContext<'_>) -> O
11901190
// `r#try!` must be used in the 2018 Edition.
11911191
// https://doc.rust-lang.org/std/macro.try.html
11921192
// https://github.com/rust-lang/rust/pull/62672
1193-
if &mac.path.to_string() == "try" || &mac.path.to_string() == "r#try" {
1193+
let path = &pprust::path_to_string(&mac.path);
1194+
if path == "try" || path == "r#try" {
11941195
let ts: TokenStream = mac.tts.clone();
11951196
let mut parser = new_parser_from_tts(context.parse_sess.inner(), ts.trees().collect());
11961197

rustfmt-core/rustfmt-lib/src/spanned.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,7 @@ macro_rules! span_with_attrs_lo_hi {
2929
if attrs.is_empty() {
3030
mk_sp($lo, $hi)
3131
} else {
32-
// this path is already gone at latest rust-ap-* 627.0.0
33-
if attrs[0].item.path.to_string() == "warn_directory_ownership" {
34-
mk_sp($lo, $hi)
35-
} else {
36-
mk_sp(attrs[0].span.lo(), $hi)
37-
}
32+
mk_sp(attrs[0].span.lo(), $hi)
3833
}
3934
}};
4035
}

rustfmt-core/rustfmt-lib/src/utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use syntax::ast::{
66
self, Attribute, CrateSugar, MetaItem, MetaItemKind, NestedMetaItem, NodeId, Path, Visibility,
77
VisibilityKind,
88
};
9-
use syntax::ptr;
9+
use syntax::{ptr, print::pprust};
1010
use unicode_width::UnicodeWidthStr;
1111

1212
use crate::comment::{filter_normal_code, CharClasses, FullCodeCharKind, LineClasses};
@@ -42,7 +42,7 @@ pub(crate) fn is_same_visibility(a: &Visibility, b: &Visibility) -> bool {
4242
(
4343
VisibilityKind::Restricted { path: p, .. },
4444
VisibilityKind::Restricted { path: q, .. },
45-
) => p.to_string() == q.to_string(),
45+
) => pprust::path_to_string(p) == pprust::path_to_string(q),
4646
(VisibilityKind::Public, VisibilityKind::Public)
4747
| (VisibilityKind::Inherited, VisibilityKind::Inherited)
4848
| (
@@ -241,7 +241,7 @@ pub(crate) fn last_line_extendable(s: &str) -> bool {
241241
fn is_skip(meta_item: &MetaItem) -> bool {
242242
match meta_item.kind {
243243
MetaItemKind::Word => {
244-
let path_str = meta_item.path.to_string();
244+
let path_str = pprust::path_to_string(&meta_item.path);
245245
path_str == skip_annotation().as_str() || path_str == depr_skip_annotation().as_str()
246246
}
247247
MetaItemKind::List(ref l) => {

0 commit comments

Comments
 (0)