Skip to content

Commit

Permalink
Rename Function*Parameter -> Fn*Param
Browse files Browse the repository at this point in the history
  • Loading branch information
Bromeon committed Jul 11, 2022
1 parent 6d104f7 commit 4ccc9d8
Show file tree
Hide file tree
Showing 28 changed files with 83 additions and 85 deletions.
9 changes: 4 additions & 5 deletions src/lib.rs
Expand Up @@ -69,9 +69,8 @@ pub use error::Error;
pub use parse::parse_declaration;
pub use punctuated::Punctuated;
pub use types::{
Attribute, AttributeValue, Constant, Declaration, Enum, EnumVariant, EnumVariantValue,
Function, FunctionParameter, FunctionReceiverParameter, GenericBound, GenericParam,
GenericParamList, Impl, ImplBody, ImplMember, NamedField, NamedStructFields, Struct,
StructFields, TupleField, TupleStructFields, TyExpr, TypeDefinition, Union, ValueExpr,
VisMarker, WhereClause, WhereClauseItem,
Attribute, AttributeValue, Constant, Declaration, Enum, EnumVariant, EnumVariantValue, FnParam,
FnReceiverParam, Function, GenericBound, GenericParam, GenericParamList, Impl, ImplBody,
ImplMember, NamedField, NamedStructFields, Struct, StructFields, TupleField, TupleStructFields,
TyExpr, TypeDefinition, Union, ValueExpr, VisMarker, WhereClause, WhereClauseItem,
};
13 changes: 6 additions & 7 deletions src/parse_fn.rs
Expand Up @@ -4,16 +4,15 @@ use crate::parse_type::{
use crate::parse_utils::{consume_attributes, consume_comma, consume_stuff_until, parse_ident};
use crate::punctuated::Punctuated;
use crate::types::{
Function, FunctionParameter, FunctionQualifiers, FunctionReceiverParameter,
FunctionTypedParameter, GroupSpan, TyExpr,
FnParam, FnQualifiers, FnReceiverParam, FnTypedParam, Function, GroupSpan, TyExpr,
};
use crate::{Attribute, VisMarker};
use proc_macro2::{Delimiter, Ident, Punct, TokenStream, TokenTree};
use std::iter::Peekable;

type TokenIter = Peekable<proc_macro2::token_stream::IntoIter>;

pub(crate) fn consume_fn_qualifiers(tokens: &mut TokenIter) -> FunctionQualifiers {
pub(crate) fn consume_fn_qualifiers(tokens: &mut TokenIter) -> FnQualifiers {
let tk_default = match tokens.peek() {
Some(TokenTree::Ident(ident)) if ident == "default" => {
let ident = ident.clone();
Expand Down Expand Up @@ -70,7 +69,7 @@ pub(crate) fn consume_fn_qualifiers(tokens: &mut TokenIter) -> FunctionQualifier
}
};

FunctionQualifiers {
FnQualifiers {
tk_default,
tk_const,
tk_async,
Expand All @@ -80,7 +79,7 @@ pub(crate) fn consume_fn_qualifiers(tokens: &mut TokenIter) -> FunctionQualifier
}
}

pub(crate) fn parse_fn_params(tokens: TokenStream) -> Punctuated<FunctionParameter> {
pub(crate) fn parse_fn_params(tokens: TokenStream) -> Punctuated<FnParam> {
let mut fields = Punctuated::new();

let mut tokens = tokens.into_iter().peekable();
Expand Down Expand Up @@ -116,7 +115,7 @@ pub(crate) fn parse_fn_params(tokens: TokenStream) -> Punctuated<FunctionParamet
};

let param = if let Some(tk_self) = tk_self {
FunctionParameter::Receiver(FunctionReceiverParameter {
FnParam::Receiver(FnReceiverParam {
attributes,
tk_ref,
tk_mut,
Expand All @@ -130,7 +129,7 @@ pub(crate) fn parse_fn_params(tokens: TokenStream) -> Punctuated<FunctionParamet
_ => panic!("cannot parse fn params"),
};
let ty_tokens = consume_field_type(&mut tokens);
FunctionParameter::Typed(FunctionTypedParameter {
FnParam::Typed(FnTypedParam {
attributes,
tk_mut,
name: ident,
Expand Down
4 changes: 2 additions & 2 deletions src/snapshots/venial__tests__parse_all_kw_fn.snap
Expand Up @@ -8,7 +8,7 @@ Function(
vis_marker: Some(
pub,
),
qualifiers: FunctionQualifiers {
qualifiers: FnQualifiers {
tk_default: Some(
Ident(
default,
Expand Down Expand Up @@ -50,7 +50,7 @@ Function(
tk_params_parens: (),
params: [
Typed(
FunctionTypedParameter {
FnTypedParam {
attributes: [],
tk_mut: None,
name: Ident(
Expand Down
4 changes: 2 additions & 2 deletions src/snapshots/venial__tests__parse_async_fn.snap
Expand Up @@ -8,7 +8,7 @@ Function(
vis_marker: Some(
pub,
),
qualifiers: FunctionQualifiers {
qualifiers: FnQualifiers {
tk_default: None,
tk_const: None,
tk_async: Some(
Expand All @@ -30,7 +30,7 @@ Function(
tk_params_parens: (),
params: [
Typed(
FunctionTypedParameter {
FnTypedParam {
attributes: [],
tk_mut: None,
name: Ident(
Expand Down
4 changes: 2 additions & 2 deletions src/snapshots/venial__tests__parse_attr_fn.snap
Expand Up @@ -18,7 +18,7 @@ Function(
},
],
vis_marker: None,
qualifiers: FunctionQualifiers {
qualifiers: FnQualifiers {
tk_default: None,
tk_const: None,
tk_async: None,
Expand All @@ -36,7 +36,7 @@ Function(
tk_params_parens: (),
params: [
Typed(
FunctionTypedParameter {
FnTypedParam {
attributes: [],
tk_mut: None,
name: Ident(
Expand Down
4 changes: 2 additions & 2 deletions src/snapshots/venial__tests__parse_const_fn.snap
Expand Up @@ -8,7 +8,7 @@ Function(
vis_marker: Some(
pub,
),
qualifiers: FunctionQualifiers {
qualifiers: FnQualifiers {
tk_default: None,
tk_const: Some(
Ident(
Expand All @@ -30,7 +30,7 @@ Function(
tk_params_parens: (),
params: [
Typed(
FunctionTypedParameter {
FnTypedParam {
attributes: [],
tk_mut: None,
name: Ident(
Expand Down
4 changes: 2 additions & 2 deletions src/snapshots/venial__tests__parse_default_fn.snap
Expand Up @@ -8,7 +8,7 @@ Function(
vis_marker: Some(
pub,
),
qualifiers: FunctionQualifiers {
qualifiers: FnQualifiers {
tk_default: Some(
Ident(
default,
Expand All @@ -30,7 +30,7 @@ Function(
tk_params_parens: (),
params: [
Typed(
FunctionTypedParameter {
FnTypedParam {
attributes: [],
tk_mut: None,
name: Ident(
Expand Down
2 changes: 1 addition & 1 deletion src/snapshots/venial__tests__parse_empty_fn.snap
Expand Up @@ -6,7 +6,7 @@ Function(
Function {
attributes: [],
vis_marker: None,
qualifiers: FunctionQualifiers {
qualifiers: FnQualifiers {
tk_default: None,
tk_const: None,
tk_async: None,
Expand Down
4 changes: 2 additions & 2 deletions src/snapshots/venial__tests__parse_extern_abi_fn.snap
Expand Up @@ -8,7 +8,7 @@ Function(
vis_marker: Some(
pub,
),
qualifiers: FunctionQualifiers {
qualifiers: FnQualifiers {
tk_default: None,
tk_const: None,
tk_async: None,
Expand All @@ -34,7 +34,7 @@ Function(
tk_params_parens: (),
params: [
Typed(
FunctionTypedParameter {
FnTypedParam {
attributes: [],
tk_mut: None,
name: Ident(
Expand Down
4 changes: 2 additions & 2 deletions src/snapshots/venial__tests__parse_extern_fn.snap
Expand Up @@ -8,7 +8,7 @@ Function(
vis_marker: Some(
pub,
),
qualifiers: FunctionQualifiers {
qualifiers: FnQualifiers {
tk_default: None,
tk_const: None,
tk_async: None,
Expand All @@ -30,7 +30,7 @@ Function(
tk_params_parens: (),
params: [
Typed(
FunctionTypedParameter {
FnTypedParam {
attributes: [],
tk_mut: None,
name: Ident(
Expand Down
6 changes: 3 additions & 3 deletions src/snapshots/venial__tests__parse_fn.snap
Expand Up @@ -6,7 +6,7 @@ Function(
Function {
attributes: [],
vis_marker: None,
qualifiers: FunctionQualifiers {
qualifiers: FnQualifiers {
tk_default: None,
tk_const: None,
tk_async: None,
Expand All @@ -24,7 +24,7 @@ Function(
tk_params_parens: (),
params: [
Typed(
FunctionTypedParameter {
FnTypedParam {
attributes: [],
tk_mut: None,
name: Ident(
Expand All @@ -40,7 +40,7 @@ Function(
},
),
Typed(
FunctionTypedParameter {
FnTypedParam {
attributes: [],
tk_mut: None,
name: Ident(
Expand Down
6 changes: 3 additions & 3 deletions src/snapshots/venial__tests__parse_fn_body.snap
Expand Up @@ -6,7 +6,7 @@ Function(
Function {
attributes: [],
vis_marker: None,
qualifiers: FunctionQualifiers {
qualifiers: FnQualifiers {
tk_default: None,
tk_const: None,
tk_async: None,
Expand All @@ -24,7 +24,7 @@ Function(
tk_params_parens: (),
params: [
Typed(
FunctionTypedParameter {
FnTypedParam {
attributes: [],
tk_mut: None,
name: Ident(
Expand All @@ -40,7 +40,7 @@ Function(
},
),
Typed(
FunctionTypedParameter {
FnTypedParam {
attributes: [],
tk_mut: None,
name: Ident(
Expand Down
4 changes: 2 additions & 2 deletions src/snapshots/venial__tests__parse_fn_lifetimes.snap
Expand Up @@ -6,7 +6,7 @@ Function(
Function {
attributes: [],
vis_marker: None,
qualifiers: FunctionQualifiers {
qualifiers: FnQualifiers {
tk_default: None,
tk_const: None,
tk_async: None,
Expand All @@ -31,7 +31,7 @@ Function(
tk_params_parens: (),
params: [
Typed(
FunctionTypedParameter {
FnTypedParam {
attributes: [],
tk_mut: None,
name: Ident(
Expand Down
6 changes: 3 additions & 3 deletions src/snapshots/venial__tests__parse_fn_mut_param.snap
Expand Up @@ -6,7 +6,7 @@ Function(
Function {
attributes: [],
vis_marker: None,
qualifiers: FunctionQualifiers {
qualifiers: FnQualifiers {
tk_default: None,
tk_const: None,
tk_async: None,
Expand All @@ -24,7 +24,7 @@ Function(
tk_params_parens: (),
params: [
Typed(
FunctionTypedParameter {
FnTypedParam {
attributes: [],
tk_mut: None,
name: Ident(
Expand All @@ -40,7 +40,7 @@ Function(
},
),
Typed(
FunctionTypedParameter {
FnTypedParam {
attributes: [],
tk_mut: Some(
Ident(
Expand Down
6 changes: 3 additions & 3 deletions src/snapshots/venial__tests__parse_fn_prototype.snap
Expand Up @@ -6,7 +6,7 @@ Function(
Function {
attributes: [],
vis_marker: None,
qualifiers: FunctionQualifiers {
qualifiers: FnQualifiers {
tk_default: None,
tk_const: None,
tk_async: None,
Expand All @@ -24,7 +24,7 @@ Function(
tk_params_parens: (),
params: [
Typed(
FunctionTypedParameter {
FnTypedParam {
attributes: [],
tk_mut: None,
name: Ident(
Expand All @@ -40,7 +40,7 @@ Function(
},
),
Typed(
FunctionTypedParameter {
FnTypedParam {
attributes: [],
tk_mut: None,
name: Ident(
Expand Down
4 changes: 2 additions & 2 deletions src/snapshots/venial__tests__parse_fn_self_param-2.snap
Expand Up @@ -7,7 +7,7 @@ Ok(
Function {
attributes: [],
vis_marker: None,
qualifiers: FunctionQualifiers {
qualifiers: FnQualifiers {
tk_default: None,
tk_const: None,
tk_async: None,
Expand All @@ -25,7 +25,7 @@ Ok(
tk_params_parens: (),
params: [
Receiver(
FunctionReceiverParameter {
FnReceiverParam {
attributes: [],
tk_ref: Some(
Punct {
Expand Down
4 changes: 2 additions & 2 deletions src/snapshots/venial__tests__parse_fn_self_param-3.snap
Expand Up @@ -7,7 +7,7 @@ Ok(
Function {
attributes: [],
vis_marker: None,
qualifiers: FunctionQualifiers {
qualifiers: FnQualifiers {
tk_default: None,
tk_const: None,
tk_async: None,
Expand All @@ -25,7 +25,7 @@ Ok(
tk_params_parens: (),
params: [
Receiver(
FunctionReceiverParameter {
FnReceiverParam {
attributes: [],
tk_ref: None,
tk_mut: Some(
Expand Down
4 changes: 2 additions & 2 deletions src/snapshots/venial__tests__parse_fn_self_param-4.snap
Expand Up @@ -7,7 +7,7 @@ Ok(
Function {
attributes: [],
vis_marker: None,
qualifiers: FunctionQualifiers {
qualifiers: FnQualifiers {
tk_default: None,
tk_const: None,
tk_async: None,
Expand All @@ -25,7 +25,7 @@ Ok(
tk_params_parens: (),
params: [
Receiver(
FunctionReceiverParameter {
FnReceiverParam {
attributes: [],
tk_ref: Some(
Punct {
Expand Down

0 comments on commit 4ccc9d8

Please sign in to comment.