mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
Remove HirId -> LocalDefId
map from HIR.
This commit is contained in:
parent
92c4f1e2d9
commit
3e32533cc2
5 changed files with 10 additions and 15 deletions
|
@ -778,20 +778,20 @@ fn walk_parents<'tcx>(
|
|||
|
||||
Node::Expr(parent) if parent.span.ctxt() == ctxt => match parent.kind {
|
||||
ExprKind::Ret(_) => {
|
||||
let owner_id = cx.tcx.hir().body_owner(cx.enclosing_body.unwrap());
|
||||
let owner_id = cx.tcx.hir().body_owner_def_id(cx.enclosing_body.unwrap());
|
||||
Some(
|
||||
if let Node::Expr(
|
||||
closure_expr @ Expr {
|
||||
kind: ExprKind::Closure(closure),
|
||||
..
|
||||
},
|
||||
) = cx.tcx.hir().get(owner_id)
|
||||
) = cx.tcx.hir().get_by_def_id(owner_id)
|
||||
{
|
||||
closure_result_position(cx, closure, cx.typeck_results().expr_ty(closure_expr), precedence)
|
||||
} else {
|
||||
let output = cx
|
||||
.tcx
|
||||
.erase_late_bound_regions(cx.tcx.fn_sig(cx.tcx.hir().local_def_id(owner_id)).subst_identity().output());
|
||||
.erase_late_bound_regions(cx.tcx.fn_sig(owner_id).subst_identity().output());
|
||||
ty_auto_deref_stability(cx, output, precedence).position_for_result(cx)
|
||||
},
|
||||
)
|
||||
|
|
|
@ -157,7 +157,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustiveEnum {
|
|||
&& def.variants.len() > 1
|
||||
{
|
||||
let mut iter = def.variants.iter().filter_map(|v| {
|
||||
(matches!(v.data, hir::VariantData::Unit(..))
|
||||
(matches!(v.data, hir::VariantData::Unit(_, _))
|
||||
&& v.ident.as_str().starts_with('_')
|
||||
&& is_doc_hidden(cx.tcx.hir().attrs(v.hir_id)))
|
||||
.then_some((v.def_id, v.span))
|
||||
|
|
|
@ -11,8 +11,7 @@ use super::SUSPICIOUS_MAP;
|
|||
pub fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, count_recv: &hir::Expr<'_>, map_arg: &hir::Expr<'_>) {
|
||||
if_chain! {
|
||||
if is_trait_method(cx, count_recv, sym::Iterator);
|
||||
let closure = expr_or_init(cx, map_arg);
|
||||
if let hir::ExprKind::Closure(closure) = closure.kind;
|
||||
if let hir::ExprKind::Closure(closure) = expr_or_init(cx, map_arg).kind;
|
||||
let closure_body = cx.tcx.hir().body(closure.body);
|
||||
if !cx.typeck_results().expr_ty(closure_body.value).is_unit();
|
||||
then {
|
||||
|
|
|
@ -1119,9 +1119,8 @@ pub fn can_move_expr_to_closure<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'
|
|||
self.captures.entry(l).and_modify(|e| *e |= cap).or_insert(cap);
|
||||
}
|
||||
},
|
||||
ExprKind::Closure { .. } => {
|
||||
let closure_id = self.cx.tcx.hir().local_def_id(e.hir_id);
|
||||
for capture in self.cx.typeck_results().closure_min_captures_flattened(closure_id) {
|
||||
ExprKind::Closure(closure) => {
|
||||
for capture in self.cx.typeck_results().closure_min_captures_flattened(closure.def_id) {
|
||||
let local_id = match capture.place.base {
|
||||
PlaceBase::Local(id) => id,
|
||||
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
|
|||
}
|
||||
|
||||
/// Convenience function to get the nth argument type of a function.
|
||||
pub fn nth_arg<'tcx>(cx: &LateContext<'tcx>, fn_item: hir::HirId, nth: usize) -> Ty<'tcx> {
|
||||
let fn_def_id = cx.tcx.hir().local_def_id(fn_item);
|
||||
pub fn nth_arg<'tcx>(cx: &LateContext<'tcx>, fn_def_id: hir::OwnerId, nth: usize) -> Ty<'tcx> {
|
||||
let arg = cx.tcx.fn_sig(fn_def_id).subst_identity().input(nth);
|
||||
cx.tcx.erase_late_bound_regions(arg)
|
||||
}
|
||||
|
|
|
@ -809,7 +809,7 @@ pub struct DerefClosure {
|
|||
///
|
||||
/// note: this only works on single line immutable closures with exactly one input parameter.
|
||||
pub fn deref_closure_args(cx: &LateContext<'_>, closure: &hir::Expr<'_>) -> Option<DerefClosure> {
|
||||
if let hir::ExprKind::Closure(&Closure { fn_decl, body, .. }) = closure.kind {
|
||||
if let hir::ExprKind::Closure(&Closure { fn_decl, def_id, body, .. }) = closure.kind {
|
||||
let closure_body = cx.tcx.hir().body(body);
|
||||
// is closure arg a type annotated double reference (i.e.: `|x: &&i32| ...`)
|
||||
// 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
|
|||
applicability: Applicability::MachineApplicable,
|
||||
};
|
||||
|
||||
let fn_def_id = cx.tcx.hir().local_def_id(closure.hir_id);
|
||||
let infcx = cx.tcx.infer_ctxt().build();
|
||||
ExprUseVisitor::new(&mut visitor, &infcx, fn_def_id, cx.param_env, cx.typeck_results())
|
||||
.consume_body(closure_body);
|
||||
ExprUseVisitor::new(&mut visitor, &infcx, def_id, cx.param_env, cx.typeck_results()).consume_body(closure_body);
|
||||
|
||||
if !visitor.suggestion_start.is_empty() {
|
||||
return Some(DerefClosure {
|
||||
|
|
Loading…
Reference in a new issue