Reorder GenericArgument::Const next to Type

Now that const generics were stabilized.
This commit is contained in:
David Tolnay 2022-09-18 16:12:45 -07:00
parent be1b7585a5
commit e3d6e7b66c
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
10 changed files with 44 additions and 44 deletions

2
src/gen/clone.rs generated
View File

@ -910,9 +910,9 @@ impl Clone for GenericArgument {
match self {
GenericArgument::Lifetime(v0) => GenericArgument::Lifetime(v0.clone()),
GenericArgument::Type(v0) => GenericArgument::Type(v0.clone()),
GenericArgument::Const(v0) => GenericArgument::Const(v0.clone()),
GenericArgument::Binding(v0) => GenericArgument::Binding(v0.clone()),
GenericArgument::Constraint(v0) => GenericArgument::Constraint(v0.clone()),
GenericArgument::Const(v0) => GenericArgument::Const(v0.clone()),
}
}
}

10
src/gen/debug.rs generated
View File

@ -1268,6 +1268,11 @@ impl Debug for GenericArgument {
formatter.field(v0);
formatter.finish()
}
GenericArgument::Const(v0) => {
let mut formatter = formatter.debug_tuple("Const");
formatter.field(v0);
formatter.finish()
}
GenericArgument::Binding(v0) => {
let mut formatter = formatter.debug_tuple("Binding");
formatter.field(v0);
@ -1278,11 +1283,6 @@ impl Debug for GenericArgument {
formatter.field(v0);
formatter.finish()
}
GenericArgument::Const(v0) => {
let mut formatter = formatter.debug_tuple("Const");
formatter.field(v0);
formatter.finish()
}
}
}
}

6
src/gen/eq.rs generated
View File

@ -878,15 +878,15 @@ impl PartialEq for GenericArgument {
(GenericArgument::Type(self0), GenericArgument::Type(other0)) => {
self0 == other0
}
(GenericArgument::Const(self0), GenericArgument::Const(other0)) => {
self0 == other0
}
(GenericArgument::Binding(self0), GenericArgument::Binding(other0)) => {
self0 == other0
}
(GenericArgument::Constraint(self0), GenericArgument::Constraint(other0)) => {
self0 == other0
}
(GenericArgument::Const(self0), GenericArgument::Const(other0)) => {
self0 == other0
}
_ => false,
}
}

6
src/gen/fold.rs generated
View File

@ -1787,15 +1787,15 @@ where
GenericArgument::Type(_binding_0) => {
GenericArgument::Type(f.fold_type(_binding_0))
}
GenericArgument::Const(_binding_0) => {
GenericArgument::Const(f.fold_expr(_binding_0))
}
GenericArgument::Binding(_binding_0) => {
GenericArgument::Binding(f.fold_binding(_binding_0))
}
GenericArgument::Constraint(_binding_0) => {
GenericArgument::Constraint(f.fold_constraint(_binding_0))
}
GenericArgument::Const(_binding_0) => {
GenericArgument::Const(f.fold_expr(_binding_0))
}
}
}
#[cfg(feature = "full")]

6
src/gen/hash.rs generated
View File

@ -1184,15 +1184,15 @@ impl Hash for GenericArgument {
state.write_u8(1u8);
v0.hash(state);
}
GenericArgument::Binding(v0) => {
GenericArgument::Const(v0) => {
state.write_u8(2u8);
v0.hash(state);
}
GenericArgument::Constraint(v0) => {
GenericArgument::Binding(v0) => {
state.write_u8(3u8);
v0.hash(state);
}
GenericArgument::Const(v0) => {
GenericArgument::Constraint(v0) => {
state.write_u8(4u8);
v0.hash(state);
}

6
src/gen/visit.rs generated
View File

@ -1974,15 +1974,15 @@ where
GenericArgument::Type(_binding_0) => {
v.visit_type(_binding_0);
}
GenericArgument::Const(_binding_0) => {
v.visit_expr(_binding_0);
}
GenericArgument::Binding(_binding_0) => {
v.visit_binding(_binding_0);
}
GenericArgument::Constraint(_binding_0) => {
v.visit_constraint(_binding_0);
}
GenericArgument::Const(_binding_0) => {
v.visit_expr(_binding_0);
}
}
}
#[cfg(feature = "full")]

6
src/gen/visit_mut.rs generated
View File

@ -1975,15 +1975,15 @@ where
GenericArgument::Type(_binding_0) => {
v.visit_type_mut(_binding_0);
}
GenericArgument::Const(_binding_0) => {
v.visit_expr_mut(_binding_0);
}
GenericArgument::Binding(_binding_0) => {
v.visit_binding_mut(_binding_0);
}
GenericArgument::Constraint(_binding_0) => {
v.visit_constraint_mut(_binding_0);
}
GenericArgument::Const(_binding_0) => {
v.visit_expr_mut(_binding_0);
}
}
}
#[cfg(feature = "full")]

View File

@ -109,16 +109,16 @@ ast_enum! {
Lifetime(Lifetime),
/// A type argument.
Type(Type),
/// A binding (equality constraint) on an associated type: the `Item =
/// u8` in `Iterator<Item = u8>`.
Binding(Binding),
/// An associated type bound: `Iterator<Item: Display>`.
Constraint(Constraint),
/// A const expression. Must be inside of a block.
///
/// NOTE: Identity expressions are represented as Type arguments, as
/// they are indistinguishable syntactically.
Const(Expr),
/// A binding (equality constraint) on an associated type: the `Item =
/// u8` in `Iterator<Item = u8>`.
Binding(Binding),
/// An associated type bound: `Iterator<Item: Display>`.
Constraint(Constraint),
}
}
@ -729,8 +729,6 @@ pub(crate) mod printing {
match self {
GenericArgument::Lifetime(lt) => lt.to_tokens(tokens),
GenericArgument::Type(ty) => ty.to_tokens(tokens),
GenericArgument::Binding(tb) => tb.to_tokens(tokens),
GenericArgument::Constraint(tc) => tc.to_tokens(tokens),
GenericArgument::Const(e) => match *e {
Expr::Lit(_) => e.to_tokens(tokens),
@ -746,6 +744,8 @@ pub(crate) mod printing {
e.to_tokens(tokens);
}),
},
GenericArgument::Binding(tb) => tb.to_tokens(tokens),
GenericArgument::Constraint(tc) => tc.to_tokens(tokens),
}
}
}
@ -766,17 +766,17 @@ pub(crate) mod printing {
trailing_or_empty = param.punct().is_some();
}
GenericArgument::Type(_)
| GenericArgument::Const(_)
| GenericArgument::Binding(_)
| GenericArgument::Constraint(_)
| GenericArgument::Const(_) => {}
| GenericArgument::Constraint(_) => {}
}
}
for param in self.args.pairs() {
match **param.value() {
GenericArgument::Type(_)
| GenericArgument::Const(_)
| GenericArgument::Binding(_)
| GenericArgument::Constraint(_)
| GenericArgument::Const(_) => {
| GenericArgument::Constraint(_) => {
if !trailing_or_empty {
<Token![,]>::default().to_tokens(tokens);
}

10
syn.json generated
View File

@ -2243,6 +2243,11 @@
"syn": "Type"
}
],
"Const": [
{
"syn": "Expr"
}
],
"Binding": [
{
"syn": "Binding"
@ -2252,11 +2257,6 @@
{
"syn": "Constraint"
}
],
"Const": [
{
"syn": "Expr"
}
]
}
},

14
tests/debug/gen.rs generated
View File

@ -2215,6 +2215,13 @@ impl Debug for Lite<syn::GenericArgument> {
formatter.write_str(")")?;
Ok(())
}
syn::GenericArgument::Const(_val) => {
formatter.write_str("Const")?;
formatter.write_str("(")?;
Debug::fmt(Lite(_val), formatter)?;
formatter.write_str(")")?;
Ok(())
}
syn::GenericArgument::Binding(_val) => {
formatter.write_str("Binding")?;
formatter.write_str("(")?;
@ -2229,13 +2236,6 @@ impl Debug for Lite<syn::GenericArgument> {
formatter.write_str(")")?;
Ok(())
}
syn::GenericArgument::Const(_val) => {
formatter.write_str("Const")?;
formatter.write_str("(")?;
Debug::fmt(Lite(_val), formatter)?;
formatter.write_str(")")?;
Ok(())
}
}
}
}