Skip to content

Commit 2e78db3

Browse files
authored
Rollup merge of #100610 - nnethercote:ast-and-parser-tweaks, r=spastorino
Ast and parser tweaks r? `@spastorino`
2 parents cf5c764 + 3308627 commit 2e78db3

File tree

8 files changed

+14
-25
lines changed

8 files changed

+14
-25
lines changed

compiler/rustc_ast/src/ast.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,6 @@ pub struct WhereRegionPredicate {
497497
/// E.g., `T = int`.
498498
#[derive(Clone, Encodable, Decodable, Debug)]
499499
pub struct WhereEqPredicate {
500-
pub id: NodeId,
501500
pub span: Span,
502501
pub lhs_ty: P<Ty>,
503502
pub rhs_ty: P<Ty>,
@@ -3042,6 +3041,7 @@ mod size_asserts {
30423041
static_assert_size!(Attribute, 32);
30433042
static_assert_size!(Block, 48);
30443043
static_assert_size!(Expr, 104);
3044+
static_assert_size!(ExprKind, 72);
30453045
static_assert_size!(Fn, 192);
30463046
static_assert_size!(ForeignItem, 160);
30473047
static_assert_size!(ForeignItemKind, 72);
@@ -3051,9 +3051,13 @@ mod size_asserts {
30513051
static_assert_size!(Item, 200);
30523052
static_assert_size!(ItemKind, 112);
30533053
static_assert_size!(Lit, 48);
3054+
static_assert_size!(LitKind, 24);
30543055
static_assert_size!(Pat, 120);
3056+
static_assert_size!(PatKind, 96);
30553057
static_assert_size!(Path, 40);
30563058
static_assert_size!(PathSegment, 24);
30573059
static_assert_size!(Stmt, 32);
3060+
static_assert_size!(StmtKind, 16);
30583061
static_assert_size!(Ty, 96);
3062+
static_assert_size!(TyKind, 72);
30593063
}

compiler/rustc_ast/src/mut_visit.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -935,8 +935,7 @@ pub fn noop_visit_where_predicate<T: MutVisitor>(pred: &mut WherePredicate, vis:
935935
visit_vec(bounds, |bound| noop_visit_param_bound(bound, vis));
936936
}
937937
WherePredicate::EqPredicate(ep) => {
938-
let WhereEqPredicate { id, span, lhs_ty, rhs_ty } = ep;
939-
vis.visit_id(id);
938+
let WhereEqPredicate { span, lhs_ty, rhs_ty } = ep;
940939
vis.visit_span(span);
941940
vis.visit_ty(lhs_ty);
942941
vis.visit_ty(rhs_ty);

compiler/rustc_ast_lowering/src/item.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1498,9 +1498,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
14981498
),
14991499
in_where_clause: true,
15001500
}),
1501-
WherePredicate::EqPredicate(WhereEqPredicate { id, ref lhs_ty, ref rhs_ty, span }) => {
1501+
WherePredicate::EqPredicate(WhereEqPredicate { ref lhs_ty, ref rhs_ty, span }) => {
15021502
hir::WherePredicate::EqPredicate(hir::WhereEqPredicate {
1503-
hir_id: self.lower_node_id(id),
15041503
lhs_ty: self
15051504
.lower_ty(lhs_ty, ImplTraitContext::Disallowed(ImplTraitPosition::Type)),
15061505
rhs_ty: self

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -640,11 +640,7 @@ impl<'a> TraitDef<'a> {
640640
}
641641
ast::WherePredicate::EqPredicate(we) => {
642642
let span = we.span.with_ctxt(ctxt);
643-
ast::WherePredicate::EqPredicate(ast::WhereEqPredicate {
644-
id: ast::DUMMY_NODE_ID,
645-
span,
646-
..we.clone()
647-
})
643+
ast::WherePredicate::EqPredicate(ast::WhereEqPredicate { span, ..we.clone() })
648644
}
649645
}
650646
}));

compiler/rustc_hir/src/hir.rs

-1
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,6 @@ impl<'hir> WhereRegionPredicate<'hir> {
778778
/// An equality predicate (e.g., `T = int`); currently unsupported.
779779
#[derive(Debug, HashStable_Generic)]
780780
pub struct WhereEqPredicate<'hir> {
781-
pub hir_id: HirId,
782781
pub span: Span,
783782
pub lhs_ty: &'hir Ty<'hir>,
784783
pub rhs_ty: &'hir Ty<'hir>,

compiler/rustc_hir/src/intravisit.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -876,10 +876,7 @@ pub fn walk_where_predicate<'v, V: Visitor<'v>>(
876876
visitor.visit_lifetime(lifetime);
877877
walk_list!(visitor, visit_param_bound, bounds);
878878
}
879-
WherePredicate::EqPredicate(WhereEqPredicate {
880-
hir_id, ref lhs_ty, ref rhs_ty, ..
881-
}) => {
882-
visitor.visit_id(hir_id);
879+
WherePredicate::EqPredicate(WhereEqPredicate { ref lhs_ty, ref rhs_ty, .. }) => {
883880
visitor.visit_ty(lhs_ty);
884881
visitor.visit_ty(rhs_ty);
885882
}

compiler/rustc_parse/src/parser/generics.rs

-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ impl<'a> Parser<'a> {
314314
span: lo.to(self.prev_token.span),
315315
lhs_ty: ty,
316316
rhs_ty,
317-
id: ast::DUMMY_NODE_ID,
318317
}))
319318
} else {
320319
self.maybe_recover_bounds_doubled_colon(&ty)?;

compiler/rustc_parse/src/parser/path.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ impl<'a> Parser<'a> {
527527
Ok(ident_gen_args) => ident_gen_args,
528528
Err(()) => return Ok(Some(AngleBracketedArg::Arg(arg))),
529529
};
530-
if binder.is_some() {
530+
if binder {
531531
// FIXME(compiler-errors): this could be improved by suggesting lifting
532532
// this up to the trait, at least before this becomes real syntax.
533533
// e.g. `Trait<for<'a> Assoc = Ty>` -> `for<'a> Trait<Assoc = Ty>`
@@ -720,28 +720,24 @@ impl<'a> Parser<'a> {
720720

721721
/// Given a arg inside of generics, we try to destructure it as if it were the LHS in
722722
/// `LHS = ...`, i.e. an associated type binding.
723-
/// This returns (optionally, if they are present) any `for<'a, 'b>` binder args, the
723+
/// This returns a bool indicating if there are any `for<'a, 'b>` binder args, the
724724
/// identifier, and any GAT arguments.
725725
fn get_ident_from_generic_arg(
726726
&self,
727727
gen_arg: &GenericArg,
728-
) -> Result<(Option<Vec<ast::GenericParam>>, Ident, Option<GenericArgs>), ()> {
728+
) -> Result<(bool, Ident, Option<GenericArgs>), ()> {
729729
if let GenericArg::Type(ty) = gen_arg {
730730
if let ast::TyKind::Path(qself, path) = &ty.kind
731731
&& qself.is_none()
732732
&& let [seg] = path.segments.as_slice()
733733
{
734-
return Ok((None, seg.ident, seg.args.as_deref().cloned()));
734+
return Ok((false, seg.ident, seg.args.as_deref().cloned()));
735735
} else if let ast::TyKind::TraitObject(bounds, ast::TraitObjectSyntax::None) = &ty.kind
736736
&& let [ast::GenericBound::Trait(trait_ref, ast::TraitBoundModifier::None)] =
737737
bounds.as_slice()
738738
&& let [seg] = trait_ref.trait_ref.path.segments.as_slice()
739739
{
740-
return Ok((
741-
Some(trait_ref.bound_generic_params.clone()),
742-
seg.ident,
743-
seg.args.as_deref().cloned(),
744-
));
740+
return Ok((true, seg.ident, seg.args.as_deref().cloned()));
745741
}
746742
}
747743
Err(())

0 commit comments

Comments
 (0)