unify the AST repr of type const and const RHS#159596
Conversation
|
cc @rust-lang/clippy The parser was modified, potentially altering the grammar of (stable) Rust cc @fmease
cc @rust-lang/rustfmt |
|
|
| self.with_lifetime_rib(LifetimeRibKind::elided(LifetimeRes::Infer), |this| match rhs_kind { | ||
| ConstItemRhsKind::TypeConst { rhs: Some(anon_const) } => { | ||
| this.resolve_anon_const(anon_const, AnonConstKind::ConstArg(IsRepeatExpr::No)); | ||
| } | ||
| ConstItemRhsKind::Body { rhs: Some(expr) } => { | ||
| if let Some(body) = body { | ||
| self.with_lifetime_rib(LifetimeRibKind::elided(LifetimeRes::Infer), |this| { | ||
| this.with_constant_rib(IsRepeatExpr::No, ConstantHasGenerics::Yes, item, |this| { | ||
| this.visit_expr(expr) | ||
| }); | ||
| } | ||
| _ => (), | ||
| }) | ||
| this.visit_expr(body) | ||
| }) | ||
| }) | ||
| } |
There was a problem hiding this comment.
this is actually a bit subtle/involved change, just want to point it out. Upon repeatedly inlining resolve_anon_const, the old behavior amounted to:
- type consts:
LifetimeRib(infer) { ConstantRib(Generics::Yes, None) { LifetimeRib(Infer) { ... expr ... } } } - regular consts:
LifetimeRib(infer) { ConstantRib(Generics::Yes, item) { ... expr ... } }
The ConstantRib item argument, AFAIK, is only used for diagnostics, and so it's fine to change it from None->item (seems more correct, anyway). I also removed the duplicate inner LifetimeRib.
| pub rhs_kind: ConstItemRhsKind, | ||
| pub body: Option<Box<Expr>>, | ||
| #[visitable(ignore)] | ||
| pub kind: ConstItemKind, |
There was a problem hiding this comment.
these names are all bikesheddable, fwiw, just kinda kept the names that were there before.
bodyorexpr?ConstItemKind::BodyorConstItemKind::Normal? Or Regular or Standard or Plain or...kindor something specific to, like,is_type_const: TypeConstness::{Yes, No}?- or just,
is_type_const: bool?
This comment has been minimized.
This comment has been minimized.
867d626 to
e895ed8
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
related to min_generic_const_args, tracking issue here: #132980
Previously, we were parsing/lowering the RHS of type consts differently than regular consts. We no longer need to do so, yippee! This deletes the anon const from the RHS of type consts. This removes the fake defid for the rhs of type consts, FYI.
r? @BoxyUwU