Skip to content

Commit d458151

Browse files
committed
Sort impl blocks by rendering the type using quote
1 parent 8d66111 commit d458151

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

build-util/src/visitors.rs

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ use std::{
55
rc::Rc,
66
};
77

8-
use crate::vita_headers_db::{missing_features_filter, stub_lib_name, VitaDb};
8+
use quote::ToTokens;
99
use syn::{
1010
token, visit_mut::VisitMut, AttrStyle, Attribute, ForeignItem, Ident, Item, ItemForeignMod,
11-
MacroDelimiter, Meta, MetaList, Type,
11+
MacroDelimiter, Meta, MetaList,
1212
};
1313

14+
use crate::vita_headers_db::{missing_features_filter, stub_lib_name, VitaDb};
15+
1416
type FeatureSet = BTreeSet<Rc<str>>;
1517

1618
const DEFINED_ELSEWHERE_FUNCTIONS: [(&str, &str); 3] = [
@@ -215,24 +217,7 @@ impl VisitMut for Sort {
215217
Item::Enum(i) => (4, i.ident.to_string()),
216218
Item::Union(i) => (4, i.ident.to_string()),
217219
Item::Impl(i) => {
218-
let ident =
219-
match &*i.self_ty {
220-
Type::Path(path_type) => path_type.path.segments.iter().fold(
221-
String::new(),
222-
|acc, segment| {
223-
let ident_string = segment.ident.to_string();
224-
if acc.is_empty() {
225-
ident_string
226-
} else {
227-
acc + "::" + &ident_string
228-
}
229-
},
230-
),
231-
ty => {
232-
log::warn!("impl on unexpected type {ty:?}");
233-
String::new()
234-
}
235-
};
220+
let ident = i.self_ty.clone().into_token_stream().to_string();
236221
(4, ident)
237222
}
238223
Item::Const(i) => (5, i.ident.to_string()),

0 commit comments

Comments
 (0)