Skip to content

Commit 5bb58a6

Browse files
committed
Make check_match and check_liveness take a LocalDefId
1 parent 1ce80e2 commit 5bb58a6

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

compiler/rustc_interface/src/passes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
775775
// "not all control paths return a value" is reported here.
776776
//
777777
// maybe move the check to a MIR pass?
778-
tcx.ensure().check_liveness(def_id.to_def_id());
778+
tcx.ensure().check_liveness(def_id);
779779
});
780780
});
781781
}

compiler/rustc_middle/src/query/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ rustc_queries! {
832832
desc { |tcx| "checking privacy in {}", describe_as_module(key, tcx) }
833833
}
834834

835-
query check_liveness(key: DefId) {
835+
query check_liveness(key: LocalDefId) {
836836
desc { |tcx| "checking liveness of variables in `{}`", tcx.def_path_str(key) }
837837
}
838838

@@ -1021,7 +1021,7 @@ rustc_queries! {
10211021
}
10221022

10231023
query check_match(key: LocalDefId) {
1024-
desc { |tcx| "match-checking `{}`", tcx.def_path_str(key.to_def_id()) }
1024+
desc { |tcx| "match-checking `{}`", tcx.def_path_str(key) }
10251025
cache_on_disk_if { true }
10261026
}
10271027

compiler/rustc_passes/src/liveness.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ use rustc_errors::Applicability;
9090
use rustc_errors::Diagnostic;
9191
use rustc_hir as hir;
9292
use rustc_hir::def::*;
93-
use rustc_hir::def_id::{DefId, LocalDefId};
93+
use rustc_hir::def_id::LocalDefId;
9494
use rustc_hir::intravisit::{self, Visitor};
9595
use rustc_hir::{Expr, HirId, HirIdMap, HirIdSet};
9696
use rustc_index::vec::IndexVec;
@@ -137,27 +137,22 @@ fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt<'_>) -> String {
137137
}
138138
}
139139

140-
fn check_liveness(tcx: TyCtxt<'_>, def_id: DefId) {
141-
let local_def_id = match def_id.as_local() {
142-
None => return,
143-
Some(def_id) => def_id,
144-
};
145-
140+
fn check_liveness(tcx: TyCtxt<'_>, def_id: LocalDefId) {
146141
// Don't run unused pass for #[derive()]
147-
let parent = tcx.local_parent(local_def_id);
142+
let parent = tcx.local_parent(def_id);
148143
if let DefKind::Impl { .. } = tcx.def_kind(parent)
149144
&& tcx.has_attr(parent, sym::automatically_derived)
150145
{
151146
return;
152147
}
153148

154149
// Don't run unused pass for #[naked]
155-
if tcx.has_attr(def_id, sym::naked) {
150+
if tcx.has_attr(def_id.to_def_id(), sym::naked) {
156151
return;
157152
}
158153

159154
let mut maps = IrMaps::new(tcx);
160-
let body_id = tcx.hir().body_owned_by(local_def_id);
155+
let body_id = tcx.hir().body_owned_by(def_id);
161156
let hir_id = tcx.hir().body_owner(body_id);
162157
let body = tcx.hir().body(body_id);
163158

@@ -173,7 +168,7 @@ fn check_liveness(tcx: TyCtxt<'_>, def_id: DefId) {
173168
maps.visit_body(body);
174169

175170
// compute liveness
176-
let mut lsets = Liveness::new(&mut maps, local_def_id);
171+
let mut lsets = Liveness::new(&mut maps, def_id);
177172
let entry_ln = lsets.compute(&body, hir_id);
178173
lsets.log_liveness(entry_ln, body_id.hir_id);
179174

0 commit comments

Comments
 (0)