Rollup merge of #100610 - nnethercote:ast-and-parser-tweaks, r=spastorino
Ast and parser tweaks r? `@spastorino`
This commit is contained in:
commit
2e78db3858
8 changed files with 14 additions and 25 deletions
|
@ -497,7 +497,6 @@ pub struct WhereRegionPredicate {
|
|||
/// E.g., `T = int`.
|
||||
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||
pub struct WhereEqPredicate {
|
||||
pub id: NodeId,
|
||||
pub span: Span,
|
||||
pub lhs_ty: P<Ty>,
|
||||
pub rhs_ty: P<Ty>,
|
||||
|
@ -3042,6 +3041,7 @@ mod size_asserts {
|
|||
static_assert_size!(Attribute, 32);
|
||||
static_assert_size!(Block, 48);
|
||||
static_assert_size!(Expr, 104);
|
||||
static_assert_size!(ExprKind, 72);
|
||||
static_assert_size!(Fn, 192);
|
||||
static_assert_size!(ForeignItem, 160);
|
||||
static_assert_size!(ForeignItemKind, 72);
|
||||
|
@ -3051,9 +3051,13 @@ mod size_asserts {
|
|||
static_assert_size!(Item, 200);
|
||||
static_assert_size!(ItemKind, 112);
|
||||
static_assert_size!(Lit, 48);
|
||||
static_assert_size!(LitKind, 24);
|
||||
static_assert_size!(Pat, 120);
|
||||
static_assert_size!(PatKind, 96);
|
||||
static_assert_size!(Path, 40);
|
||||
static_assert_size!(PathSegment, 24);
|
||||
static_assert_size!(Stmt, 32);
|
||||
static_assert_size!(StmtKind, 16);
|
||||
static_assert_size!(Ty, 96);
|
||||
static_assert_size!(TyKind, 72);
|
||||
}
|
||||
|
|
|
@ -935,8 +935,7 @@ pub fn noop_visit_where_predicate<T: MutVisitor>(pred: &mut WherePredicate, vis:
|
|||
visit_vec(bounds, |bound| noop_visit_param_bound(bound, vis));
|
||||
}
|
||||
WherePredicate::EqPredicate(ep) => {
|
||||
let WhereEqPredicate { id, span, lhs_ty, rhs_ty } = ep;
|
||||
vis.visit_id(id);
|
||||
let WhereEqPredicate { span, lhs_ty, rhs_ty } = ep;
|
||||
vis.visit_span(span);
|
||||
vis.visit_ty(lhs_ty);
|
||||
vis.visit_ty(rhs_ty);
|
||||
|
|
|
@ -1498,9 +1498,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
),
|
||||
in_where_clause: true,
|
||||
}),
|
||||
WherePredicate::EqPredicate(WhereEqPredicate { id, ref lhs_ty, ref rhs_ty, span }) => {
|
||||
WherePredicate::EqPredicate(WhereEqPredicate { ref lhs_ty, ref rhs_ty, span }) => {
|
||||
hir::WherePredicate::EqPredicate(hir::WhereEqPredicate {
|
||||
hir_id: self.lower_node_id(id),
|
||||
lhs_ty: self
|
||||
.lower_ty(lhs_ty, ImplTraitContext::Disallowed(ImplTraitPosition::Type)),
|
||||
rhs_ty: self
|
||||
|
|
|
@ -640,11 +640,7 @@ impl<'a> TraitDef<'a> {
|
|||
}
|
||||
ast::WherePredicate::EqPredicate(we) => {
|
||||
let span = we.span.with_ctxt(ctxt);
|
||||
ast::WherePredicate::EqPredicate(ast::WhereEqPredicate {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
span,
|
||||
..we.clone()
|
||||
})
|
||||
ast::WherePredicate::EqPredicate(ast::WhereEqPredicate { span, ..we.clone() })
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -778,7 +778,6 @@ impl<'hir> WhereRegionPredicate<'hir> {
|
|||
/// An equality predicate (e.g., `T = int`); currently unsupported.
|
||||
#[derive(Debug, HashStable_Generic)]
|
||||
pub struct WhereEqPredicate<'hir> {
|
||||
pub hir_id: HirId,
|
||||
pub span: Span,
|
||||
pub lhs_ty: &'hir Ty<'hir>,
|
||||
pub rhs_ty: &'hir Ty<'hir>,
|
||||
|
|
|
@ -876,10 +876,7 @@ pub fn walk_where_predicate<'v, V: Visitor<'v>>(
|
|||
visitor.visit_lifetime(lifetime);
|
||||
walk_list!(visitor, visit_param_bound, bounds);
|
||||
}
|
||||
WherePredicate::EqPredicate(WhereEqPredicate {
|
||||
hir_id, ref lhs_ty, ref rhs_ty, ..
|
||||
}) => {
|
||||
visitor.visit_id(hir_id);
|
||||
WherePredicate::EqPredicate(WhereEqPredicate { ref lhs_ty, ref rhs_ty, .. }) => {
|
||||
visitor.visit_ty(lhs_ty);
|
||||
visitor.visit_ty(rhs_ty);
|
||||
}
|
||||
|
|
|
@ -314,7 +314,6 @@ impl<'a> Parser<'a> {
|
|||
span: lo.to(self.prev_token.span),
|
||||
lhs_ty: ty,
|
||||
rhs_ty,
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
}))
|
||||
} else {
|
||||
self.maybe_recover_bounds_doubled_colon(&ty)?;
|
||||
|
|
|
@ -527,7 +527,7 @@ impl<'a> Parser<'a> {
|
|||
Ok(ident_gen_args) => ident_gen_args,
|
||||
Err(()) => return Ok(Some(AngleBracketedArg::Arg(arg))),
|
||||
};
|
||||
if binder.is_some() {
|
||||
if binder {
|
||||
// FIXME(compiler-errors): this could be improved by suggesting lifting
|
||||
// this up to the trait, at least before this becomes real syntax.
|
||||
// e.g. `Trait<for<'a> Assoc = Ty>` -> `for<'a> Trait<Assoc = Ty>`
|
||||
|
@ -720,28 +720,24 @@ impl<'a> Parser<'a> {
|
|||
|
||||
/// Given a arg inside of generics, we try to destructure it as if it were the LHS in
|
||||
/// `LHS = ...`, i.e. an associated type binding.
|
||||
/// This returns (optionally, if they are present) any `for<'a, 'b>` binder args, the
|
||||
/// This returns a bool indicating if there are any `for<'a, 'b>` binder args, the
|
||||
/// identifier, and any GAT arguments.
|
||||
fn get_ident_from_generic_arg(
|
||||
&self,
|
||||
gen_arg: &GenericArg,
|
||||
) -> Result<(Option<Vec<ast::GenericParam>>, Ident, Option<GenericArgs>), ()> {
|
||||
) -> Result<(bool, Ident, Option<GenericArgs>), ()> {
|
||||
if let GenericArg::Type(ty) = gen_arg {
|
||||
if let ast::TyKind::Path(qself, path) = &ty.kind
|
||||
&& qself.is_none()
|
||||
&& let [seg] = path.segments.as_slice()
|
||||
{
|
||||
return Ok((None, seg.ident, seg.args.as_deref().cloned()));
|
||||
return Ok((false, seg.ident, seg.args.as_deref().cloned()));
|
||||
} else if let ast::TyKind::TraitObject(bounds, ast::TraitObjectSyntax::None) = &ty.kind
|
||||
&& let [ast::GenericBound::Trait(trait_ref, ast::TraitBoundModifier::None)] =
|
||||
bounds.as_slice()
|
||||
&& let [seg] = trait_ref.trait_ref.path.segments.as_slice()
|
||||
{
|
||||
return Ok((
|
||||
Some(trait_ref.bound_generic_params.clone()),
|
||||
seg.ident,
|
||||
seg.args.as_deref().cloned(),
|
||||
));
|
||||
return Ok((true, seg.ident, seg.args.as_deref().cloned()));
|
||||
}
|
||||
}
|
||||
Err(())
|
||||
|
|
Loading…
Add table
Reference in a new issue