Skip to content

Commit 0beba93

Browse files
committed
Auto merge of #79441 - jonas-schievink:rollup-l9v00bl, r=jonas-schievink
Rollup of 10 pull requests Successful merges: - #77758 (suggest turbofish syntax for uninferred const arguments) - #79000 (Move lev_distance to rustc_ast, make non-generic) - #79362 (Lower patterns before using the bound variable) - #79365 (Upgrades the coverage map to Version 4) - #79402 (Fix typos) - #79412 (Clean up rustdoc tests by removing unnecessary features) - #79413 (Fix persisted doctests on Windows / when using workspaces) - #79420 (Fixes a word typo in librustdoc) - #79421 (Fix docs formatting for `thir::pattern::_match`) - #79428 (Fixup compiler docs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents aefcf1f + 89ab563 commit 0beba93

File tree

63 files changed

+540
-365
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+540
-365
lines changed

compiler/rustc_ast/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ macro_rules! unwrap_or {
3434
pub mod util {
3535
pub mod classify;
3636
pub mod comments;
37-
pub mod lev_distance;
3837
pub mod literal;
3938
pub mod parser;
4039
}

compiler/rustc_ast_lowering/src/expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
353353
let else_arm = self.arm(else_pat, else_expr);
354354

355355
// Handle then + scrutinee:
356-
let then_expr = self.lower_block_expr(then);
357356
let (then_pat, scrutinee, desugar) = match cond.kind {
358357
// `<pat> => <then>`:
359358
ExprKind::Let(ref pat, ref scrutinee) => {
@@ -375,6 +374,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
375374
(pat, cond, hir::MatchSource::IfDesugar { contains_else_clause })
376375
}
377376
};
377+
let then_expr = self.lower_block_expr(then);
378378
let then_arm = self.arm(then_pat, self.arena.alloc(then_expr));
379379

380380
hir::ExprKind::Match(scrutinee, arena_vec![self; then_arm, else_arm], desugar)
@@ -400,7 +400,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
400400
};
401401

402402
// Handle then + scrutinee:
403-
let then_expr = self.lower_block_expr(body);
404403
let (then_pat, scrutinee, desugar, source) = match cond.kind {
405404
ExprKind::Let(ref pat, ref scrutinee) => {
406405
// to:
@@ -440,6 +439,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
440439
(pat, cond, hir::MatchSource::WhileDesugar, hir::LoopSource::While)
441440
}
442441
};
442+
let then_expr = self.lower_block_expr(body);
443443
let then_arm = self.arm(then_pat, self.arena.alloc(then_expr));
444444

445445
// `match <scrutinee> { ... }`

compiler/rustc_ast_lowering/src/lib.rs

+5-43
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
425425
/// declared for every type and trait definition.
426426
struct MiscCollector<'tcx, 'lowering, 'hir> {
427427
lctx: &'tcx mut LoweringContext<'lowering, 'hir>,
428-
hir_id_owner: Option<NodeId>,
429428
}
430429

431430
impl MiscCollector<'_, '_, '_> {
@@ -452,30 +451,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
452451
}
453452
}
454453
}
455-
456-
fn with_hir_id_owner<T>(
457-
&mut self,
458-
owner: Option<NodeId>,
459-
f: impl FnOnce(&mut Self) -> T,
460-
) -> T {
461-
let old = mem::replace(&mut self.hir_id_owner, owner);
462-
let r = f(self);
463-
self.hir_id_owner = old;
464-
r
465-
}
466454
}
467455

468456
impl<'tcx> Visitor<'tcx> for MiscCollector<'tcx, '_, '_> {
469-
fn visit_pat(&mut self, p: &'tcx Pat) {
470-
if let PatKind::Paren(..) | PatKind::Rest = p.kind {
471-
// Doesn't generate a HIR node
472-
} else if let Some(owner) = self.hir_id_owner {
473-
self.lctx.lower_node_id_with_owner(p.id, owner);
474-
}
475-
476-
visit::walk_pat(self, p)
477-
}
478-
479457
fn visit_item(&mut self, item: &'tcx Item) {
480458
let hir_id = self.lctx.allocate_hir_id_counter(item.id);
481459

@@ -499,24 +477,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
499477
_ => {}
500478
}
501479

502-
self.with_hir_id_owner(Some(item.id), |this| {
503-
visit::walk_item(this, item);
504-
});
480+
visit::walk_item(self, item);
505481
}
506482

507483
fn visit_assoc_item(&mut self, item: &'tcx AssocItem, ctxt: AssocCtxt) {
508484
self.lctx.allocate_hir_id_counter(item.id);
509-
let owner = match (&item.kind, ctxt) {
510-
// Ignore patterns in trait methods without bodies.
511-
(AssocItemKind::Fn(_, _, _, None), AssocCtxt::Trait) => None,
512-
_ => Some(item.id),
513-
};
514-
self.with_hir_id_owner(owner, |this| visit::walk_assoc_item(this, item, ctxt));
515-
}
516-
517-
fn visit_foreign_item(&mut self, i: &'tcx ForeignItem) {
518-
// Ignore patterns in foreign items
519-
self.with_hir_id_owner(None, |this| visit::walk_foreign_item(this, i));
485+
visit::walk_assoc_item(self, item, ctxt);
520486
}
521487

522488
fn visit_ty(&mut self, t: &'tcx Ty) {
@@ -527,18 +493,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
527493
// Mirrors visit::walk_fn_decl
528494
for parameter in &f.decl.inputs {
529495
// We don't lower the ids of argument patterns
530-
self.with_hir_id_owner(None, |this| {
531-
this.visit_pat(&parameter.pat);
532-
});
496+
self.visit_pat(&parameter.pat);
533497
self.visit_ty(&parameter.ty)
534498
}
535499
self.visit_fn_ret_ty(&f.decl.output)
536500
}
537501
TyKind::ImplTrait(def_node_id, _) => {
538502
self.lctx.allocate_hir_id_counter(def_node_id);
539-
self.with_hir_id_owner(Some(def_node_id), |this| {
540-
visit::walk_ty(this, t);
541-
});
503+
visit::walk_ty(self, t);
542504
}
543505
_ => visit::walk_ty(self, t),
544506
}
@@ -548,7 +510,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
548510
self.lower_node_id(CRATE_NODE_ID);
549511
debug_assert!(self.node_id_to_hir_id[CRATE_NODE_ID] == Some(hir::CRATE_HIR_ID));
550512

551-
visit::walk_crate(&mut MiscCollector { lctx: &mut self, hir_id_owner: None }, c);
513+
visit::walk_crate(&mut MiscCollector { lctx: &mut self }, c);
552514
visit::walk_crate(&mut item::ItemLowerer { lctx: &mut self }, c);
553515

554516
let module = self.lower_mod(&c.module);

0 commit comments

Comments
 (0)