Rename hir::map::local_def_id_from_hir_id to local_def_id
This commit is contained in:
parent
a9f8d3a034
commit
7293defb34
@ -118,7 +118,7 @@ fn check_fn(
|
||||
span: Span,
|
||||
hir_id: HirId,
|
||||
) {
|
||||
let def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id);
|
||||
let def_id = cx.tcx.hir().local_def_id(hir_id);
|
||||
if !cx.tcx.has_attr(def_id, sym!(test)) {
|
||||
self.check(cx, body, span);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CopyIterator {
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.node {
|
||||
let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id_from_hir_id(item.hir_id));
|
||||
let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id(item.hir_id));
|
||||
|
||||
if is_copy(cx, ty) && match_path(&trait_ref.path, &paths::ITERATOR) {
|
||||
span_note_and_lint(
|
||||
|
@ -67,7 +67,7 @@
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Derive {
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.node {
|
||||
let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id_from_hir_id(item.hir_id));
|
||||
let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id(item.hir_id));
|
||||
let is_automatically_derived = is_automatically_derived(&*item.attrs);
|
||||
|
||||
check_hash_peq(cx, item.span, trait_ref, ty, is_automatically_derived);
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EmptyEnum {
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &Item) {
|
||||
let did = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
let did = cx.tcx.hir().local_def_id(item.hir_id);
|
||||
if let ItemKind::Enum(..) = item.node {
|
||||
let ty = cx.tcx.type_of(did);
|
||||
let adt = ty.ty_adt_def().expect("already checked whether this is an enum");
|
||||
|
@ -77,7 +77,7 @@ fn check_fn(
|
||||
too_large_for_stack: self.too_large_for_stack,
|
||||
};
|
||||
|
||||
let fn_def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id);
|
||||
let fn_def_id = cx.tcx.hir().local_def_id(hir_id);
|
||||
let region_scope_tree = &cx.tcx.region_scope_tree(fn_def_id);
|
||||
ExprUseVisitor::new(
|
||||
&mut v,
|
||||
|
@ -33,7 +33,7 @@
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for FallibleImplFrom {
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
|
||||
// check for `impl From<???> for ..`
|
||||
let impl_def_id = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
let impl_def_id = cx.tcx.hir().local_def_id(item.hir_id);
|
||||
if_chain! {
|
||||
if let hir::ItemKind::Impl(.., ref impl_items) = item.node;
|
||||
if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(impl_def_id);
|
||||
@ -95,7 +95,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
then {
|
||||
// check the body for `begin_panic` or `unwrap`
|
||||
let body = cx.tcx.hir().body(body_id);
|
||||
let impl_item_def_id = cx.tcx.hir().local_def_id_from_hir_id(impl_item.id.hir_id);
|
||||
let impl_item_def_id = cx.tcx.hir().local_def_id(impl_item.id.hir_id);
|
||||
let mut fpu = FindPanicUnwrap {
|
||||
lcx: cx,
|
||||
tables: cx.tcx.typeck_tables_of(impl_item_def_id),
|
||||
|
@ -46,7 +46,7 @@ pub fn new(maximum_size_difference_allowed: u64) -> Self {
|
||||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeEnumVariant {
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &Item) {
|
||||
let did = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
let did = cx.tcx.hir().local_def_id(item.hir_id);
|
||||
if let ItemKind::Enum(ref def, _) = item.node {
|
||||
let ty = cx.tcx.type_of(did);
|
||||
let adt = ty.ty_adt_def().expect("already checked whether this is an enum");
|
||||
|
@ -122,7 +122,7 @@ fn is_named_self(cx: &LateContext<'_, '_>, item: &TraitItemRef, name: &str) -> b
|
||||
item.ident.name.as_str() == name
|
||||
&& if let AssocItemKind::Method { has_self } = item.kind {
|
||||
has_self && {
|
||||
let did = cx.tcx.hir().local_def_id_from_hir_id(item.id.hir_id);
|
||||
let did = cx.tcx.hir().local_def_id(item.id.hir_id);
|
||||
cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
|
||||
}
|
||||
} else {
|
||||
@ -141,7 +141,7 @@ fn fill_trait_set(traitt: DefId, set: &mut FxHashSet<DefId>, cx: &LateContext<'_
|
||||
|
||||
if cx.access_levels.is_exported(visited_trait.hir_id) && trait_items.iter().any(|i| is_named_self(cx, i, "len")) {
|
||||
let mut current_and_super_traits = FxHashSet::default();
|
||||
let visited_trait_def_id = cx.tcx.hir().local_def_id_from_hir_id(visited_trait.hir_id);
|
||||
let visited_trait_def_id = cx.tcx.hir().local_def_id(visited_trait.hir_id);
|
||||
fill_trait_set(visited_trait_def_id, &mut current_and_super_traits, cx);
|
||||
|
||||
let is_empty_method_found = current_and_super_traits
|
||||
@ -173,7 +173,7 @@ fn is_named_self(cx: &LateContext<'_, '_>, item: &ImplItemRef, name: &str) -> bo
|
||||
item.ident.name.as_str() == name
|
||||
&& if let AssocItemKind::Method { has_self } = item.kind {
|
||||
has_self && {
|
||||
let did = cx.tcx.hir().local_def_id_from_hir_id(item.id.hir_id);
|
||||
let did = cx.tcx.hir().local_def_id(item.id.hir_id);
|
||||
cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
|
||||
}
|
||||
} else {
|
||||
@ -193,7 +193,7 @@ fn is_named_self(cx: &LateContext<'_, '_>, item: &ImplItemRef, name: &str) -> bo
|
||||
|
||||
if let Some(i) = impl_items.iter().find(|i| is_named_self(cx, i, "len")) {
|
||||
if cx.access_levels.is_exported(i.id.hir_id) {
|
||||
let def_id = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
let def_id = cx.tcx.hir().local_def_id(item.hir_id);
|
||||
let ty = cx.tcx.type_of(def_id);
|
||||
|
||||
span_lint(
|
||||
|
@ -1102,7 +1102,7 @@ fn check_for_loop_range<'a, 'tcx>(
|
||||
// ensure that the indexed variable was declared before the loop, see #601
|
||||
if let Some(indexed_extent) = indexed_extent {
|
||||
let parent_id = cx.tcx.hir().get_parent_item(expr.hir_id);
|
||||
let parent_def_id = cx.tcx.hir().local_def_id_from_hir_id(parent_id);
|
||||
let parent_def_id = cx.tcx.hir().local_def_id(parent_id);
|
||||
let region_scope_tree = cx.tcx.region_scope_tree(parent_def_id);
|
||||
let pat_extent = region_scope_tree.var_scope(pat.hir_id.local_id);
|
||||
if region_scope_tree.is_subscope_of(indexed_extent, pat_extent) {
|
||||
@ -1792,7 +1792,7 @@ fn check(&mut self, idx: &'tcx Expr, seqexpr: &'tcx Expr, expr: &'tcx Expr) -> b
|
||||
match res {
|
||||
Res::Local(hir_id) => {
|
||||
let parent_id = self.cx.tcx.hir().get_parent_item(expr.hir_id);
|
||||
let parent_def_id = self.cx.tcx.hir().local_def_id_from_hir_id(parent_id);
|
||||
let parent_def_id = self.cx.tcx.hir().local_def_id(parent_id);
|
||||
let extent = self.cx.tcx.region_scope_tree(parent_def_id).var_scope(hir_id.local_id);
|
||||
if indexed_indirectly {
|
||||
self.indexed_indirectly.insert(seqvar.segments[0].ident.name, Some(extent));
|
||||
|
@ -948,7 +948,7 @@ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, implitem: &'tcx hir::I
|
||||
let name = implitem.ident.name.as_str();
|
||||
let parent = cx.tcx.hir().get_parent_item(implitem.hir_id);
|
||||
let item = cx.tcx.hir().expect_item(parent);
|
||||
let def_id = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
let def_id = cx.tcx.hir().local_def_id(item.hir_id);
|
||||
let ty = cx.tcx.type_of(def_id);
|
||||
if_chain! {
|
||||
if let hir::ImplItemKind::Method(ref sig, id) = implitem.node;
|
||||
|
@ -69,7 +69,7 @@ fn check_fn(
|
||||
span: Span,
|
||||
hir_id: HirId,
|
||||
) {
|
||||
let def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id);
|
||||
let def_id = cx.tcx.hir().local_def_id(hir_id);
|
||||
|
||||
if in_external_macro(cx.tcx.sess, span) || is_entrypoint_fn(cx, def_id) {
|
||||
return;
|
||||
|
@ -133,7 +133,7 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
|
||||
hir::ItemKind::Fn(..) => {
|
||||
// ignore main()
|
||||
if it.ident.name == sym!(main) {
|
||||
let def_id = cx.tcx.hir().local_def_id_from_hir_id(it.hir_id);
|
||||
let def_id = cx.tcx.hir().local_def_id(it.hir_id);
|
||||
let def_key = cx.tcx.hir().def_key(def_id);
|
||||
if def_key.parent == Some(hir::def_id::CRATE_DEF_INDEX) {
|
||||
return;
|
||||
@ -171,7 +171,7 @@ fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, trait_item: &'tcx hir
|
||||
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx hir::ImplItem) {
|
||||
// If the method is an impl for a trait, don't doc.
|
||||
let def_id = cx.tcx.hir().local_def_id_from_hir_id(impl_item.hir_id);
|
||||
let def_id = cx.tcx.hir().local_def_id(impl_item.hir_id);
|
||||
match cx.tcx.associated_item(def_id).container {
|
||||
ty::TraitContainer(_) => return,
|
||||
ty::ImplContainer(cid) => {
|
||||
|
@ -145,7 +145,7 @@ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx hir::
|
||||
hir::ImplItemKind::Const(..) | hir::ImplItemKind::Type(_) | hir::ImplItemKind::Existential(_) => return,
|
||||
};
|
||||
|
||||
let def_id = cx.tcx.hir().local_def_id_from_hir_id(impl_item.hir_id);
|
||||
let def_id = cx.tcx.hir().local_def_id(impl_item.hir_id);
|
||||
let trait_def_id = match cx.tcx.associated_item(def_id).container {
|
||||
TraitContainer(cid) => Some(cid),
|
||||
ImplContainer(cid) => cx.tcx.impl_trait_ref(cid).map(|t| t.def_id),
|
||||
|
@ -107,7 +107,7 @@ fn check_fn(
|
||||
|
||||
let sized_trait = need!(cx.tcx.lang_items().sized_trait());
|
||||
|
||||
let fn_def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id);
|
||||
let fn_def_id = cx.tcx.hir().local_def_id(hir_id);
|
||||
|
||||
let preds = traits::elaborate_predicates(cx.tcx, cx.param_env.caller_bounds.to_vec())
|
||||
.filter(|p| !p.is_global())
|
||||
|
@ -121,7 +121,7 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
|
||||
return;
|
||||
}
|
||||
if sig.decl.inputs.is_empty() && name == sym!(new) && cx.access_levels.is_reachable(id) {
|
||||
let self_did = cx.tcx.hir().local_def_id_from_hir_id(cx.tcx.hir().get_parent_item(id));
|
||||
let self_did = cx.tcx.hir().local_def_id(cx.tcx.hir().get_parent_item(id));
|
||||
let self_ty = cx.tcx.type_of(self_did);
|
||||
if_chain! {
|
||||
if same_tys(cx, self_ty, return_ty(cx, id));
|
||||
|
@ -142,7 +142,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: HirId, opt_body_id: Option<BodyId>) {
|
||||
let fn_def_id = cx.tcx.hir().local_def_id_from_hir_id(fn_id);
|
||||
let fn_def_id = cx.tcx.hir().local_def_id(fn_id);
|
||||
let sig = cx.tcx.fn_sig(fn_def_id);
|
||||
let fn_ty = sig.skip_binder();
|
||||
|
||||
|
@ -73,7 +73,7 @@ pub fn new(limit: Option<u64>, target: &SessionConfig) -> Self {
|
||||
}
|
||||
|
||||
fn check_poly_fn(&mut self, cx: &LateContext<'_, 'tcx>, hir_id: HirId, decl: &FnDecl, span: Option<Span>) {
|
||||
let fn_def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id);
|
||||
let fn_def_id = cx.tcx.hir().local_def_id(hir_id);
|
||||
|
||||
let fn_sig = cx.tcx.fn_sig(fn_def_id);
|
||||
let fn_sig = cx.tcx.erase_late_bound_regions(&fn_sig);
|
||||
|
@ -129,7 +129,7 @@ fn check_trait_method_impl_decl<'a, 'tcx>(
|
||||
let trait_method_sig = cx.tcx.fn_sig(trait_method.def_id);
|
||||
let trait_method_sig = cx.tcx.erase_late_bound_regions(&trait_method_sig);
|
||||
|
||||
let impl_method_def_id = cx.tcx.hir().local_def_id_from_hir_id(impl_item.hir_id);
|
||||
let impl_method_def_id = cx.tcx.hir().local_def_id(impl_item.hir_id);
|
||||
let impl_method_sig = cx.tcx.fn_sig(impl_method_def_id);
|
||||
let impl_method_sig = cx.tcx.erase_late_bound_regions(&impl_method_sig);
|
||||
|
||||
@ -184,7 +184,7 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
item_path,
|
||||
cx,
|
||||
};
|
||||
let impl_def_id = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
let impl_def_id = cx.tcx.hir().local_def_id(item.hir_id);
|
||||
let impl_trait_ref = cx.tcx.impl_trait_ref(impl_def_id);
|
||||
|
||||
if let Some(impl_trait_ref) = impl_trait_ref {
|
||||
|
@ -329,7 +329,7 @@ fn print_expr(cx: &LateContext<'_, '_>, expr: &hir::Expr, indent: usize) {
|
||||
}
|
||||
|
||||
fn print_item(cx: &LateContext<'_, '_>, item: &hir::Item) {
|
||||
let did = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
let did = cx.tcx.hir().local_def_id(item.hir_id);
|
||||
println!("item `{}`", item.ident.name);
|
||||
match item.vis.node {
|
||||
hir::VisibilityKind::Public => println!("public"),
|
||||
@ -342,7 +342,7 @@ fn print_item(cx: &LateContext<'_, '_>, item: &hir::Item) {
|
||||
}
|
||||
match item.node {
|
||||
hir::ItemKind::ExternCrate(ref _renamed_from) => {
|
||||
let def_id = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
let def_id = cx.tcx.hir().local_def_id(item.hir_id);
|
||||
if let Some(crate_id) = cx.tcx.extern_mod_stmt_cnum(def_id) {
|
||||
let source = cx.tcx.used_crate_source(crate_id);
|
||||
if let Some(ref src) = source.dylib {
|
||||
|
@ -716,7 +716,7 @@ pub fn is_direct_expn_of(span: Span, name: &str) -> Option<Span> {
|
||||
|
||||
/// Convenience function to get the return type of a function.
|
||||
pub fn return_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, fn_item: hir::HirId) -> Ty<'tcx> {
|
||||
let fn_def_id = cx.tcx.hir().local_def_id_from_hir_id(fn_item);
|
||||
let fn_def_id = cx.tcx.hir().local_def_id(fn_item);
|
||||
let ret_ty = cx.tcx.fn_sig(fn_def_id).output();
|
||||
cx.tcx.erase_late_bound_regions(&ret_ty)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user