Skip to content

Commit

Permalink
Sort impl blocks by rendering the type using quote
Browse files Browse the repository at this point in the history
  • Loading branch information
pheki committed Jan 6, 2024
1 parent 8d66111 commit d458151
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions build-util/src/visitors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ use std::{
rc::Rc,
};

use crate::vita_headers_db::{missing_features_filter, stub_lib_name, VitaDb};
use quote::ToTokens;
use syn::{
token, visit_mut::VisitMut, AttrStyle, Attribute, ForeignItem, Ident, Item, ItemForeignMod,
MacroDelimiter, Meta, MetaList, Type,
MacroDelimiter, Meta, MetaList,
};

use crate::vita_headers_db::{missing_features_filter, stub_lib_name, VitaDb};

type FeatureSet = BTreeSet<Rc<str>>;

const DEFINED_ELSEWHERE_FUNCTIONS: [(&str, &str); 3] = [
Expand Down Expand Up @@ -215,24 +217,7 @@ impl VisitMut for Sort {
Item::Enum(i) => (4, i.ident.to_string()),
Item::Union(i) => (4, i.ident.to_string()),
Item::Impl(i) => {
let ident =
match &*i.self_ty {
Type::Path(path_type) => path_type.path.segments.iter().fold(
String::new(),
|acc, segment| {
let ident_string = segment.ident.to_string();
if acc.is_empty() {
ident_string
} else {
acc + "::" + &ident_string
}
},
),
ty => {
log::warn!("impl on unexpected type {ty:?}");
String::new()
}
};
let ident = i.self_ty.clone().into_token_stream().to_string();
(4, ident)
}
Item::Const(i) => (5, i.ident.to_string()),
Expand Down

0 comments on commit d458151

Please sign in to comment.