Skip to content

Commit 4e6147d

Browse files
authored
Rollup merge of #129196 - Zalathar:ref-id-ref, r=compiler-errors
Remove a useless ref/id/ref round-trip from `pattern_from_hir` This re-lookup of `&hir::Pat` by its ID appears to be an artifact of earlier complexity that has since been removed from the compiler. Merely deleting the let/match results in borrow errors, but sprinkling `'tcx` in the signature allows it to work again, so I suspect that this code's current function is simply to compensate for overly loose lifetimes in the signature. Perhaps it made more sense at a time when HIR lifetimes were not tied to `'tcx`. I spotted this while working on some more experimental changes, which is why I've extracted it into its own PR.
2 parents 8a023b3 + 194ade1 commit 4e6147d

File tree

1 file changed

+2
-6
lines changed
  • compiler/rustc_mir_build/src/thir/cx

1 file changed

+2
-6
lines changed

compiler/rustc_mir_build/src/thir/cx/mod.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_hir as hir;
88
use rustc_hir::def::DefKind;
99
use rustc_hir::def_id::{DefId, LocalDefId};
1010
use rustc_hir::lang_items::LangItem;
11-
use rustc_hir::{HirId, Node};
11+
use rustc_hir::HirId;
1212
use rustc_middle::bug;
1313
use rustc_middle::middle::region;
1414
use rustc_middle::thir::*;
@@ -110,11 +110,7 @@ impl<'tcx> Cx<'tcx> {
110110
}
111111

112112
#[instrument(level = "debug", skip(self))]
113-
fn pattern_from_hir(&mut self, p: &hir::Pat<'_>) -> Box<Pat<'tcx>> {
114-
let p = match self.tcx.hir_node(p.hir_id) {
115-
Node::Pat(p) => p,
116-
node => bug!("pattern became {:?}", node),
117-
};
113+
fn pattern_from_hir(&mut self, p: &'tcx hir::Pat<'tcx>) -> Box<Pat<'tcx>> {
118114
pat_from_hir(self.tcx, self.param_env, self.typeck_results(), p)
119115
}
120116

0 commit comments

Comments
 (0)