rustc: hir().local_def_id_to_hir_id()
-> tcx.local_def_id_to_hir_id()
cleanup
This commit is contained in:
parent
a79a7d6510
commit
bf86fe130c
@ -255,7 +255,7 @@ fn check_hash_peq<'tcx>(
|
||||
"you are deriving `Hash` but have implemented `PartialEq` explicitly",
|
||||
|diag| {
|
||||
if let Some(local_def_id) = impl_id.as_local() {
|
||||
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_def_id);
|
||||
let hir_id = cx.tcx.local_def_id_to_hir_id(local_def_id);
|
||||
diag.span_note(cx.tcx.hir().span(hir_id), "`PartialEq` implemented here");
|
||||
}
|
||||
},
|
||||
@ -299,7 +299,7 @@ fn check_ord_partial_ord<'tcx>(
|
||||
|
||||
span_lint_and_then(cx, DERIVE_ORD_XOR_PARTIAL_ORD, span, mess, |diag| {
|
||||
if let Some(local_def_id) = impl_id.as_local() {
|
||||
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_def_id);
|
||||
let hir_id = cx.tcx.local_def_id_to_hir_id(local_def_id);
|
||||
diag.span_note(cx.tcx.hir().span(hir_id), "`PartialOrd` implemented here");
|
||||
}
|
||||
});
|
||||
@ -381,7 +381,7 @@ fn check_unsafe_derive_deserialize<'tcx>(
|
||||
&& match_def_path(cx, trait_def_id, &paths::SERDE_DESERIALIZE)
|
||||
&& let ty::Adt(def, _) = ty.kind()
|
||||
&& let Some(local_def_id) = def.did().as_local()
|
||||
&& let adt_hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_def_id)
|
||||
&& let adt_hir_id = cx.tcx.local_def_id_to_hir_id(local_def_id)
|
||||
&& !is_lint_allowed(cx, UNSAFE_DERIVE_DESERIALIZE, adt_hir_id)
|
||||
&& cx
|
||||
.tcx
|
||||
|
@ -58,7 +58,7 @@ impl<'tcx> LateLintPass<'tcx> for ErrorImplError {
|
||||
if let Some(trait_def_id) = imp.of_trait.and_then(|t| t.trait_def_id())
|
||||
&& error_def_id == trait_def_id
|
||||
&& let Some(def_id) = path_res(cx, imp.self_ty).opt_def_id().and_then(DefId::as_local)
|
||||
&& let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def_id)
|
||||
&& let hir_id = cx.tcx.local_def_id_to_hir_id(def_id)
|
||||
&& let Some(ident) = cx.tcx.opt_item_ident(def_id.to_def_id())
|
||||
&& ident.name == sym::Error
|
||||
&& is_visible_outside_module(cx, def_id) =>
|
||||
|
@ -74,7 +74,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
|
||||
let parent_id = cx
|
||||
.tcx
|
||||
.hir()
|
||||
.get_parent_item(cx.tcx.hir().local_def_id_to_hir_id(fn_def_id))
|
||||
.get_parent_item(cx.tcx.local_def_id_to_hir_id(fn_def_id))
|
||||
.def_id;
|
||||
let parent_node = cx.tcx.hir().find_by_def_id(parent_id);
|
||||
|
||||
|
@ -171,7 +171,7 @@ impl<'tcx> LateLintPass<'tcx> for ExcessiveBools {
|
||||
span: Span,
|
||||
def_id: LocalDefId,
|
||||
) {
|
||||
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def_id);
|
||||
let hir_id = cx.tcx.local_def_id_to_hir_id(def_id);
|
||||
if let Some(fn_header) = fn_kind.header()
|
||||
&& fn_header.abi == Abi::Rust
|
||||
&& get_parent_as_impl(cx.tcx, hir_id).map_or(true, |impl_item| impl_item.of_trait.is_none())
|
||||
|
@ -407,7 +407,7 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
|
||||
span: Span,
|
||||
def_id: LocalDefId,
|
||||
) {
|
||||
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def_id);
|
||||
let hir_id = cx.tcx.local_def_id_to_hir_id(def_id);
|
||||
too_many_arguments::check_fn(cx, kind, decl, span, hir_id, self.too_many_arguments_threshold);
|
||||
too_many_lines::check_fn(cx, kind, span, body, self.too_many_lines_threshold);
|
||||
not_unsafe_ptr_arg_deref::check_fn(cx, kind, decl, body, def_id);
|
||||
|
@ -62,7 +62,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
|
||||
if let FnKind::Closure = kind {
|
||||
return;
|
||||
}
|
||||
let ret_ty = return_ty(cx, cx.tcx.hir().local_def_id_to_hir_id(fn_def_id).expect_owner());
|
||||
let ret_ty = return_ty(cx, cx.tcx.local_def_id_to_hir_id(fn_def_id).expect_owner());
|
||||
if let ty::Alias(ty::Opaque, AliasTy { def_id, args, .. }) = *ret_ty.kind() {
|
||||
let preds = cx.tcx.explicit_item_bounds(def_id);
|
||||
let mut is_future = false;
|
||||
|
@ -63,7 +63,7 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
|
||||
&& !is_lint_allowed(
|
||||
cx,
|
||||
MULTIPLE_INHERENT_IMPL,
|
||||
cx.tcx.hir().local_def_id_to_hir_id(id),
|
||||
cx.tcx.local_def_id_to_hir_id(id),
|
||||
)
|
||||
}) {
|
||||
for impl_id in impl_ids.iter().map(|id| id.expect_local()) {
|
||||
@ -117,7 +117,7 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
|
||||
|
||||
/// Gets the span for the given impl block unless it's not being considered by the lint.
|
||||
fn get_impl_span(cx: &LateContext<'_>, id: LocalDefId) -> Option<Span> {
|
||||
let id = cx.tcx.hir().local_def_id_to_hir_id(id);
|
||||
let id = cx.tcx.local_def_id_to_hir_id(id);
|
||||
if let Node::Item(&Item {
|
||||
kind: ItemKind::Impl(impl_item),
|
||||
span,
|
||||
|
@ -142,7 +142,7 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
|
||||
&& let TyKind::Path(ty_path) = &imp.self_ty.kind
|
||||
&& let Some(ty_id) = cx.qpath_res(ty_path, imp.self_ty.hir_id).opt_def_id()
|
||||
&& let Some(local_id) = ty_id.as_local()
|
||||
&& let ty_hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_id)
|
||||
&& let ty_hir_id = cx.tcx.local_def_id_to_hir_id(local_id)
|
||||
&& !is_lint_allowed(cx, LEN_WITHOUT_IS_EMPTY, ty_hir_id)
|
||||
&& let Some(output) =
|
||||
parse_len_output(cx, cx.tcx.fn_sig(item.owner_id).instantiate_identity().skip_binder())
|
||||
|
@ -192,7 +192,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustiveEnum {
|
||||
.contains(&(enum_id.to_def_id(), variant_id.to_def_id()))
|
||||
})
|
||||
{
|
||||
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(enum_id);
|
||||
let hir_id = cx.tcx.local_def_id_to_hir_id(enum_id);
|
||||
span_lint_hir_and_then(
|
||||
cx,
|
||||
MANUAL_NON_EXHAUSTIVE,
|
||||
|
@ -27,7 +27,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, arg: &
|
||||
closure.def_id.to_def_id(),
|
||||
Binder::bind_with_vars(
|
||||
cx.typeck_results().node_type(param_ty.hir_id),
|
||||
cx.tcx.late_bound_vars(cx.tcx.hir().local_def_id_to_hir_id(closure.def_id)),
|
||||
cx.tcx.late_bound_vars(cx.tcx.local_def_id_to_hir_id(closure.def_id)),
|
||||
),
|
||||
)
|
||||
&& is_copy(cx, param_ty)
|
||||
|
@ -131,7 +131,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn {
|
||||
FnKind::Closure => return,
|
||||
}
|
||||
|
||||
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def_id);
|
||||
let hir_id = cx.tcx.local_def_id_to_hir_id(def_id);
|
||||
|
||||
// Const fns are not allowed as methods in a trait.
|
||||
{
|
||||
|
@ -137,7 +137,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> {
|
||||
return;
|
||||
}
|
||||
|
||||
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(fn_def_id);
|
||||
let hir_id = cx.tcx.local_def_id_to_hir_id(fn_def_id);
|
||||
let is_async = match kind {
|
||||
FnKind::ItemFn(.., header) => {
|
||||
if header.is_unsafe() {
|
||||
@ -256,7 +256,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> {
|
||||
span_lint_hir_and_then(
|
||||
cx,
|
||||
NEEDLESS_PASS_BY_REF_MUT,
|
||||
cx.tcx.hir().local_def_id_to_hir_id(*fn_def_id),
|
||||
cx.tcx.local_def_id_to_hir_id(*fn_def_id),
|
||||
sp,
|
||||
"this argument is a mutable reference, but not used mutably",
|
||||
|diag| {
|
||||
|
@ -86,7 +86,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
|
||||
return;
|
||||
}
|
||||
|
||||
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(fn_def_id);
|
||||
let hir_id = cx.tcx.local_def_id_to_hir_id(fn_def_id);
|
||||
|
||||
match kind {
|
||||
FnKind::ItemFn(.., header) => {
|
||||
|
@ -106,7 +106,7 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault {
|
||||
let ty = cx.tcx.type_of(d).instantiate_identity();
|
||||
if let Some(ty_def) = ty.ty_adt_def() {
|
||||
if let Some(local_def_id) = ty_def.did().as_local() {
|
||||
impls.insert(cx.tcx.hir().local_def_id_to_hir_id(local_def_id));
|
||||
impls.insert(cx.tcx.local_def_id_to_hir_id(local_def_id));
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -119,7 +119,7 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault {
|
||||
&& let self_def = cx.tcx.type_of(self_def_id).instantiate_identity()
|
||||
&& let Some(self_def) = self_def.ty_adt_def()
|
||||
&& let Some(self_local_did) = self_def.did().as_local()
|
||||
&& let self_id = cx.tcx.hir().local_def_id_to_hir_id(self_local_did)
|
||||
&& let self_id = cx.tcx.local_def_id_to_hir_id(self_local_did)
|
||||
&& impling_types.contains(&self_id)
|
||||
{
|
||||
return;
|
||||
|
@ -100,7 +100,7 @@ impl<'tcx> LateLintPass<'tcx> for NonSendFieldInSendTy {
|
||||
if let Some(field_hir_id) = field
|
||||
.did
|
||||
.as_local()
|
||||
.map(|local_def_id| hir_map.local_def_id_to_hir_id(local_def_id))
|
||||
.map(|local_def_id| cx.tcx.local_def_id_to_hir_id(local_def_id))
|
||||
&& !is_lint_allowed(cx, NON_SEND_FIELDS_IN_SEND_TY, field_hir_id)
|
||||
&& let field_ty = field.ty(cx.tcx, impl_trait_args)
|
||||
&& !ty_allowed_in_send(cx, field_ty, send_trait)
|
||||
|
@ -55,7 +55,7 @@ impl<'tcx> LateLintPass<'tcx> for PanicInResultFn {
|
||||
if matches!(fn_kind, FnKind::Closure) {
|
||||
return;
|
||||
}
|
||||
let owner = cx.tcx.hir().local_def_id_to_hir_id(def_id).expect_owner();
|
||||
let owner = cx.tcx.local_def_id_to_hir_id(def_id).expect_owner();
|
||||
if is_type_diagnostic_item(cx, return_ty(cx, owner), sym::Result) {
|
||||
lint_impl_body(cx, span, body);
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ impl<'tcx> LateLintPass<'tcx> for PassByRefOrValue {
|
||||
return;
|
||||
}
|
||||
|
||||
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def_id);
|
||||
let hir_id = cx.tcx.local_def_id_to_hir_id(def_id);
|
||||
match kind {
|
||||
FnKind::ItemFn(.., header) => {
|
||||
if header.abi != Abi::Rust {
|
||||
|
@ -115,7 +115,7 @@ impl<'tcx> LateLintPass<'tcx> for ReturnSelfNotMustUse {
|
||||
// `#[must_use]` should be put on the trait definition directly.
|
||||
&& cx.tcx.trait_id_of_impl(impl_def).is_none()
|
||||
{
|
||||
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(fn_def);
|
||||
let hir_id = cx.tcx.local_def_id_to_hir_id(fn_def);
|
||||
check_method(cx, decl, fn_def, span, hir_id.expect_owner());
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ impl<'tcx> LateLintPass<'tcx> for SelfNamedConstructors {
|
||||
|
||||
if let Some(self_def) = self_ty.ty_adt_def()
|
||||
&& let Some(self_local_did) = self_def.did().as_local()
|
||||
&& let self_id = cx.tcx.hir().local_def_id_to_hir_id(self_local_did)
|
||||
&& let self_id = cx.tcx.local_def_id_to_hir_id(self_local_did)
|
||||
&& let Some(Node::Item(x)) = cx.tcx.hir().find(self_id)
|
||||
&& let type_name = x.ident.name.as_str().to_lowercase()
|
||||
&& (impl_item.ident.name.as_str() == type_name
|
||||
|
@ -324,7 +324,7 @@ impl<'tcx> LateLintPass<'tcx> for Types {
|
||||
let is_in_trait_impl = if let Some(hir::Node::Item(item)) = cx.tcx.hir().find_by_def_id(
|
||||
cx.tcx
|
||||
.hir()
|
||||
.get_parent_item(cx.tcx.hir().local_def_id_to_hir_id(def_id))
|
||||
.get_parent_item(cx.tcx.local_def_id_to_hir_id(def_id))
|
||||
.def_id,
|
||||
) {
|
||||
matches!(item.kind, ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }))
|
||||
|
@ -349,7 +349,7 @@ fn block_parents_have_safety_comment(
|
||||
span,
|
||||
owner_id,
|
||||
..
|
||||
})) => (*span, cx.tcx.hir().local_def_id_to_hir_id(owner_id.def_id)),
|
||||
})) => (*span, cx.tcx.local_def_id_to_hir_id(owner_id.def_id)),
|
||||
_ => {
|
||||
if is_branchy(expr) {
|
||||
return false;
|
||||
@ -370,7 +370,7 @@ fn block_parents_have_safety_comment(
|
||||
span,
|
||||
owner_id,
|
||||
..
|
||||
}) => (*span, cx.tcx.hir().local_def_id_to_hir_id(owner_id.def_id)),
|
||||
}) => (*span, cx.tcx.local_def_id_to_hir_id(owner_id.def_id)),
|
||||
_ => return false,
|
||||
};
|
||||
// if unsafe block is part of a let/const/static statement,
|
||||
|
@ -91,7 +91,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryWraps {
|
||||
}
|
||||
|
||||
// Abort if the method is implementing a trait or of it a trait method.
|
||||
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def_id);
|
||||
let hir_id = cx.tcx.local_def_id_to_hir_id(def_id);
|
||||
if let Some(Node::Item(item)) = cx.tcx.hir().find_parent(hir_id) {
|
||||
if matches!(
|
||||
item.kind,
|
||||
|
@ -709,7 +709,7 @@ pub fn get_trait_def_id(cx: &LateContext<'_>, path: &[&str]) -> Option<DefId> {
|
||||
/// ```
|
||||
pub fn trait_ref_of_method<'tcx>(cx: &LateContext<'tcx>, def_id: LocalDefId) -> Option<&'tcx TraitRef<'tcx>> {
|
||||
// Get the implemented trait for the current function
|
||||
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def_id);
|
||||
let hir_id = cx.tcx.local_def_id_to_hir_id(def_id);
|
||||
let parent_impl = cx.tcx.hir().get_parent_item(hir_id);
|
||||
if parent_impl != hir::CRATE_OWNER_ID
|
||||
&& let hir::Node::Item(item) = cx.tcx.hir().get_by_def_id(parent_impl.def_id)
|
||||
@ -2567,7 +2567,7 @@ pub fn inherits_cfg(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
|
||||
|
||||
tcx.has_attr(def_id, sym::cfg)
|
||||
|| hir
|
||||
.parent_iter(hir.local_def_id_to_hir_id(def_id))
|
||||
.parent_iter(tcx.local_def_id_to_hir_id(def_id))
|
||||
.flat_map(|(parent_id, _)| hir.attrs(parent_id))
|
||||
.any(|attr| attr.has_name(sym::cfg))
|
||||
}
|
||||
@ -2687,7 +2687,7 @@ impl<'tcx> ExprUseNode<'tcx> {
|
||||
.and(Binder::dummy(cx.tcx.type_of(id).instantiate_identity())),
|
||||
)),
|
||||
Self::Return(id) => {
|
||||
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(id.def_id);
|
||||
let hir_id = cx.tcx.local_def_id_to_hir_id(id.def_id);
|
||||
if let Some(Node::Expr(Expr {
|
||||
kind: ExprKind::Closure(c),
|
||||
..
|
||||
|
@ -694,7 +694,7 @@ pub fn ty_sig<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<ExprFnSig<'t
|
||||
ty::Closure(id, subs) => {
|
||||
let decl = id
|
||||
.as_local()
|
||||
.and_then(|id| cx.tcx.hir().fn_decl_by_hir_id(cx.tcx.hir().local_def_id_to_hir_id(id)));
|
||||
.and_then(|id| cx.tcx.hir().fn_decl_by_hir_id(cx.tcx.local_def_id_to_hir_id(id)));
|
||||
Some(ExprFnSig::Closure(decl, subs.as_closure().sig()))
|
||||
},
|
||||
ty::FnDef(id, subs) => Some(ExprFnSig::Sig(cx.tcx.fn_sig(id).instantiate(cx.tcx, subs), Some(id))),
|
||||
|
Loading…
x
Reference in New Issue
Block a user