diff --git a/src/gen/clone.rs b/src/gen/clone.rs index 8de1cd8c92..a413e3ec70 100644 --- a/src/gen/clone.rs +++ b/src/gen/clone.rs @@ -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()), } } } diff --git a/src/gen/debug.rs b/src/gen/debug.rs index 4adf8c5936..a1f0afa790 100644 --- a/src/gen/debug.rs +++ b/src/gen/debug.rs @@ -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() - } } } } diff --git a/src/gen/eq.rs b/src/gen/eq.rs index 40fed0b890..20acb809d8 100644 --- a/src/gen/eq.rs +++ b/src/gen/eq.rs @@ -878,13 +878,13 @@ impl PartialEq for GenericArgument { (GenericArgument::Type(self0), GenericArgument::Type(other0)) => { self0 == other0 } - (GenericArgument::Binding(self0), GenericArgument::Binding(other0)) => { + (GenericArgument::Const(self0), GenericArgument::Const(other0)) => { self0 == other0 } - (GenericArgument::Constraint(self0), GenericArgument::Constraint(other0)) => { + (GenericArgument::Binding(self0), GenericArgument::Binding(other0)) => { self0 == other0 } - (GenericArgument::Const(self0), GenericArgument::Const(other0)) => { + (GenericArgument::Constraint(self0), GenericArgument::Constraint(other0)) => { self0 == other0 } _ => false, diff --git a/src/gen/fold.rs b/src/gen/fold.rs index 6e19e6f3a8..98bb5794aa 100644 --- a/src/gen/fold.rs +++ b/src/gen/fold.rs @@ -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")] diff --git a/src/gen/hash.rs b/src/gen/hash.rs index f68a7630e2..d0400e19d6 100644 --- a/src/gen/hash.rs +++ b/src/gen/hash.rs @@ -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); } diff --git a/src/gen/visit.rs b/src/gen/visit.rs index 051b659368..19ddd2e726 100644 --- a/src/gen/visit.rs +++ b/src/gen/visit.rs @@ -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")] diff --git a/src/gen/visit_mut.rs b/src/gen/visit_mut.rs index 3ddbe9c067..239709d194 100644 --- a/src/gen/visit_mut.rs +++ b/src/gen/visit_mut.rs @@ -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")] diff --git a/src/path.rs b/src/path.rs index 6d2bbf9eaa..742273afdc 100644 --- a/src/path.rs +++ b/src/path.rs @@ -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`. - Binding(Binding), - /// An associated type bound: `Iterator`. - 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`. + Binding(Binding), + /// An associated type bound: `Iterator`. + 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 { ::default().to_tokens(tokens); } diff --git a/syn.json b/syn.json index fbd1419562..d50c8f5c7c 100644 --- a/syn.json +++ b/syn.json @@ -2243,6 +2243,11 @@ "syn": "Type" } ], + "Const": [ + { + "syn": "Expr" + } + ], "Binding": [ { "syn": "Binding" @@ -2252,11 +2257,6 @@ { "syn": "Constraint" } - ], - "Const": [ - { - "syn": "Expr" - } ] } }, diff --git a/tests/debug/gen.rs b/tests/debug/gen.rs index a49ee6c92f..cfd63d117b 100644 --- a/tests/debug/gen.rs +++ b/tests/debug/gen.rs @@ -2215,22 +2215,22 @@ impl Debug for Lite { formatter.write_str(")")?; Ok(()) } - syn::GenericArgument::Binding(_val) => { - formatter.write_str("Binding")?; + syn::GenericArgument::Const(_val) => { + formatter.write_str("Const")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } - syn::GenericArgument::Constraint(_val) => { - formatter.write_str("Constraint")?; + syn::GenericArgument::Binding(_val) => { + formatter.write_str("Binding")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } - syn::GenericArgument::Const(_val) => { - formatter.write_str("Const")?; + syn::GenericArgument::Constraint(_val) => { + formatter.write_str("Constraint")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?;