diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index bd5ce5d18b839..0a462379dcf7a 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -101,7 +101,7 @@ pub struct Path { } // Succeeds if the path has a single segment that is arg-free and matches the given symbol. -impl PartialEq for Path { +impl PartialEq for Box { #[inline] fn eq(&self, name: &Symbol) -> bool { if let [segment] = self.segments.as_ref() @@ -115,7 +115,7 @@ impl PartialEq for Path { } // Succeeds if the path has segments that are arg-free and match the given symbols. -impl PartialEq<&[Symbol]> for Path { +impl PartialEq<&[Symbol]> for Box { #[inline] fn eq(&self, names: &&[Symbol]) -> bool { self.segments.iter().eq(*names) @@ -134,8 +134,12 @@ impl StableHash for Path { impl Path { /// Convert a span and an identifier to the corresponding /// one-segment path. - pub fn from_ident(ident: Ident) -> Path { - Path { segments: thin_vec![PathSegment::from_ident(ident)], span: ident.span, tokens: None } + pub fn from_ident(ident: Ident) -> Box { + Box::new(Path { + segments: thin_vec![PathSegment::from_ident(ident)], + span: ident.span, + tokens: None, + }) } pub fn is_global(&self) -> bool { @@ -407,7 +411,7 @@ impl GenericBound { } } -pub type GenericBounds = Vec; +pub type GenericBounds = ThinVec; /// Specifies the enforced ordering for generic parameters. In the future, /// if we wanted to relax this order, we could override `PartialEq` and @@ -567,7 +571,7 @@ pub struct Crate { #[derive(Clone, Encodable, Decodable, Debug, StableHash)] pub struct MetaItem { pub unsafety: Safety, - pub path: Path, + pub path: Box, pub kind: MetaItemKind, pub span: Span, } @@ -884,10 +888,10 @@ pub enum PatKind { Ident(BindingMode, Ident, Option>), /// A struct or struct variant pattern (e.g., `Variant {x, y, ..}`). - Struct(Option>, Path, ThinVec, PatFieldsRest), + Struct(Option>, Box, ThinVec, PatFieldsRest), /// A tuple struct/variant pattern (`Variant(x, y, .., z)`). - TupleStruct(Option>, Path, ThinVec), + TupleStruct(Option>, Box, ThinVec), /// An or-pattern `A | B | C`. /// Invariant: `pats.len() >= 2`. @@ -897,7 +901,7 @@ pub enum PatKind { /// Unqualified path patterns `A::B::C` can legally refer to variants, structs, constants /// or associated constants. Qualified path patterns `::B::C`/`::B::C` can /// only legally refer to associated constants. - Path(Option>, Path), + Path(Option>, Box), /// A tuple pattern (`(a, b)`). Tuple(ThinVec), @@ -1534,7 +1538,7 @@ impl Expr { let (Some(lhs), Some(rhs)) = (lhs.to_bound(), rhs.to_bound()) else { return None; }; - TyKind::TraitObject(vec![lhs, rhs], TraitObjectSyntax::None) + TyKind::TraitObject(thin_vec![lhs, rhs], TraitObjectSyntax::None) } ExprKind::Underscore => TyKind::Infer, @@ -1667,6 +1671,15 @@ impl From> for Expr { } } +#[derive(Clone, Encodable, Decodable, Debug, Walkable)] +pub struct ForLoop { + pub pat: Box, + pub iter: Box, + pub body: Box, + pub label: Option