Skip to content

Commit 3e32533

Browse files
committed
Remove HirId -> LocalDefId map from HIR.
1 parent 92c4f1e commit 3e32533

File tree

5 files changed

+10
-15
lines changed

5 files changed

+10
-15
lines changed

clippy_lints/src/dereference.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -778,20 +778,20 @@ fn walk_parents<'tcx>(
778778

779779
Node::Expr(parent) if parent.span.ctxt() == ctxt => match parent.kind {
780780
ExprKind::Ret(_) => {
781-
let owner_id = cx.tcx.hir().body_owner(cx.enclosing_body.unwrap());
781+
let owner_id = cx.tcx.hir().body_owner_def_id(cx.enclosing_body.unwrap());
782782
Some(
783783
if let Node::Expr(
784784
closure_expr @ Expr {
785785
kind: ExprKind::Closure(closure),
786786
..
787787
},
788-
) = cx.tcx.hir().get(owner_id)
788+
) = cx.tcx.hir().get_by_def_id(owner_id)
789789
{
790790
closure_result_position(cx, closure, cx.typeck_results().expr_ty(closure_expr), precedence)
791791
} else {
792792
let output = cx
793793
.tcx
794-
.erase_late_bound_regions(cx.tcx.fn_sig(cx.tcx.hir().local_def_id(owner_id)).subst_identity().output());
794+
.erase_late_bound_regions(cx.tcx.fn_sig(owner_id).subst_identity().output());
795795
ty_auto_deref_stability(cx, output, precedence).position_for_result(cx)
796796
},
797797
)

clippy_lints/src/manual_non_exhaustive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustiveEnum {
157157
&& def.variants.len() > 1
158158
{
159159
let mut iter = def.variants.iter().filter_map(|v| {
160-
(matches!(v.data, hir::VariantData::Unit(..))
160+
(matches!(v.data, hir::VariantData::Unit(_, _))
161161
&& v.ident.as_str().starts_with('_')
162162
&& is_doc_hidden(cx.tcx.hir().attrs(v.hir_id)))
163163
.then_some((v.def_id, v.span))

clippy_lints/src/methods/suspicious_map.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ use super::SUSPICIOUS_MAP;
1111
pub fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, count_recv: &hir::Expr<'_>, map_arg: &hir::Expr<'_>) {
1212
if_chain! {
1313
if is_trait_method(cx, count_recv, sym::Iterator);
14-
let closure = expr_or_init(cx, map_arg);
15-
if let hir::ExprKind::Closure(closure) = closure.kind;
14+
if let hir::ExprKind::Closure(closure) = expr_or_init(cx, map_arg).kind;
1615
let closure_body = cx.tcx.hir().body(closure.body);
1716
if !cx.typeck_results().expr_ty(closure_body.value).is_unit();
1817
then {

clippy_utils/src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,9 +1119,8 @@ pub fn can_move_expr_to_closure<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'
11191119
self.captures.entry(l).and_modify(|e| *e |= cap).or_insert(cap);
11201120
}
11211121
},
1122-
ExprKind::Closure { .. } => {
1123-
let closure_id = self.cx.tcx.hir().local_def_id(e.hir_id);
1124-
for capture in self.cx.typeck_results().closure_min_captures_flattened(closure_id) {
1122+
ExprKind::Closure(closure) => {
1123+
for capture in self.cx.typeck_results().closure_min_captures_flattened(closure.def_id) {
11251124
let local_id = match capture.place.base {
11261125
PlaceBase::Local(id) => id,
11271126
PlaceBase::Upvar(var) => var.var_path.hir_id,
@@ -1584,8 +1583,7 @@ pub fn return_ty<'tcx>(cx: &LateContext<'tcx>, fn_def_id: hir::OwnerId) -> Ty<'t
15841583
}
15851584

15861585
/// Convenience function to get the nth argument type of a function.
1587-
pub fn nth_arg<'tcx>(cx: &LateContext<'tcx>, fn_item: hir::HirId, nth: usize) -> Ty<'tcx> {
1588-
let fn_def_id = cx.tcx.hir().local_def_id(fn_item);
1586+
pub fn nth_arg<'tcx>(cx: &LateContext<'tcx>, fn_def_id: hir::OwnerId, nth: usize) -> Ty<'tcx> {
15891587
let arg = cx.tcx.fn_sig(fn_def_id).subst_identity().input(nth);
15901588
cx.tcx.erase_late_bound_regions(arg)
15911589
}

clippy_utils/src/sugg.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ pub struct DerefClosure {
809809
///
810810
/// note: this only works on single line immutable closures with exactly one input parameter.
811811
pub fn deref_closure_args(cx: &LateContext<'_>, closure: &hir::Expr<'_>) -> Option<DerefClosure> {
812-
if let hir::ExprKind::Closure(&Closure { fn_decl, body, .. }) = closure.kind {
812+
if let hir::ExprKind::Closure(&Closure { fn_decl, def_id, body, .. }) = closure.kind {
813813
let closure_body = cx.tcx.hir().body(body);
814814
// is closure arg a type annotated double reference (i.e.: `|x: &&i32| ...`)
815815
// a type annotation is present if param `kind` is different from `TyKind::Infer`
@@ -829,10 +829,8 @@ pub fn deref_closure_args(cx: &LateContext<'_>, closure: &hir::Expr<'_>) -> Opti
829829
applicability: Applicability::MachineApplicable,
830830
};
831831

832-
let fn_def_id = cx.tcx.hir().local_def_id(closure.hir_id);
833832
let infcx = cx.tcx.infer_ctxt().build();
834-
ExprUseVisitor::new(&mut visitor, &infcx, fn_def_id, cx.param_env, cx.typeck_results())
835-
.consume_body(closure_body);
833+
ExprUseVisitor::new(&mut visitor, &infcx, def_id, cx.param_env, cx.typeck_results()).consume_body(closure_body);
836834

837835
if !visitor.suggestion_start.is_empty() {
838836
return Some(DerefClosure {

0 commit comments

Comments
 (0)