Rollup merge of #122780 - GuillaumeGomez:rename-hir-local, r=oli-obk
Rename `hir::Local` into `hir::LetStmt` Follow-up of #122776. As discussed on [zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Improve.20naming.20of.20.60ExprKind.3A.3ALet.60.3F). I made this change into a separate PR because I'm less sure about this change as is. For example, we have `visit_local` and `LocalSource` items. Is it fine to keep these two as is (I supposed it is but I prefer to ask) or not? Having `Node::Local(LetStmt)` makes things more explicit but is it going too far? r? ```@oli-obk```
This commit is contained in:
commit
99e34b4f7a
82 changed files with 178 additions and 177 deletions
|
@ -937,7 +937,7 @@ impl<'tcx> LateContext<'tcx> {
|
|||
}
|
||||
&& let Some(init) = match parent_node {
|
||||
hir::Node::Expr(expr) => Some(expr),
|
||||
hir::Node::Local(hir::Local { init, .. }) => *init,
|
||||
hir::Node::LetStmt(hir::LetStmt { init, .. }) => *init,
|
||||
_ => None,
|
||||
}
|
||||
{
|
||||
|
@ -982,7 +982,7 @@ impl<'tcx> LateContext<'tcx> {
|
|||
}
|
||||
&& let Some(init) = match parent_node {
|
||||
hir::Node::Expr(expr) => Some(expr),
|
||||
hir::Node::Local(hir::Local { init, .. }) => *init,
|
||||
hir::Node::LetStmt(hir::LetStmt { init, .. }) => *init,
|
||||
hir::Node::Item(item) => match item.kind {
|
||||
hir::ItemKind::Const(.., body_id) | hir::ItemKind::Static(.., body_id) => {
|
||||
Some(self.tcx.hir().body(body_id).value)
|
||||
|
|
|
@ -238,7 +238,7 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
|
|||
}
|
||||
}
|
||||
|
||||
fn visit_local(&mut self, l: &'tcx hir::Local<'tcx>) {
|
||||
fn visit_local(&mut self, l: &'tcx hir::LetStmt<'tcx>) {
|
||||
self.with_lint_attrs(l.hir_id, |cx| {
|
||||
lint_callback!(cx, check_local, l);
|
||||
hir_visit::walk_local(cx, l);
|
||||
|
|
|
@ -105,7 +105,7 @@ const SYNC_GUARD_SYMBOLS: [Symbol; 3] = [
|
|||
|
||||
impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
|
||||
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
|
||||
fn check_local(&mut self, cx: &LateContext<'_>, local: &hir::Local<'_>) {
|
||||
fn check_local(&mut self, cx: &LateContext<'_>, local: &hir::LetStmt<'_>) {
|
||||
if matches!(local.source, rustc_hir::LocalSource::AsyncFn) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -354,7 +354,7 @@ impl<'tcx> Visitor<'tcx> for LintLevelsBuilder<'_, LintLevelQueryMap<'tcx>> {
|
|||
intravisit::walk_variant(self, v);
|
||||
}
|
||||
|
||||
fn visit_local(&mut self, l: &'tcx hir::Local<'tcx>) {
|
||||
fn visit_local(&mut self, l: &'tcx hir::LetStmt<'tcx>) {
|
||||
self.add_id(l.hir_id);
|
||||
intravisit::walk_local(self, l);
|
||||
}
|
||||
|
@ -428,7 +428,7 @@ impl<'tcx> Visitor<'tcx> for LintLevelsBuilder<'_, QueryMapExpectationsWrapper<'
|
|||
intravisit::walk_variant(self, v);
|
||||
}
|
||||
|
||||
fn visit_local(&mut self, l: &'tcx hir::Local<'tcx>) {
|
||||
fn visit_local(&mut self, l: &'tcx hir::LetStmt<'tcx>) {
|
||||
self.add_id(l.hir_id);
|
||||
intravisit::walk_local(self, l);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ macro_rules! late_lint_methods {
|
|||
fn check_foreign_item(a: &'tcx rustc_hir::ForeignItem<'tcx>);
|
||||
fn check_item(a: &'tcx rustc_hir::Item<'tcx>);
|
||||
fn check_item_post(a: &'tcx rustc_hir::Item<'tcx>);
|
||||
fn check_local(a: &'tcx rustc_hir::Local<'tcx>);
|
||||
fn check_local(a: &'tcx rustc_hir::LetStmt<'tcx>);
|
||||
fn check_block(a: &'tcx rustc_hir::Block<'tcx>);
|
||||
fn check_block_post(a: &'tcx rustc_hir::Block<'tcx>);
|
||||
fn check_stmt(a: &'tcx rustc_hir::Stmt<'tcx>);
|
||||
|
|
|
@ -46,7 +46,7 @@ declare_lint! {
|
|||
declare_lint_pass!(UnitBindings => [UNIT_BINDINGS]);
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for UnitBindings {
|
||||
fn check_local(&mut self, cx: &crate::LateContext<'tcx>, local: &'tcx hir::Local<'tcx>) {
|
||||
fn check_local(&mut self, cx: &crate::LateContext<'tcx>, local: &'tcx hir::LetStmt<'tcx>) {
|
||||
// Suppress warning if user:
|
||||
// - explicitly ascribes a type to the pattern
|
||||
// - explicitly wrote `let pat = ();`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue