Skip to content

Commit 16513d6

Browse files
committed
Rename local_did to def_id
Signed-off-by: Miguel Guarniz <[email protected]>
1 parent 25bdc89 commit 16513d6

File tree

9 files changed

+28
-24
lines changed

9 files changed

+28
-24
lines changed

compiler/rustc_driver/src/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ impl<'tcx> pprust_hir::PpAnn for TypedAnnotation<'tcx> {
328328
let typeck_results = self.maybe_typeck_results.get().or_else(|| {
329329
self.tcx
330330
.hir()
331-
.maybe_body_owned_by(self.tcx.hir().local_def_id(expr.hir_id))
331+
.maybe_body_owned_by(expr.hir_id.owner)
332332
.map(|body_id| self.tcx.typeck_body(body_id))
333333
});
334334

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/util.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ pub fn find_param_with_region<'tcx>(
4949
};
5050

5151
let hir = &tcx.hir();
52-
let local_did = id.as_local()?;
53-
let hir_id = hir.local_def_id_to_hir_id(local_did);
52+
let def_id = id.as_local()?;
53+
let hir_id = hir.local_def_id_to_hir_id(def_id);
5454

5555
// FIXME: use def_kind
5656
// Don't perform this on closures
@@ -61,7 +61,7 @@ pub fn find_param_with_region<'tcx>(
6161
_ => {}
6262
}
6363

64-
let body_id = hir.maybe_body_owned_by(local_did)?;
64+
let body_id = hir.maybe_body_owned_by(def_id)?;
6565

6666
let owner_id = hir.body_owner(body_id);
6767
let fn_decl = hir.fn_decl_by_hir_id(owner_id).unwrap();

compiler/rustc_metadata/src/rmeta/encoder.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1614,16 +1614,16 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
16141614
}
16151615

16161616
fn encode_info_for_anon_const(&mut self, id: hir::HirId) {
1617-
let local_did = self.tcx.hir().local_def_id(id);
1618-
debug!("EncodeContext::encode_info_for_anon_const({:?})", local_did);
1619-
let body_id = self.tcx.hir().body_owned_by(local_did);
1617+
let def_id = self.tcx.hir().local_def_id(id);
1618+
debug!("EncodeContext::encode_info_for_anon_const({:?})", def_id);
1619+
let body_id = self.tcx.hir().body_owned_by(def_id);
16201620
let const_data = self.encode_rendered_const_for_body(body_id);
1621-
let qualifs = self.tcx.mir_const_qualif(local_did);
1621+
let qualifs = self.tcx.mir_const_qualif(def_id);
16221622

1623-
record!(self.tables.kind[local_did.to_def_id()] <- EntryKind::AnonConst);
1624-
record!(self.tables.mir_const_qualif[local_did.to_def_id()] <- qualifs);
1625-
record!(self.tables.rendered_const[local_did.to_def_id()] <- const_data);
1626-
self.encode_item_type(local_did.to_def_id());
1623+
record!(self.tables.kind[def_id.to_def_id()] <- EntryKind::AnonConst);
1624+
record!(self.tables.mir_const_qualif[def_id.to_def_id()] <- qualifs);
1625+
record!(self.tables.rendered_const[def_id.to_def_id()] <- const_data);
1626+
self.encode_item_type(def_id.to_def_id());
16271627
}
16281628

16291629
fn encode_native_libraries(&mut self) -> LazyArray<NativeLib> {

compiler/rustc_middle/src/hir/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ pub fn provide(providers: &mut Providers) {
157157
};
158158
providers.fn_arg_names = |tcx, id| {
159159
let hir = tcx.hir();
160-
let local_did = id.expect_local();
161-
let hir_id = hir.local_def_id_to_hir_id(local_did);
162-
if let Some(body_id) = hir.maybe_body_owned_by(local_did) {
160+
let def_id = id.expect_local();
161+
let hir_id = hir.local_def_id_to_hir_id(def_id);
162+
if let Some(body_id) = hir.maybe_body_owned_by(def_id) {
163163
tcx.arena.alloc_from_iter(hir.body_param_names(body_id))
164164
} else if let Node::TraitItem(&TraitItem {
165165
kind: TraitItemKind::Fn(_, TraitFn::Required(idents)),

compiler/rustc_mir_build/src/thir/pattern/check_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use rustc_span::{BytePos, Span};
2626
pub(crate) fn check_match(tcx: TyCtxt<'_>, def_id: DefId) {
2727
let body_id = match def_id.as_local() {
2828
None => return,
29-
Some(did) => tcx.hir().body_owned_by(did),
29+
Some(def_id) => tcx.hir().body_owned_by(def_id),
3030
};
3131

3232
let pattern_arena = TypedArena::default();

compiler/rustc_passes/src/upvars.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ pub fn provide(providers: &mut Providers) {
1515
return None;
1616
}
1717

18-
let local_did = def_id.expect_local();
19-
let body = tcx.hir().body(tcx.hir().maybe_body_owned_by(local_did)?);
18+
let local_def_id = def_id.expect_local();
19+
let body = tcx.hir().body(tcx.hir().maybe_body_owned_by(local_def_id)?);
2020

2121
let mut local_collector = LocalCollector::default();
2222
local_collector.visit_body(body);

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1783,7 +1783,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
17831783

17841784
let generator_body = generator_did
17851785
.as_local()
1786-
.and_then(|local_did| hir.maybe_body_owned_by(local_did))
1786+
.and_then(|def_id| hir.maybe_body_owned_by(def_id))
17871787
.map(|body_id| hir.body(body_id));
17881788
let is_async = match generator_did.as_local() {
17891789
Some(_) => generator_body

compiler/rustc_ty_utils/src/ty.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,14 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
207207
constness,
208208
);
209209

210-
let body_id = local_did
211-
.and_then(|id| tcx.hir().maybe_body_owned_by(id).map(|body| body.hir_id))
212-
.or(hir_id)
213-
.map_or(hir::CRATE_HIR_ID, |did| did);
210+
let body_id =
211+
local_did.and_then(|id| tcx.hir().maybe_body_owned_by(id).map(|body| body.hir_id));
212+
let body_id = match body_id {
213+
Some(id) => id,
214+
None if hir_id.is_some() => hir_id.unwrap(),
215+
_ => hir::CRATE_HIR_ID,
216+
};
217+
214218
let cause = traits::ObligationCause::misc(tcx.def_span(def_id), body_id);
215219
traits::normalize_param_env_or_error(tcx, unnormalized_env, cause)
216220
}

src/tools/clippy/clippy_lints/src/utils/author.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl<'tcx> LateLintPass<'tcx> for Author {
138138

139139
fn check_item(cx: &LateContext<'_>, hir_id: HirId) {
140140
let hir = cx.tcx.hir();
141-
if let Some(body_id) = hir.maybe_body_owned_by(hir.local_def_id(hir_id)) {
141+
if let Some(body_id) = hir.maybe_body_owned_by(hir_id.expect_owner()) {
142142
check_node(cx, hir_id, |v| {
143143
v.expr(&v.bind("expr", &hir.body(body_id).value));
144144
});

0 commit comments

Comments
 (0)