Skip to content

Commit

Permalink
Code review adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
rsheeter committed Oct 24, 2022
1 parent e9c1dff commit d9b7237
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions font-codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub(crate) fn generate_parse_module(items: &Items) -> Result<proc_macro2::TokenS
})
}

fn map_the_known_world(items: &Items) -> HashMap<String, FieldType> {
fn build_type_map(items: &Items) -> HashMap<String, FieldType> {
return items
.items
.iter()
Expand Down Expand Up @@ -204,7 +204,7 @@ fn resolve_pending(items: &mut Items) -> Result<(), syn::Error> {
// We should know what some stuff is now
// In theory we could repeat resolution until we succeed or stop learning
// but I don't think ever need that currently
let known = map_the_known_world(items);
let known = build_type_map(items);

known.iter().for_each(|(k, v)| trace!("{} => {:?}", k, v));

Expand Down
7 changes: 3 additions & 4 deletions font-codegen/src/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ pub(crate) enum FieldType {
},
/// A type that may be a struct or a scalar.
///
/// This only exists at parse time; when parsing is finished this will be
/// This only exists at parse time; when parsing is finished this will be
/// resolved (or be an error).
PendingResolution {
typ: syn::Ident,
Expand Down Expand Up @@ -708,7 +708,7 @@ impl FieldType {

// We'll figure it out later, what could go wrong?
if !last.arguments.is_empty() {
panic!("Whatever shall we do with {}", quote! { #last })
return Err(syn::Error::new(path.span(), "Not sure how to handle this"));
}
debug!("Pending {}", quote! { #last });
Ok(FieldType::PendingResolution {
Expand Down Expand Up @@ -1183,14 +1183,13 @@ fn get_optional_docs(input: ParseStream) -> Result<Vec<syn::Attribute>, syn::Err
}

fn get_single_generic_type_arg(input: &syn::PathArguments) -> syn::Result<syn::Path> {
let original_input = input.clone();
match get_single_generic_arg(input)? {
Some(syn::GenericArgument::Type(syn::Type::Path(path)))
if path.qself.is_none() && path.path.segments.len() == 1 =>
{
Ok(path.path.clone())
}
_ => panic!("{}", quote! { #original_input }),
_ => Err(syn::Error::new(input.span(), "expected type")),
}
}

Expand Down

0 comments on commit d9b7237

Please sign in to comment.