1
Fork 0

Rollup merge of #122487 - GuillaumeGomez:rename-stmtkind-local, r=oli-obk

Rename `StmtKind::Local` variant into `StmtKind::Let`

It comes from this [discussion](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Improve.20naming.20of.20.60ExprKind.3A.3ALet.60.3F).

Starting point was:

> I often end up looking at [ExprKind::Let](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/enum.ExprKind.html#variant.Let) instead of Local because of the name. I think renaming it (both the `ExprKind` variant and the Let struct) to `LetPattern` or LetPat could improve the situation as I'm not sure I'm not the only one encountering this issue.

And then it evolved into:

> It's already `Expr::Let` instead of `StmtKind::Local`. Counterproposal: rename `StmtKind::Local` to `StmtKind::Let`.

The goal here is to clear this confusion.

r? `@oli-obk`
This commit is contained in:
Matthias Krüger 2024-03-14 20:00:21 +01:00 committed by GitHub
commit 1f4aff7d2b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
74 changed files with 103 additions and 103 deletions

View file

@ -2444,7 +2444,7 @@ impl<'tcx> Visitor<'tcx> for CheckAttrVisitor<'tcx> {
fn visit_stmt(&mut self, stmt: &'tcx hir::Stmt<'tcx>) {
// When checking statements ignore expressions, they will be checked later.
if let hir::StmtKind::Local(l) = stmt.kind {
if let hir::StmtKind::Let(l) = stmt.kind {
self.check_attributes(l.hir_id, stmt.span, Target::Statement, None);
}
intravisit::walk_stmt(self, stmt)

View file

@ -277,7 +277,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
fn visit_stmt(&mut self, s: &'v hir::Stmt<'v>) {
record_variants!(
(self, s, s.kind, Id::Node(s.hir_id), hir, Stmt, StmtKind),
[Local, Item, Expr, Semi]
[Let, Item, Expr, Semi]
);
hir_visit::walk_stmt(self, s)
}
@ -539,7 +539,7 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
fn visit_stmt(&mut self, s: &'v ast::Stmt) {
record_variants!(
(self, s, s.kind, Id::None, ast, Stmt, StmtKind),
[Local, Item, Expr, Semi, Empty, MacCall]
[Let, Item, Expr, Semi, Empty, MacCall]
);
ast_visit::walk_stmt(self, s)
}

View file

@ -771,7 +771,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
fn propagate_through_stmt(&mut self, stmt: &hir::Stmt<'_>, succ: LiveNode) -> LiveNode {
match stmt.kind {
hir::StmtKind::Local(local) => {
hir::StmtKind::Let(local) => {
// Note: we mark the variable as defined regardless of whether
// there is an initializer. Initially I had thought to only mark
// the live variable as defined if it was initialized, and then we

View file

@ -280,7 +280,7 @@ impl<'tcx> Visitor<'tcx> for CheckInlineAssembly<'tcx> {
fn visit_stmt(&mut self, stmt: &'tcx hir::Stmt<'tcx>) {
match stmt.kind {
StmtKind::Item(..) => {}
StmtKind::Local(..) => {
StmtKind::Let(..) => {
self.items.push((ItemKind::NonAsm, stmt.span));
}
StmtKind::Expr(expr) | StmtKind::Semi(expr) => {