rustc_middle: Remove trait DefIdTree

This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
This commit is contained in:
Vadim Petrochenkov 2023-02-22 19:51:17 +04:00
parent 7e966bcd03
commit c83553da31
90 changed files with 118 additions and 154 deletions

View File

@ -13,7 +13,7 @@ use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID}; use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
use rustc_hir::PredicateOrigin; use rustc_hir::PredicateOrigin;
use rustc_index::vec::{Idx, IndexVec}; use rustc_index::vec::{Idx, IndexVec};
use rustc_middle::ty::{DefIdTree, ResolverAstLowering, TyCtxt}; use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
use rustc_span::edit_distance::find_best_match_for_name; use rustc_span::edit_distance::find_best_match_for_name;
use rustc_span::source_map::DesugaringKind; use rustc_span::source_map::DesugaringKind;
use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::symbol::{kw, sym, Ident};

View File

@ -13,7 +13,7 @@ use rustc_middle::mir::{
Place, PlaceRef, ProjectionElem, Rvalue, Statement, StatementKind, Terminator, TerminatorKind, Place, PlaceRef, ProjectionElem, Rvalue, Statement, StatementKind, Terminator, TerminatorKind,
}; };
use rustc_middle::ty::print::Print; use rustc_middle::ty::print::Print;
use rustc_middle::ty::{self, DefIdTree, Instance, Ty, TyCtxt}; use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
use rustc_mir_dataflow::move_paths::{InitLocation, LookupResult}; use rustc_mir_dataflow::move_paths::{InitLocation, LookupResult};
use rustc_span::def_id::LocalDefId; use rustc_span::def_id::LocalDefId;
use rustc_span::{symbol::sym, Span, Symbol, DUMMY_SP}; use rustc_span::{symbol::sym, Span, Symbol, DUMMY_SP};

View File

@ -6,7 +6,7 @@ use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res}; use rustc_hir::def::{DefKind, Res};
use rustc_middle::ty::print::RegionHighlightMode; use rustc_middle::ty::print::RegionHighlightMode;
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef}; use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
use rustc_middle::ty::{self, DefIdTree, RegionVid, Ty}; use rustc_middle::ty::{self, RegionVid, Ty};
use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{Span, DUMMY_SP}; use rustc_span::{Span, DUMMY_SP};

View File

@ -22,9 +22,7 @@ use rustc_hir::BodyOwnerKind;
use rustc_index::vec::{Idx, IndexVec}; use rustc_index::vec::{Idx, IndexVec};
use rustc_infer::infer::NllRegionVariableOrigin; use rustc_infer::infer::NllRegionVariableOrigin;
use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::{ use rustc_middle::ty::{self, InlineConstSubsts, InlineConstSubstsParts, RegionVid, Ty, TyCtxt};
self, DefIdTree, InlineConstSubsts, InlineConstSubstsParts, RegionVid, Ty, TyCtxt,
};
use rustc_middle::ty::{InternalSubsts, SubstsRef}; use rustc_middle::ty::{InternalSubsts, SubstsRef};
use rustc_span::Symbol; use rustc_span::Symbol;
use std::iter; use std::iter;

View File

@ -5,7 +5,7 @@ use super::CodegenUnitDebugContext;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_middle::ty::layout::{HasParamEnv, LayoutOf}; use rustc_middle::ty::layout::{HasParamEnv, LayoutOf};
use rustc_middle::ty::{self, DefIdTree, Ty}; use rustc_middle::ty::{self, Ty};
use trace; use trace;
use crate::common::CodegenCx; use crate::common::CodegenCx;

View File

@ -11,7 +11,7 @@ use rustc_middle::middle::exported_symbols::{
use rustc_middle::ty::query::{ExternProviders, Providers}; use rustc_middle::ty::query::{ExternProviders, Providers};
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef}; use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
use rustc_middle::ty::Instance; use rustc_middle::ty::Instance;
use rustc_middle::ty::{self, DefIdTree, SymbolName, TyCtxt}; use rustc_middle::ty::{self, SymbolName, TyCtxt};
use rustc_session::config::{CrateType, OomStrategy}; use rustc_session::config::{CrateType, OomStrategy};
use rustc_target::spec::SanitizerSet; use rustc_target::spec::SanitizerSet;

View File

@ -8,7 +8,7 @@ use rustc_hir::{lang_items, weak_lang_items::WEAK_LANG_ITEMS, LangItem};
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}; use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
use rustc_middle::mir::mono::Linkage; use rustc_middle::mir::mono::Linkage;
use rustc_middle::ty::query::Providers; use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{self as ty, DefIdTree, TyCtxt}; use rustc_middle::ty::{self as ty, TyCtxt};
use rustc_session::{lint, parse::feature_err}; use rustc_session::{lint, parse::feature_err};
use rustc_span::{sym, Span}; use rustc_span::{sym, Span};
use rustc_target::spec::{abi, SanitizerSet}; use rustc_target::spec::{abi, SanitizerSet};

View File

@ -8,7 +8,7 @@ use rustc_hir::def_id::DefId;
use rustc_hir::def_id::LocalDefId; use rustc_hir::def_id::LocalDefId;
use rustc_hir::def_id::LOCAL_CRATE; use rustc_hir::def_id::LOCAL_CRATE;
use rustc_middle::ty::query::Providers; use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{DefIdTree, TyCtxt}; use rustc_middle::ty::TyCtxt;
use rustc_session::parse::feature_err; use rustc_session::parse::feature_err;
use rustc_session::Session; use rustc_session::Session;
use rustc_span::symbol::sym; use rustc_span::symbol::sym;

View File

@ -2,7 +2,7 @@ use rustc_hir as hir;
use rustc_hir::def::DefKind; use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::ty::query::Providers; use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{DefIdTree, TyCtxt}; use rustc_middle::ty::TyCtxt;
use rustc_span::symbol::Symbol; use rustc_span::symbol::Symbol;
/// Whether the `def_id` is an unstable const fn and what feature gate is necessary to enable it /// Whether the `def_id` is an unstable const fn and what feature gate is necessary to enable it

View File

@ -12,9 +12,7 @@ use rustc_infer::traits::{ImplSource, Obligation, ObligationCause};
use rustc_middle::mir; use rustc_middle::mir;
use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef}; use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
use rustc_middle::ty::{ use rustc_middle::ty::{suggest_constraining_type_param, Adt, Closure, FnDef, FnPtr, Param, Ty};
suggest_constraining_type_param, Adt, Closure, DefIdTree, FnDef, FnPtr, Param, Ty,
};
use rustc_middle::ty::{Binder, TraitRef}; use rustc_middle::ty::{Binder, TraitRef};
use rustc_session::parse::feature_err; use rustc_session::parse::feature_err;
use rustc_span::symbol::sym; use rustc_span::symbol::sym;

View File

@ -35,7 +35,7 @@ use rustc_middle::middle::stability::AllowUnstable;
use rustc_middle::ty::subst::{self, GenericArgKind, InternalSubsts, SubstsRef}; use rustc_middle::ty::subst::{self, GenericArgKind, InternalSubsts, SubstsRef};
use rustc_middle::ty::DynKind; use rustc_middle::ty::DynKind;
use rustc_middle::ty::GenericParamDefKind; use rustc_middle::ty::GenericParamDefKind;
use rustc_middle::ty::{self, Const, DefIdTree, IsSuggestable, Ty, TyCtxt, TypeVisitableExt}; use rustc_middle::ty::{self, Const, IsSuggestable, Ty, TyCtxt, TypeVisitableExt};
use rustc_session::lint::builtin::{AMBIGUOUS_ASSOCIATED_ITEMS, BARE_TRAIT_OBJECTS}; use rustc_session::lint::builtin::{AMBIGUOUS_ASSOCIATED_ITEMS, BARE_TRAIT_OBJECTS};
use rustc_span::edit_distance::find_best_match_for_name; use rustc_span::edit_distance::find_best_match_for_name;
use rustc_span::edition::Edition; use rustc_span::edition::Edition;

View File

@ -22,8 +22,7 @@ use rustc_middle::ty::layout::{LayoutError, MAX_SIMD_LANES};
use rustc_middle::ty::subst::GenericArgKind; use rustc_middle::ty::subst::GenericArgKind;
use rustc_middle::ty::util::{Discr, IntTypeExt}; use rustc_middle::ty::util::{Discr, IntTypeExt};
use rustc_middle::ty::{ use rustc_middle::ty::{
self, AdtDef, DefIdTree, ParamEnv, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, self, AdtDef, ParamEnv, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
TypeVisitableExt,
}; };
use rustc_session::lint::builtin::{UNINHABITED_STATIC, UNSUPPORTED_CALLING_CONVENTIONS}; use rustc_session::lint::builtin::{UNINHABITED_STATIC, UNSUPPORTED_CALLING_CONVENTIONS};
use rustc_span::symbol::sym; use rustc_span::symbol::sym;

View File

@ -16,8 +16,7 @@ use rustc_infer::traits::util;
use rustc_middle::ty::error::{ExpectedFound, TypeError}; use rustc_middle::ty::error::{ExpectedFound, TypeError};
use rustc_middle::ty::util::ExplicitSelf; use rustc_middle::ty::util::ExplicitSelf;
use rustc_middle::ty::{ use rustc_middle::ty::{
self, DefIdTree, InternalSubsts, Ty, TypeFoldable, TypeFolder, TypeSuperFoldable, self, InternalSubsts, Ty, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt,
TypeVisitableExt,
}; };
use rustc_middle::ty::{GenericParamDefKind, ToPredicate, TyCtxt}; use rustc_middle::ty::{GenericParamDefKind, ToPredicate, TyCtxt};
use rustc_span::Span; use rustc_span::Span;

View File

@ -3,7 +3,7 @@ use crate::astconv::AstConv;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_infer::traits::util; use rustc_infer::traits::util;
use rustc_middle::ty::subst::InternalSubsts; use rustc_middle::ty::subst::InternalSubsts;
use rustc_middle::ty::{self, DefIdTree, TyCtxt}; use rustc_middle::ty::{self, TyCtxt};
use rustc_span::def_id::DefId; use rustc_span::def_id::DefId;
use rustc_span::Span; use rustc_span::Span;

View File

@ -17,7 +17,7 @@ use rustc_hir::{GenericArg, GenericParam, GenericParamKind, HirIdMap, LifetimeNa
use rustc_middle::bug; use rustc_middle::bug;
use rustc_middle::hir::nested_filter; use rustc_middle::hir::nested_filter;
use rustc_middle::middle::resolve_bound_vars::*; use rustc_middle::middle::resolve_bound_vars::*;
use rustc_middle::ty::{self, DefIdTree, TyCtxt, TypeSuperVisitable, TypeVisitor}; use rustc_middle::ty::{self, TyCtxt, TypeSuperVisitable, TypeVisitor};
use rustc_session::lint; use rustc_session::lint;
use rustc_span::def_id::DefId; use rustc_span::def_id::DefId;
use rustc_span::symbol::{sym, Ident}; use rustc_span::symbol::{sym, Ident};

View File

@ -9,7 +9,7 @@ use rustc_middle::ty::print::with_forced_trimmed_paths;
use rustc_middle::ty::subst::InternalSubsts; use rustc_middle::ty::subst::InternalSubsts;
use rustc_middle::ty::util::IntTypeExt; use rustc_middle::ty::util::IntTypeExt;
use rustc_middle::ty::{ use rustc_middle::ty::{
self, DefIdTree, IsSuggestable, Ty, TyCtxt, TypeFolder, TypeSuperFoldable, TypeVisitableExt, self, IsSuggestable, Ty, TyCtxt, TypeFolder, TypeSuperFoldable, TypeVisitableExt,
}; };
use rustc_span::symbol::Ident; use rustc_span::symbol::Ident;
use rustc_span::{Span, DUMMY_SP}; use rustc_span::{Span, DUMMY_SP};

View File

@ -1,7 +1,7 @@
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_hir::def::DefKind; use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_middle::ty::{self, DefIdTree, Ty, TyCtxt}; use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_middle::ty::{GenericArg, GenericArgKind}; use rustc_middle::ty::{GenericArg, GenericArgKind};
use rustc_span::Span; use rustc_span::Span;

View File

@ -8,7 +8,7 @@ use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::ty::query::Providers; use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{self, CrateVariancesMap, SubstsRef, Ty, TyCtxt}; use rustc_middle::ty::{self, CrateVariancesMap, SubstsRef, Ty, TyCtxt};
use rustc_middle::ty::{DefIdTree, TypeSuperVisitable, TypeVisitable}; use rustc_middle::ty::{TypeSuperVisitable, TypeVisitable};
use std::ops::ControlFlow; use std::ops::ControlFlow;
/// Defines the `TermsContext` basically houses an arena where we can /// Defines the `TermsContext` basically houses an arena where we can

View File

@ -25,7 +25,7 @@ use rustc_middle::ty::error::TypeError;
use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt}; use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt};
use rustc_middle::ty::{ use rustc_middle::ty::{
self, AdtKind, CanonicalUserType, DefIdTree, GenericParamDefKind, Ty, TyCtxt, UserType, self, AdtKind, CanonicalUserType, GenericParamDefKind, Ty, TyCtxt, UserType,
}; };
use rustc_middle::ty::{GenericArgKind, SubstsRef, UserSelfTy, UserSubsts}; use rustc_middle::ty::{GenericArgKind, SubstsRef, UserSelfTy, UserSubsts};
use rustc_session::lint; use rustc_session::lint;

View File

@ -3,9 +3,7 @@ use rustc_hir as hir;
use rustc_hir::def::Res; use rustc_hir::def::Res;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_infer::traits::ObligationCauseCode; use rustc_infer::traits::ObligationCauseCode;
use rustc_middle::ty::{ use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor};
self, DefIdTree, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor,
};
use rustc_span::{self, Span}; use rustc_span::{self, Span};
use rustc_trait_selection::traits; use rustc_trait_selection::traits;

View File

@ -28,7 +28,7 @@ use rustc_infer::infer::InferOk;
use rustc_infer::infer::TypeTrace; use rustc_infer::infer::TypeTrace;
use rustc_middle::ty::adjustment::AllowTwoPhase; use rustc_middle::ty::adjustment::AllowTwoPhase;
use rustc_middle::ty::visit::TypeVisitableExt; use rustc_middle::ty::visit::TypeVisitableExt;
use rustc_middle::ty::{self, DefIdTree, IsSuggestable, Ty}; use rustc_middle::ty::{self, IsSuggestable, Ty};
use rustc_session::Session; use rustc_session::Session;
use rustc_span::symbol::{kw, Ident}; use rustc_span::symbol::{kw, Ident};
use rustc_span::{self, sym, Span}; use rustc_span::{self, sym, Span};

View File

@ -16,7 +16,7 @@ use rustc_infer::traits::{self, StatementAsExpression};
use rustc_middle::lint::in_external_macro; use rustc_middle::lint::in_external_macro;
use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{ use rustc_middle::ty::{
self, suggest_constraining_type_params, Binder, DefIdTree, IsSuggestable, ToPredicate, Ty, self, suggest_constraining_type_params, Binder, IsSuggestable, ToPredicate, Ty,
TypeVisitableExt, TypeVisitableExt,
}; };
use rustc_session::errors::ExprParenthesesNeeded; use rustc_session::errors::ExprParenthesesNeeded;

View File

@ -27,7 +27,7 @@ use rustc_middle::traits::util::supertraits;
use rustc_middle::ty::fast_reject::DeepRejectCtxt; use rustc_middle::ty::fast_reject::DeepRejectCtxt;
use rustc_middle::ty::fast_reject::{simplify_type, TreatParams}; use rustc_middle::ty::fast_reject::{simplify_type, TreatParams};
use rustc_middle::ty::print::{with_crate_prefix, with_forced_trimmed_paths}; use rustc_middle::ty::print::{with_crate_prefix, with_forced_trimmed_paths};
use rustc_middle::ty::{self, DefIdTree, GenericArgKind, Ty, TyCtxt, TypeVisitableExt}; use rustc_middle::ty::{self, GenericArgKind, Ty, TyCtxt, TypeVisitableExt};
use rustc_middle::ty::{IsSuggestable, ToPolyTraitRef}; use rustc_middle::ty::{IsSuggestable, ToPolyTraitRef};
use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::Symbol; use rustc_span::Symbol;

View File

@ -13,7 +13,7 @@ use rustc_middle::ty::adjustment::{
}; };
use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{ use rustc_middle::ty::{
self, DefIdTree, IsSuggestable, Ty, TyCtxt, TypeFolder, TypeSuperFoldable, TypeVisitableExt, self, IsSuggestable, Ty, TyCtxt, TypeFolder, TypeSuperFoldable, TypeVisitableExt,
}; };
use rustc_session::errors::ExprParenthesesNeeded; use rustc_session::errors::ExprParenthesesNeeded;
use rustc_span::source_map::Spanned; use rustc_span::source_map::Spanned;

View File

@ -17,7 +17,7 @@ use rustc_middle::hir::nested_filter;
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind}; use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind};
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow}; use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow};
use rustc_middle::ty::print::{FmtPrinter, PrettyPrinter, Print, Printer}; use rustc_middle::ty::print::{FmtPrinter, PrettyPrinter, Print, Printer};
use rustc_middle::ty::{self, DefIdTree, InferConst}; use rustc_middle::ty::{self, InferConst};
use rustc_middle::ty::{GenericArg, GenericArgKind, SubstsRef}; use rustc_middle::ty::{GenericArg, GenericArgKind, SubstsRef};
use rustc_middle::ty::{IsSuggestable, Ty, TyCtxt, TypeckResults}; use rustc_middle::ty::{IsSuggestable, Ty, TyCtxt, TypeckResults};
use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::symbol::{kw, sym, Ident};

View File

@ -5,7 +5,7 @@ use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use crate::infer::TyCtxt; use crate::infer::TyCtxt;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::LocalDefId; use rustc_hir::def_id::LocalDefId;
use rustc_middle::ty::{self, Binder, DefIdTree, Region, Ty, TypeVisitable}; use rustc_middle::ty::{self, Binder, Region, Ty, TypeVisitable};
use rustc_span::Span; use rustc_span::Span;
/// Information about the anonymous region we are searching for. /// Information about the anonymous region we are searching for.

View File

@ -17,7 +17,7 @@ use rustc_hir::{is_range_literal, Expr, ExprKind, Node};
use rustc_middle::ty::layout::{IntegerExt, LayoutOf, SizeSkeleton}; use rustc_middle::ty::layout::{IntegerExt, LayoutOf, SizeSkeleton};
use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::subst::SubstsRef;
use rustc_middle::ty::{ use rustc_middle::ty::{
self, AdtKind, DefIdTree, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, self, AdtKind, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
}; };
use rustc_span::def_id::LocalDefId; use rustc_span::def_id::LocalDefId;
use rustc_span::source_map; use rustc_span::source_map;

View File

@ -14,7 +14,7 @@ use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_infer::traits::util::elaborate_predicates_with_span; use rustc_infer::traits::util::elaborate_predicates_with_span;
use rustc_middle::ty::adjustment; use rustc_middle::ty::adjustment;
use rustc_middle::ty::{self, DefIdTree, Ty}; use rustc_middle::ty::{self, Ty};
use rustc_span::symbol::Symbol; use rustc_span::symbol::Symbol;
use rustc_span::symbol::{kw, sym}; use rustc_span::symbol::{kw, sym};
use rustc_span::{BytePos, Span}; use rustc_span::{BytePos, Span};

View File

@ -1,5 +1,5 @@
use crate::hir::{ModuleItems, Owner}; use crate::hir::{ModuleItems, Owner};
use crate::ty::{DefIdTree, TyCtxt}; use crate::ty::TyCtxt;
use rustc_ast as ast; use rustc_ast as ast;
use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};

View File

@ -7,7 +7,7 @@ pub mod nested_filter;
pub mod place; pub mod place;
use crate::ty::query::Providers; use crate::ty::query::Providers;
use crate::ty::{DefIdTree, ImplSubject, TyCtxt}; use crate::ty::{ImplSubject, TyCtxt};
use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::{par_for_each_in, Send, Sync}; use rustc_data_structures::sync::{par_for_each_in, Send, Sync};

View File

@ -1,7 +1,7 @@
//! A pass that checks to make sure private fields and methods aren't used //! A pass that checks to make sure private fields and methods aren't used
//! outside their scopes. This pass will also generate a set of exported items //! outside their scopes. This pass will also generate a set of exported items
//! which are available for use externally when compiled as a library. //! which are available for use externally when compiled as a library.
use crate::ty::{DefIdTree, TyCtxt, Visibility}; use crate::ty::{TyCtxt, Visibility};
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_macros::HashStable; use rustc_macros::HashStable;
@ -112,7 +112,7 @@ impl EffectiveVisibilities {
&mut self, &mut self,
def_id: LocalDefId, def_id: LocalDefId,
eff_vis: &EffectiveVisibility, eff_vis: &EffectiveVisibility,
tree: impl DefIdTree, tcx: TyCtxt<'_>,
) { ) {
use std::collections::hash_map::Entry; use std::collections::hash_map::Entry;
match self.map.entry(def_id) { match self.map.entry(def_id) {
@ -122,7 +122,7 @@ impl EffectiveVisibilities {
let vis_at_level = eff_vis.at_level(l); let vis_at_level = eff_vis.at_level(l);
let old_vis_at_level = old_eff_vis.at_level_mut(l); let old_vis_at_level = old_eff_vis.at_level_mut(l);
if vis_at_level != old_vis_at_level if vis_at_level != old_vis_at_level
&& vis_at_level.is_at_least(*old_vis_at_level, tree) && vis_at_level.is_at_least(*old_vis_at_level, tcx)
{ {
*old_vis_at_level = *vis_at_level *old_vis_at_level = *vis_at_level
} }
@ -219,7 +219,7 @@ impl<Id: Eq + Hash> EffectiveVisibilities<Id> {
lazy_private_vis: impl FnOnce() -> Visibility, lazy_private_vis: impl FnOnce() -> Visibility,
inherited_effective_vis: EffectiveVisibility, inherited_effective_vis: EffectiveVisibility,
level: Level, level: Level,
tree: impl DefIdTree, tcx: TyCtxt<'_>,
) -> bool { ) -> bool {
let mut changed = false; let mut changed = false;
let mut current_effective_vis = self let mut current_effective_vis = self
@ -240,7 +240,7 @@ impl<Id: Eq + Hash> EffectiveVisibilities<Id> {
&& level != l) && level != l)
{ {
calculated_effective_vis = calculated_effective_vis =
if nominal_vis.is_at_least(inherited_effective_vis_at_level, tree) { if nominal_vis.is_at_least(inherited_effective_vis_at_level, tcx) {
inherited_effective_vis_at_level inherited_effective_vis_at_level
} else { } else {
nominal_vis nominal_vis
@ -249,7 +249,7 @@ impl<Id: Eq + Hash> EffectiveVisibilities<Id> {
// effective visibility can't be decreased at next update call for the // effective visibility can't be decreased at next update call for the
// same id // same id
if *current_effective_vis_at_level != calculated_effective_vis if *current_effective_vis_at_level != calculated_effective_vis
&& calculated_effective_vis.is_at_least(*current_effective_vis_at_level, tree) && calculated_effective_vis.is_at_least(*current_effective_vis_at_level, tcx)
{ {
changed = true; changed = true;
*current_effective_vis_at_level = calculated_effective_vis; *current_effective_vis_at_level = calculated_effective_vis;

View File

@ -3,7 +3,7 @@
pub use self::StabilityLevel::*; pub use self::StabilityLevel::*;
use crate::ty::{self, DefIdTree, TyCtxt}; use crate::ty::{self, TyCtxt};
use rustc_ast::NodeId; use rustc_ast::NodeId;
use rustc_attr::{self as attr, ConstStability, DefaultBodyStability, Deprecation, Stability}; use rustc_attr::{self as attr, ConstStability, DefaultBodyStability, Deprecation, Stability};
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;

View File

@ -10,7 +10,7 @@ use crate::ty::codec::{TyDecoder, TyEncoder};
use crate::ty::fold::{FallibleTypeFolder, TypeFoldable}; use crate::ty::fold::{FallibleTypeFolder, TypeFoldable};
use crate::ty::print::{FmtPrinter, Printer}; use crate::ty::print::{FmtPrinter, Printer};
use crate::ty::visit::{TypeVisitable, TypeVisitableExt, TypeVisitor}; use crate::ty::visit::{TypeVisitable, TypeVisitableExt, TypeVisitor};
use crate::ty::{self, DefIdTree, List, Ty, TyCtxt}; use crate::ty::{self, List, Ty, TyCtxt};
use crate::ty::{AdtDef, InstanceDef, ScalarInt, UserTypeAnnotationIndex}; use crate::ty::{AdtDef, InstanceDef, ScalarInt, UserTypeAnnotationIndex};
use crate::ty::{GenericArg, InternalSubsts, SubstsRef}; use crate::ty::{GenericArg, InternalSubsts, SubstsRef};

View File

@ -1,6 +1,6 @@
pub use self::AssocItemContainer::*; pub use self::AssocItemContainer::*;
use crate::ty::{self, DefIdTree}; use crate::ty;
use rustc_data_structures::sorted_map::SortedIndexMultiMap; use rustc_data_structures::sorted_map::SortedIndexMultiMap;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{DefKind, Namespace}; use rustc_hir::def::{DefKind, Namespace};

View File

@ -1,6 +1,6 @@
use crate::middle::resolve_bound_vars as rbv; use crate::middle::resolve_bound_vars as rbv;
use crate::mir::interpret::LitToConstInput; use crate::mir::interpret::LitToConstInput;
use crate::ty::{self, DefIdTree, InternalSubsts, ParamEnv, ParamEnvAnd, Ty, TyCtxt}; use crate::ty::{self, InternalSubsts, ParamEnv, ParamEnvAnd, Ty, TyCtxt};
use rustc_data_structures::intern::Interned; use rustc_data_structures::intern::Interned;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res}; use rustc_hir::def::{DefKind, Res};

View File

@ -20,11 +20,10 @@ use crate::traits;
use crate::traits::solve::{ExternalConstraints, ExternalConstraintsData}; use crate::traits::solve::{ExternalConstraints, ExternalConstraintsData};
use crate::ty::query::{self, TyCtxtAt}; use crate::ty::query::{self, TyCtxtAt};
use crate::ty::{ use crate::ty::{
self, AdtDef, AdtDefData, AdtKind, Binder, Const, ConstData, DefIdTree, FloatTy, FloatVar, self, AdtDef, AdtDefData, AdtKind, Binder, Const, ConstData, FloatTy, FloatVar, FloatVid,
FloatVid, GenericParamDefKind, ImplPolarity, InferTy, IntTy, IntVar, IntVid, List, ParamConst, GenericParamDefKind, ImplPolarity, InferTy, IntTy, IntVar, IntVid, List, ParamConst, ParamTy,
ParamTy, PolyExistentialPredicate, PolyFnSig, Predicate, PredicateKind, Region, RegionKind, PolyExistentialPredicate, PolyFnSig, Predicate, PredicateKind, Region, RegionKind, ReprOptions,
ReprOptions, TraitObjectVisitor, Ty, TyKind, TyVar, TyVid, TypeAndMut, TypeckResults, UintTy, TraitObjectVisitor, Ty, TyKind, TyVar, TyVid, TypeAndMut, TypeckResults, UintTy, Visibility,
Visibility,
}; };
use crate::ty::{GenericArg, InternalSubsts, SubstsRef}; use crate::ty::{GenericArg, InternalSubsts, SubstsRef};
use rustc_ast as ast; use rustc_ast as ast;

View File

@ -3,9 +3,9 @@
use std::ops::ControlFlow; use std::ops::ControlFlow;
use crate::ty::{ use crate::ty::{
AliasTy, Const, ConstKind, DefIdTree, FallibleTypeFolder, InferConst, InferTy, Opaque, AliasTy, Const, ConstKind, FallibleTypeFolder, InferConst, InferTy, Opaque, PolyTraitPredicate,
PolyTraitPredicate, Projection, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, Projection, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, TypeSuperVisitable, TypeVisitable,
TypeSuperVisitable, TypeVisitable, TypeVisitor, TypeVisitor,
}; };
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;

View File

@ -1,5 +1,5 @@
use crate::ty::context::TyCtxt; use crate::ty::context::TyCtxt;
use crate::ty::{self, DefId, DefIdTree, ParamEnv, Ty}; use crate::ty::{self, DefId, ParamEnv, Ty};
/// Represents whether some type is inhabited in a given context. /// Represents whether some type is inhabited in a given context.
/// Examples of uninhabited types are `!`, `enum Void {}`, or a struct /// Examples of uninhabited types are `!`, `enum Void {}`, or a struct

View File

@ -325,12 +325,15 @@ pub struct ClosureSizeProfileData<'tcx> {
pub after_feature_tys: Ty<'tcx>, pub after_feature_tys: Ty<'tcx>,
} }
pub trait DefIdTree: Copy { impl TyCtxt<'_> {
fn opt_parent(self, id: DefId) -> Option<DefId>; #[inline]
pub fn opt_parent(self, id: DefId) -> Option<DefId> {
self.def_key(id).parent.map(|index| DefId { index, ..id })
}
#[inline] #[inline]
#[track_caller] #[track_caller]
fn parent(self, id: DefId) -> DefId { pub fn parent(self, id: DefId) -> DefId {
match self.opt_parent(id) { match self.opt_parent(id) {
Some(id) => id, Some(id) => id,
// not `unwrap_or_else` to avoid breaking caller tracking // not `unwrap_or_else` to avoid breaking caller tracking
@ -340,17 +343,17 @@ pub trait DefIdTree: Copy {
#[inline] #[inline]
#[track_caller] #[track_caller]
fn opt_local_parent(self, id: LocalDefId) -> Option<LocalDefId> { pub fn opt_local_parent(self, id: LocalDefId) -> Option<LocalDefId> {
self.opt_parent(id.to_def_id()).map(DefId::expect_local) self.opt_parent(id.to_def_id()).map(DefId::expect_local)
} }
#[inline] #[inline]
#[track_caller] #[track_caller]
fn local_parent(self, id: LocalDefId) -> LocalDefId { pub fn local_parent(self, id: LocalDefId) -> LocalDefId {
self.parent(id.to_def_id()).expect_local() self.parent(id.to_def_id()).expect_local()
} }
fn is_descendant_of(self, mut descendant: DefId, ancestor: DefId) -> bool { pub fn is_descendant_of(self, mut descendant: DefId, ancestor: DefId) -> bool {
if descendant.krate != ancestor.krate { if descendant.krate != ancestor.krate {
return false; return false;
} }
@ -365,13 +368,6 @@ pub trait DefIdTree: Copy {
} }
} }
impl<'tcx> DefIdTree for TyCtxt<'tcx> {
#[inline]
fn opt_parent(self, id: DefId) -> Option<DefId> {
self.def_key(id).parent.map(|index| DefId { index, ..id })
}
}
impl<Id> Visibility<Id> { impl<Id> Visibility<Id> {
pub fn is_public(self) -> bool { pub fn is_public(self) -> bool {
matches!(self, Visibility::Public) matches!(self, Visibility::Public)
@ -391,19 +387,19 @@ impl<Id: Into<DefId>> Visibility<Id> {
} }
/// Returns `true` if an item with this visibility is accessible from the given module. /// Returns `true` if an item with this visibility is accessible from the given module.
pub fn is_accessible_from(self, module: impl Into<DefId>, tree: impl DefIdTree) -> bool { pub fn is_accessible_from(self, module: impl Into<DefId>, tcx: TyCtxt<'_>) -> bool {
match self { match self {
// Public items are visible everywhere. // Public items are visible everywhere.
Visibility::Public => true, Visibility::Public => true,
Visibility::Restricted(id) => tree.is_descendant_of(module.into(), id.into()), Visibility::Restricted(id) => tcx.is_descendant_of(module.into(), id.into()),
} }
} }
/// Returns `true` if this visibility is at least as accessible as the given visibility /// Returns `true` if this visibility is at least as accessible as the given visibility
pub fn is_at_least(self, vis: Visibility<impl Into<DefId>>, tree: impl DefIdTree) -> bool { pub fn is_at_least(self, vis: Visibility<impl Into<DefId>>, tcx: TyCtxt<'_>) -> bool {
match vis { match vis {
Visibility::Public => self.is_public(), Visibility::Public => self.is_public(),
Visibility::Restricted(id) => self.is_accessible_from(id, tree), Visibility::Restricted(id) => self.is_accessible_from(id, tcx),
} }
} }
} }

View File

@ -1,5 +1,5 @@
use crate::ty::GenericArg; use crate::ty::GenericArg;
use crate::ty::{self, DefIdTree, Ty, TyCtxt}; use crate::ty::{self, Ty, TyCtxt};
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sso::SsoHashSet; use rustc_data_structures::sso::SsoHashSet;

View File

@ -1,6 +1,6 @@
use crate::mir::interpret::{AllocRange, GlobalAlloc, Pointer, Provenance, Scalar}; use crate::mir::interpret::{AllocRange, GlobalAlloc, Pointer, Provenance, Scalar};
use crate::ty::{ use crate::ty::{
self, ConstInt, DefIdTree, ParamConst, ScalarInt, Term, TermKind, Ty, TyCtxt, TypeFoldable, self, ConstInt, ParamConst, ScalarInt, Term, TermKind, Ty, TyCtxt, TypeFoldable,
TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
}; };
use crate::ty::{GenericArg, GenericArgKind}; use crate::ty::{GenericArg, GenericArgKind};

View File

@ -7,7 +7,7 @@ use crate::ty::subst::{GenericArg, InternalSubsts, SubstsRef};
use crate::ty::visit::ValidateBoundVars; use crate::ty::visit::ValidateBoundVars;
use crate::ty::InferTy::*; use crate::ty::InferTy::*;
use crate::ty::{ use crate::ty::{
self, AdtDef, DefIdTree, Discr, FallibleTypeFolder, Term, Ty, TyCtxt, TypeFlags, TypeFoldable, self, AdtDef, Discr, FallibleTypeFolder, Term, Ty, TyCtxt, TypeFlags, TypeFoldable,
TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor,
}; };
use crate::ty::{List, ParamEnv}; use crate::ty::{List, ParamEnv};

View File

@ -4,8 +4,8 @@ use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use crate::mir; use crate::mir;
use crate::ty::layout::IntegerExt; use crate::ty::layout::IntegerExt;
use crate::ty::{ use crate::ty::{
self, DefIdTree, FallibleTypeFolder, ToPredicate, Ty, TyCtxt, TypeFoldable, TypeFolder, self, FallibleTypeFolder, ToPredicate, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable,
TypeSuperFoldable, TypeVisitableExt, TypeVisitableExt,
}; };
use crate::ty::{GenericArgKind, SubstsRef}; use crate::ty::{GenericArgKind, SubstsRef};
use rustc_apfloat::Float as _; use rustc_apfloat::Float as _;

View File

@ -4,7 +4,7 @@ use rustc_errors::{pluralize, struct_span_err, Applicability, MultiSpan};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res}; use rustc_hir::def::{DefKind, Res};
use rustc_middle::ty::Representability; use rustc_middle::ty::Representability;
use rustc_middle::ty::{self, DefIdTree, Ty, TyCtxt}; use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_query_system::query::QueryInfo; use rustc_query_system::query::QueryInfo;
use rustc_query_system::Value; use rustc_query_system::Value;
use rustc_span::def_id::LocalDefId; use rustc_span::def_id::LocalDefId;

View File

@ -25,7 +25,7 @@ use rustc_middle::mir::{BorrowKind, Field, Mutability};
use rustc_middle::thir::{Ascription, BindingMode, FieldPat, LocalVarId, Pat, PatKind, PatRange}; use rustc_middle::thir::{Ascription, BindingMode, FieldPat, LocalVarId, Pat, PatKind, PatRange};
use rustc_middle::ty::subst::{GenericArg, SubstsRef}; use rustc_middle::ty::subst::{GenericArg, SubstsRef};
use rustc_middle::ty::CanonicalUserTypeAnnotation; use rustc_middle::ty::CanonicalUserTypeAnnotation;
use rustc_middle::ty::{self, AdtDef, ConstKind, DefIdTree, Region, Ty, TyCtxt, UserType}; use rustc_middle::ty::{self, AdtDef, ConstKind, Region, Ty, TyCtxt, UserType};
use rustc_span::{Span, Symbol}; use rustc_span::{Span, Symbol};
use std::cmp::Ordering; use std::cmp::Ordering;

View File

@ -9,7 +9,7 @@ use rustc_middle::middle::exported_symbols::{SymbolExportInfo, SymbolExportLevel
use rustc_middle::mir::mono::{CodegenUnit, CodegenUnitNameBuilder, Linkage, Visibility}; use rustc_middle::mir::mono::{CodegenUnit, CodegenUnitNameBuilder, Linkage, Visibility};
use rustc_middle::mir::mono::{InstantiationMode, MonoItem}; use rustc_middle::mir::mono::{InstantiationMode, MonoItem};
use rustc_middle::ty::print::characteristic_def_id_of_type; use rustc_middle::ty::print::characteristic_def_id_of_type;
use rustc_middle::ty::{self, visit::TypeVisitableExt, DefIdTree, InstanceDef, TyCtxt}; use rustc_middle::ty::{self, visit::TypeVisitableExt, InstanceDef, TyCtxt};
use rustc_span::symbol::Symbol; use rustc_span::symbol::Symbol;
use super::PartitioningCx; use super::PartitioningCx;

View File

@ -13,7 +13,7 @@ use rustc_hir::{Node, PatKind, TyKind};
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::middle::privacy::Level; use rustc_middle::middle::privacy::Level;
use rustc_middle::ty::query::Providers; use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{self, DefIdTree, TyCtxt}; use rustc_middle::ty::{self, TyCtxt};
use rustc_session::lint; use rustc_session::lint;
use rustc_span::symbol::{sym, Symbol}; use rustc_span::symbol::{sym, Symbol};
use std::mem; use std::mem;

View File

@ -4,7 +4,7 @@ use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID, LOCAL_CRATE}; use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID, LOCAL_CRATE};
use rustc_hir::{ItemId, Node, CRATE_HIR_ID}; use rustc_hir::{ItemId, Node, CRATE_HIR_ID};
use rustc_middle::ty::query::Providers; use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{DefIdTree, TyCtxt}; use rustc_middle::ty::TyCtxt;
use rustc_session::config::{sigpipe, CrateType, EntryFnType}; use rustc_session::config::{sigpipe, CrateType, EntryFnType};
use rustc_session::parse::feature_err; use rustc_session::parse::feature_err;
use rustc_span::symbol::sym; use rustc_span::symbol::sym;

View File

@ -5,7 +5,7 @@ use rustc_hir::intravisit;
use rustc_hir::{HirId, ItemLocalId}; use rustc_hir::{HirId, ItemLocalId};
use rustc_index::bit_set::GrowableBitSet; use rustc_index::bit_set::GrowableBitSet;
use rustc_middle::hir::nested_filter; use rustc_middle::hir::nested_filter;
use rustc_middle::ty::{DefIdTree, TyCtxt}; use rustc_middle::ty::TyCtxt;
pub fn check_crate(tcx: TyCtxt<'_>) { pub fn check_crate(tcx: TyCtxt<'_>) {
tcx.dep_graph.assert_ignored(); tcx.dep_graph.assert_ignored();

View File

@ -95,7 +95,7 @@ use rustc_hir::intravisit::{self, Visitor};
use rustc_hir::{Expr, HirId, HirIdMap, HirIdSet}; use rustc_hir::{Expr, HirId, HirIdMap, HirIdSet};
use rustc_index::vec::IndexVec; use rustc_index::vec::IndexVec;
use rustc_middle::ty::query::Providers; use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{self, DefIdTree, RootVariableMinCaptureList, Ty, TyCtxt}; use rustc_middle::ty::{self, RootVariableMinCaptureList, Ty, TyCtxt};
use rustc_session::lint; use rustc_session::lint;
use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::{BytePos, Span}; use rustc_span::{BytePos, Span};

View File

@ -14,7 +14,7 @@ use rustc_hir::Node;
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}; use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
use rustc_middle::middle::privacy::{self, Level}; use rustc_middle::middle::privacy::{self, Level};
use rustc_middle::ty::query::Providers; use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{self, DefIdTree, TyCtxt}; use rustc_middle::ty::{self, TyCtxt};
use rustc_session::config::CrateType; use rustc_session::config::CrateType;
use rustc_target::spec::abi::Abi; use rustc_target::spec::abi::Abi;

View File

@ -29,7 +29,7 @@ use rustc_middle::middle::privacy::{EffectiveVisibilities, Level};
use rustc_middle::span_bug; use rustc_middle::span_bug;
use rustc_middle::ty::query::Providers; use rustc_middle::ty::query::Providers;
use rustc_middle::ty::subst::InternalSubsts; use rustc_middle::ty::subst::InternalSubsts;
use rustc_middle::ty::{self, Const, DefIdTree, GenericParamDefKind}; use rustc_middle::ty::{self, Const, GenericParamDefKind};
use rustc_middle::ty::{TraitRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor}; use rustc_middle::ty::{TraitRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor};
use rustc_session::lint; use rustc_session::lint;
use rustc_span::hygiene::Transparency; use rustc_span::hygiene::Transparency;

View File

@ -25,9 +25,8 @@ use rustc_expand::expand::AstFragment;
use rustc_hir::def::{self, *}; use rustc_hir::def::{self, *};
use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID}; use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID};
use rustc_metadata::creader::LoadedMacro; use rustc_metadata::creader::LoadedMacro;
use rustc_middle::bug;
use rustc_middle::metadata::ModChild; use rustc_middle::metadata::ModChild;
use rustc_middle::ty::{self, DefIdTree}; use rustc_middle::{bug, ty};
use rustc_session::cstore::CrateStore; use rustc_session::cstore::CrateStore;
use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind}; use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind};
use rustc_span::source_map::respan; use rustc_span::source_map::respan;
@ -99,7 +98,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
loop { loop {
match self.get_module(def_id) { match self.get_module(def_id) {
Some(module) => return module, Some(module) => return module,
None => def_id = self.parent(def_id), None => def_id = self.tcx.parent(def_id),
} }
} }
} }
@ -775,7 +774,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
let field_vis = self let field_vis = self
.try_resolve_visibility(&field.vis, false) .try_resolve_visibility(&field.vis, false)
.unwrap_or(ty::Visibility::Public); .unwrap_or(ty::Visibility::Public);
if ctor_vis.is_at_least(field_vis, &*self.r) { if ctor_vis.is_at_least(field_vis, self.r.tcx) {
ctor_vis = field_vis; ctor_vis = field_vis;
} }
ret_fields.push(field_vis.to_def_id()); ret_fields.push(field_vis.to_def_id());
@ -1414,10 +1413,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
if !(ctxt == AssocCtxt::Impl if !(ctxt == AssocCtxt::Impl
&& matches!(item.vis.kind, ast::VisibilityKind::Inherited) && matches!(item.vis.kind, ast::VisibilityKind::Inherited)
&& self && self.r.trait_impl_items.contains(&self.r.tcx.local_parent(local_def_id)))
.r
.trait_impl_items
.contains(&ty::DefIdTree::local_parent(&*self.r, local_def_id)))
{ {
// Trait impl item visibility is inherited from its trait when not specified // Trait impl item visibility is inherited from its trait when not specified
// explicitly. In that case we cannot determine it here in early resolve, // explicitly. In that case we cannot determine it here in early resolve,

View File

@ -15,7 +15,7 @@ use rustc_hir::def::{self, CtorKind, CtorOf, DefKind, NonMacroAttrKind, PerNS};
use rustc_hir::def_id::{DefId, CRATE_DEF_ID, LOCAL_CRATE}; use rustc_hir::def_id::{DefId, CRATE_DEF_ID, LOCAL_CRATE};
use rustc_hir::PrimTy; use rustc_hir::PrimTy;
use rustc_middle::bug; use rustc_middle::bug;
use rustc_middle::ty::{DefIdTree, TyCtxt}; use rustc_middle::ty::TyCtxt;
use rustc_session::lint::builtin::ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE; use rustc_session::lint::builtin::ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE;
use rustc_session::lint::builtin::MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS; use rustc_session::lint::builtin::MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS;
use rustc_session::lint::BuiltinLintDiagnostics; use rustc_session::lint::BuiltinLintDiagnostics;
@ -1197,7 +1197,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
segms.push(ast::PathSegment::from_ident(ident)); segms.push(ast::PathSegment::from_ident(ident));
let path = Path { span: name_binding.span, segments: segms, tokens: None }; let path = Path { span: name_binding.span, segments: segms, tokens: None };
let did = match res { let did = match res {
Res::Def(DefKind::Ctor(..), did) => this.opt_parent(did), Res::Def(DefKind::Ctor(..), did) => this.tcx.opt_parent(did),
_ => res.opt_def_id(), _ => res.opt_def_id(),
}; };
@ -1591,7 +1591,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
ctor_def_id, ctor_def_id,
)) = binding.kind )) = binding.kind
{ {
let def_id = self.parent(ctor_def_id); let def_id = self.tcx.parent(ctor_def_id);
let fields = self.field_names.get(&def_id)?; let fields = self.field_names.get(&def_id)?;
return fields.iter().map(|name| name.span).reduce(Span::to); // None for `struct Foo()` return fields.iter().map(|name| name.span).reduce(Span::to); // None for `struct Foo()`
} }

View File

@ -9,7 +9,7 @@ use rustc_hir::def_id::LocalDefId;
use rustc_hir::def_id::CRATE_DEF_ID; use rustc_hir::def_id::CRATE_DEF_ID;
use rustc_middle::middle::privacy::Level; use rustc_middle::middle::privacy::Level;
use rustc_middle::middle::privacy::{EffectiveVisibilities, EffectiveVisibility}; use rustc_middle::middle::privacy::{EffectiveVisibilities, EffectiveVisibility};
use rustc_middle::ty::{DefIdTree, Visibility}; use rustc_middle::ty::Visibility;
use std::mem; use std::mem;
type ImportId<'a> = Interned<'a, NameBinding<'a>>; type ImportId<'a> = Interned<'a, NameBinding<'a>>;
@ -60,7 +60,7 @@ impl Resolver<'_, '_> {
// For mod items `nearest_normal_mod` returns its argument, but we actually need its parent. // For mod items `nearest_normal_mod` returns its argument, but we actually need its parent.
let normal_mod_id = self.nearest_normal_mod(def_id); let normal_mod_id = self.nearest_normal_mod(def_id);
if normal_mod_id == def_id { if normal_mod_id == def_id {
self.opt_local_parent(def_id).map_or(Visibility::Public, Visibility::Restricted) self.tcx.opt_local_parent(def_id).map_or(Visibility::Public, Visibility::Restricted)
} else { } else {
Visibility::Restricted(normal_mod_id) Visibility::Restricted(normal_mod_id)
} }

View File

@ -245,7 +245,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
import: &'a Import<'a>, import: &'a Import<'a>,
) -> &'a NameBinding<'a> { ) -> &'a NameBinding<'a> {
let import_vis = import.expect_vis().to_def_id(); let import_vis = import.expect_vis().to_def_id();
let vis = if binding.vis.is_at_least(import_vis, self) let vis = if binding.vis.is_at_least(import_vis, self.tcx)
|| pub_use_of_private_extern_crate_hack(import, binding) || pub_use_of_private_extern_crate_hack(import, binding)
{ {
import_vis import_vis
@ -255,7 +255,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
if let ImportKind::Glob { ref max_vis, .. } = import.kind { if let ImportKind::Glob { ref max_vis, .. } = import.kind {
if vis == import_vis if vis == import_vis
|| max_vis.get().map_or(true, |max_vis| vis.is_at_least(max_vis, self)) || max_vis.get().map_or(true, |max_vis| vis.is_at_least(max_vis, self.tcx))
{ {
max_vis.set(Some(vis.expect_local())) max_vis.set(Some(vis.expect_local()))
} }
@ -294,7 +294,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
old_binding, old_binding,
binding, binding,
)); ));
} else if !old_binding.vis.is_at_least(binding.vis, &*this) { } else if !old_binding.vis.is_at_least(binding.vis, this.tcx) {
// We are glob-importing the same item but with greater visibility. // We are glob-importing the same item but with greater visibility.
resolution.binding = Some(binding); resolution.binding = Some(binding);
} }
@ -786,7 +786,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
} }
if !is_prelude if !is_prelude
&& let Some(max_vis) = max_vis.get() && let Some(max_vis) = max_vis.get()
&& !max_vis.is_at_least(import.expect_vis(), &*self) && !max_vis.is_at_least(import.expect_vis(), self.tcx)
{ {
let msg = "glob import doesn't reexport anything because no candidate is public enough"; let msg = "glob import doesn't reexport anything because no candidate is public enough";
self.lint_buffer.buffer_lint(UNUSED_IMPORTS, id, import.span, msg); self.lint_buffer.buffer_lint(UNUSED_IMPORTS, id, import.span, msg);
@ -977,7 +977,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
let mut crate_private_reexport = false; let mut crate_private_reexport = false;
self.per_ns(|this, ns| { self.per_ns(|this, ns| {
if let Ok(binding) = source_bindings[ns].get() { if let Ok(binding) = source_bindings[ns].get() {
if !binding.vis.is_at_least(import.expect_vis(), &*this) { if !binding.vis.is_at_least(import.expect_vis(), this.tcx) {
reexport_error = Some((ns, binding)); reexport_error = Some((ns, binding));
if let ty::Visibility::Restricted(binding_def_id) = binding.vis { if let ty::Visibility::Restricted(binding_def_id) = binding.vis {
if binding_def_id.is_top_level_module() { if binding_def_id.is_top_level_module() {

View File

@ -22,7 +22,6 @@ use rustc_hir::def::{self, CtorKind, DefKind, LifetimeRes, PartialRes, PerNS};
use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID, LOCAL_CRATE}; use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID, LOCAL_CRATE};
use rustc_hir::{BindingAnnotation, PrimTy, TraitCandidate}; use rustc_hir::{BindingAnnotation, PrimTy, TraitCandidate};
use rustc_middle::middle::resolve_bound_vars::Set1; use rustc_middle::middle::resolve_bound_vars::Set1;
use rustc_middle::ty::DefIdTree;
use rustc_middle::{bug, span_bug}; use rustc_middle::{bug, span_bug};
use rustc_session::config::{CrateType, ResolveDocLinks}; use rustc_session::config::{CrateType, ResolveDocLinks};
use rustc_session::lint; use rustc_session::lint;
@ -1671,8 +1670,12 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
// Figure out if this is a type/trait segment, // Figure out if this is a type/trait segment,
// which may need lifetime elision performed. // which may need lifetime elision performed.
let type_def_id = match partial_res.base_res() { let type_def_id = match partial_res.base_res() {
Res::Def(DefKind::AssocTy, def_id) if i + 2 == proj_start => self.r.parent(def_id), Res::Def(DefKind::AssocTy, def_id) if i + 2 == proj_start => {
Res::Def(DefKind::Variant, def_id) if i + 1 == proj_start => self.r.parent(def_id), self.r.tcx.parent(def_id)
}
Res::Def(DefKind::Variant, def_id) if i + 1 == proj_start => {
self.r.tcx.parent(def_id)
}
Res::Def(DefKind::Struct, def_id) Res::Def(DefKind::Struct, def_id)
| Res::Def(DefKind::Union, def_id) | Res::Def(DefKind::Union, def_id)
| Res::Def(DefKind::Enum, def_id) | Res::Def(DefKind::Enum, def_id)

View File

@ -21,7 +21,6 @@ use rustc_hir::def::Namespace::{self, *};
use rustc_hir::def::{self, CtorKind, CtorOf, DefKind}; use rustc_hir::def::{self, CtorKind, CtorOf, DefKind};
use rustc_hir::def_id::{DefId, CRATE_DEF_ID, LOCAL_CRATE}; use rustc_hir::def_id::{DefId, CRATE_DEF_ID, LOCAL_CRATE};
use rustc_hir::PrimTy; use rustc_hir::PrimTy;
use rustc_middle::ty::DefIdTree;
use rustc_session::lint; use rustc_session::lint;
use rustc_session::parse::feature_err; use rustc_session::parse::feature_err;
use rustc_session::Session; use rustc_session::Session;
@ -1508,7 +1507,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
} }
} }
(Res::Def(DefKind::Ctor(_, CtorKind::Fn), ctor_def_id), _) if ns == ValueNS => { (Res::Def(DefKind::Ctor(_, CtorKind::Fn), ctor_def_id), _) if ns == ValueNS => {
let def_id = self.r.parent(ctor_def_id); let def_id = self.r.tcx.parent(ctor_def_id);
if let Some(span) = self.def_span(def_id) { if let Some(span) = self.def_span(def_id) {
err.span_label(span, &format!("`{}` defined here", path_str)); err.span_label(span, &format!("`{}` defined here", path_str));
} }
@ -1999,7 +1998,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
} }
} else { } else {
let needs_placeholder = |ctor_def_id: DefId, kind: CtorKind| { let needs_placeholder = |ctor_def_id: DefId, kind: CtorKind| {
let def_id = self.r.parent(ctor_def_id); let def_id = self.r.tcx.parent(ctor_def_id);
let has_no_fields = self.r.field_names.get(&def_id).map_or(false, |f| f.is_empty()); let has_no_fields = self.r.field_names.get(&def_id).map_or(false, |f| f.is_empty());
match kind { match kind {
CtorKind::Const => false, CtorKind::Const => false,

View File

@ -44,7 +44,7 @@ use rustc_metadata::creader::{CStore, CrateLoader};
use rustc_middle::metadata::ModChild; use rustc_middle::metadata::ModChild;
use rustc_middle::middle::privacy::EffectiveVisibilities; use rustc_middle::middle::privacy::EffectiveVisibilities;
use rustc_middle::span_bug; use rustc_middle::span_bug;
use rustc_middle::ty::{self, DefIdTree, MainDefinition, RegisteredTools, TyCtxt}; use rustc_middle::ty::{self, MainDefinition, RegisteredTools, TyCtxt};
use rustc_middle::ty::{ResolverGlobalCtxt, ResolverOutputs}; use rustc_middle::ty::{ResolverGlobalCtxt, ResolverOutputs};
use rustc_query_system::ich::StableHashingContext; use rustc_query_system::ich::StableHashingContext;
use rustc_session::cstore::CrateStore; use rustc_session::cstore::CrateStore;
@ -1117,13 +1117,6 @@ impl<'a, 'tcx> AsMut<Resolver<'a, 'tcx>> for Resolver<'a, 'tcx> {
} }
} }
impl<'a, 'b, 'tcx> DefIdTree for &'a Resolver<'b, 'tcx> {
#[inline]
fn opt_parent(self, id: DefId) -> Option<DefId> {
self.tcx.opt_parent(id)
}
}
impl<'tcx> Resolver<'_, 'tcx> { impl<'tcx> Resolver<'_, 'tcx> {
fn opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId> { fn opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId> {
self.node_id_to_def_id.get(&node).copied() self.node_id_to_def_id.get(&node).copied()
@ -1789,7 +1782,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
vis: ty::Visibility<impl Into<DefId>>, vis: ty::Visibility<impl Into<DefId>>,
module: Module<'a>, module: Module<'a>,
) -> bool { ) -> bool {
vis.is_accessible_from(module.nearest_parent_mod(), self) vis.is_accessible_from(module.nearest_parent_mod(), self.tcx)
} }
fn set_binding_parent_module(&mut self, binding: &'a NameBinding<'a>, module: Module<'a>) { fn set_binding_parent_module(&mut self, binding: &'a NameBinding<'a>, module: Module<'a>) {

View File

@ -30,7 +30,7 @@ use rustc_middle::hir::map;
use rustc_middle::ty::error::TypeError::{self, Sorts}; use rustc_middle::ty::error::TypeError::{self, Sorts};
use rustc_middle::ty::relate::TypeRelation; use rustc_middle::ty::relate::TypeRelation;
use rustc_middle::ty::{ use rustc_middle::ty::{
self, suggest_arbitrary_trait_bound, suggest_constraining_type_param, AdtKind, DefIdTree, self, suggest_arbitrary_trait_bound, suggest_constraining_type_param, AdtKind,
GeneratorDiagnosticData, GeneratorInteriorTypeCause, Infer, InferTy, InternalSubsts, GeneratorDiagnosticData, GeneratorInteriorTypeCause, Infer, InferTy, InternalSubsts,
IsSuggestable, ToPredicate, Ty, TyCtxt, TypeAndMut, TypeFoldable, TypeFolder, IsSuggestable, ToPredicate, Ty, TyCtxt, TypeAndMut, TypeFoldable, TypeFolder,
TypeSuperFoldable, TypeVisitableExt, TypeckResults, TypeSuperFoldable, TypeVisitableExt, TypeckResults,

View File

@ -28,7 +28,7 @@ use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
use rustc_errors::ErrorGuaranteed; use rustc_errors::ErrorGuaranteed;
use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt}; use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt};
use rustc_middle::ty::{self, DefIdTree, ToPredicate, Ty, TyCtxt, TypeSuperVisitable}; use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt, TypeSuperVisitable};
use rustc_middle::ty::{InternalSubsts, SubstsRef}; use rustc_middle::ty::{InternalSubsts, SubstsRef};
use rustc_span::def_id::{DefId, CRATE_DEF_ID}; use rustc_span::def_id::{DefId, CRATE_DEF_ID};
use rustc_span::Span; use rustc_span::Span;

View File

@ -32,7 +32,6 @@ use rustc_infer::traits::ImplSourceBuiltinData;
use rustc_middle::traits::select::OverflowError; use rustc_middle::traits::select::OverflowError;
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable}; use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
use rustc_middle::ty::visit::{MaxUniverse, TypeVisitable, TypeVisitableExt}; use rustc_middle::ty::visit::{MaxUniverse, TypeVisitable, TypeVisitableExt};
use rustc_middle::ty::DefIdTree;
use rustc_middle::ty::{self, Term, ToPredicate, Ty, TyCtxt}; use rustc_middle::ty::{self, Term, ToPredicate, Ty, TyCtxt};
use rustc_span::symbol::sym; use rustc_span::symbol::sym;

View File

@ -58,9 +58,7 @@ mod rustc {
use rustc_middle::ty; use rustc_middle::ty;
let parent = if let ty::Adt(adt_def, ..) = scope.kind() { let parent = if let ty::Adt(adt_def, ..) = scope.kind() {
use rustc_middle::ty::DefIdTree; self.parent(adt_def.did())
let parent = self.parent(adt_def.did());
parent
} else { } else {
// Is this always how we want to handle a non-ADT scope? // Is this always how we want to handle a non-ADT scope?
return false; return false;

View File

@ -4,7 +4,7 @@ use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::definitions::DefPathData; use rustc_hir::definitions::DefPathData;
use rustc_hir::intravisit::{self, Visitor}; use rustc_hir::intravisit::{self, Visitor};
use rustc_middle::ty::{self, DefIdTree, ImplTraitInTraitData, InternalSubsts, TyCtxt}; use rustc_middle::ty::{self, ImplTraitInTraitData, InternalSubsts, TyCtxt};
use rustc_span::symbol::kw; use rustc_span::symbol::kw;
pub fn provide(providers: &mut ty::query::Providers) { pub fn provide(providers: &mut ty::query::Providers) {

View File

@ -1,4 +1,3 @@
use crate::rustc_middle::ty::DefIdTree;
use rustc_hir::{def::DefKind, def_id::DefId}; use rustc_hir::{def::DefKind, def_id::DefId};
use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::ty::{self, Ty, TyCtxt};

View File

@ -25,7 +25,7 @@ use rustc_middle::middle::resolve_bound_vars as rbv;
use rustc_middle::ty::fold::TypeFolder; use rustc_middle::ty::fold::TypeFolder;
use rustc_middle::ty::InternalSubsts; use rustc_middle::ty::InternalSubsts;
use rustc_middle::ty::TypeVisitableExt; use rustc_middle::ty::TypeVisitableExt;
use rustc_middle::ty::{self, AdtKind, DefIdTree, EarlyBinder, Ty, TyCtxt}; use rustc_middle::ty::{self, AdtKind, EarlyBinder, Ty, TyCtxt};
use rustc_middle::{bug, span_bug}; use rustc_middle::{bug, span_bug};
use rustc_span::hygiene::{AstPass, MacroKind}; use rustc_span::hygiene::{AstPass, MacroKind};
use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::symbol::{kw, sym, Ident, Symbol};

View File

@ -22,7 +22,7 @@ use rustc_hir::{BodyId, Mutability};
use rustc_hir_analysis::check::intrinsic::intrinsic_operation_unsafety; use rustc_hir_analysis::check::intrinsic::intrinsic_operation_unsafety;
use rustc_index::vec::IndexVec; use rustc_index::vec::IndexVec;
use rustc_middle::ty::fast_reject::SimplifiedType; use rustc_middle::ty::fast_reject::SimplifiedType;
use rustc_middle::ty::{self, DefIdTree, TyCtxt, Visibility}; use rustc_middle::ty::{self, TyCtxt, Visibility};
use rustc_resolve::rustdoc::{add_doc_fragment, attrs_to_doc_fragments, inner_docs, DocFragment}; use rustc_resolve::rustdoc::{add_doc_fragment, attrs_to_doc_fragments, inner_docs, DocFragment};
use rustc_session::Session; use rustc_session::Session;
use rustc_span::hygiene::MacroKind; use rustc_span::hygiene::MacroKind;

View File

@ -17,7 +17,7 @@ use rustc_hir::def_id::{DefId, LOCAL_CRATE};
use rustc_middle::mir; use rustc_middle::mir;
use rustc_middle::mir::interpret::ConstValue; use rustc_middle::mir::interpret::ConstValue;
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef}; use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
use rustc_middle::ty::{self, DefIdTree, TyCtxt}; use rustc_middle::ty::{self, TyCtxt};
use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::symbol::{kw, sym, Symbol};
use std::fmt::Write as _; use std::fmt::Write as _;
use std::mem; use std::mem;

View File

@ -19,7 +19,6 @@ use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_metadata::creader::{CStore, LoadedMacro}; use rustc_metadata::creader::{CStore, LoadedMacro};
use rustc_middle::ty; use rustc_middle::ty;
use rustc_middle::ty::DefIdTree;
use rustc_middle::ty::TyCtxt; use rustc_middle::ty::TyCtxt;
use rustc_span::symbol::kw; use rustc_span::symbol::kw;
use rustc_span::{sym, Symbol}; use rustc_span::{sym, Symbol};

View File

@ -8,7 +8,6 @@ use crate::visit::DocVisitor;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_lint::builtin::MISSING_DOCS; use rustc_lint::builtin::MISSING_DOCS;
use rustc_middle::lint::LintLevelSource; use rustc_middle::lint::LintLevelSource;
use rustc_middle::ty::DefIdTree;
use rustc_session::lint; use rustc_session::lint;
use rustc_span::FileName; use rustc_span::FileName;
use serde::Serialize; use serde::Serialize;

View File

@ -14,7 +14,6 @@ use crate::visit::DocVisitor;
use crate::visit_ast::inherits_doc_hidden; use crate::visit_ast::inherits_doc_hidden;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_middle::lint::LintLevelSource; use rustc_middle::lint::LintLevelSource;
use rustc_middle::ty::DefIdTree;
use rustc_session::lint; use rustc_session::lint;
pub(crate) const CHECK_DOC_TEST_VISIBILITY: Pass = Pass { pub(crate) const CHECK_DOC_TEST_VISIBILITY: Pass = Pass {

View File

@ -13,7 +13,7 @@ use rustc_hir::def::Namespace::*;
use rustc_hir::def::{DefKind, Namespace, PerNS}; use rustc_hir::def::{DefKind, Namespace, PerNS};
use rustc_hir::def_id::{DefId, CRATE_DEF_ID}; use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
use rustc_hir::Mutability; use rustc_hir::Mutability;
use rustc_middle::ty::{DefIdTree, Ty, TyCtxt}; use rustc_middle::ty::{Ty, TyCtxt};
use rustc_middle::{bug, ty}; use rustc_middle::{bug, ty};
use rustc_resolve::rustdoc::MalformedGenerics; use rustc_resolve::rustdoc::MalformedGenerics;
use rustc_resolve::rustdoc::{prepare_to_doc_link_resolution, strip_generics_from_path}; use rustc_resolve::rustdoc::{prepare_to_doc_link_resolution, strip_generics_from_path};

View File

@ -9,7 +9,7 @@ use crate::visit::DocVisitor;
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LOCAL_CRATE}; use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LOCAL_CRATE};
use rustc_middle::ty::{self, DefIdTree}; use rustc_middle::ty;
use rustc_span::symbol::sym; use rustc_span::symbol::sym;
pub(crate) const COLLECT_TRAIT_IMPLS: Pass = Pass { pub(crate) const COLLECT_TRAIT_IMPLS: Pass = Pass {

View File

@ -9,7 +9,6 @@ use crate::fold::DocFolder;
use crate::passes::Pass; use crate::passes::Pass;
use rustc_hir::def_id::LocalDefId; use rustc_hir::def_id::LocalDefId;
use rustc_middle::ty::DefIdTree;
pub(crate) const PROPAGATE_DOC_CFG: Pass = Pass { pub(crate) const PROPAGATE_DOC_CFG: Pass = Pass {
name: "propagate-doc-cfg", name: "propagate-doc-cfg",

View File

@ -8,7 +8,7 @@ use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId, LocalDefIdSet};
use rustc_hir::intravisit::{walk_item, Visitor}; use rustc_hir::intravisit::{walk_item, Visitor};
use rustc_hir::{Node, CRATE_HIR_ID}; use rustc_hir::{Node, CRATE_HIR_ID};
use rustc_middle::hir::nested_filter; use rustc_middle::hir::nested_filter;
use rustc_middle::ty::{DefIdTree, TyCtxt}; use rustc_middle::ty::TyCtxt;
use rustc_span::def_id::{CRATE_DEF_ID, LOCAL_CRATE}; use rustc_span::def_id::{CRATE_DEF_ID, LOCAL_CRATE};
use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::Span; use rustc_span::Span;

View File

@ -8,7 +8,7 @@ use rustc_hir::{
Body, Expr, ExprKind, GenericArg, Impl, ImplItemKind, Item, ItemKind, Node, PathSegment, QPath, Ty, TyKind, Body, Expr, ExprKind, GenericArg, Impl, ImplItemKind, Item, ItemKind, Node, PathSegment, QPath, Ty, TyKind,
}; };
use rustc_lint::{LateContext, LateLintPass}; use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::{AdtDef, DefIdTree}; use rustc_middle::ty::AdtDef;
use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_span::sym; use rustc_span::sym;

View File

@ -9,7 +9,7 @@ use rustc_errors::Applicability;
use rustc_hir::def::{DefKind, Res}; use rustc_hir::def::{DefKind, Res};
use rustc_hir::{Expr, Pat, PatKind}; use rustc_hir::{Expr, Pat, PatKind};
use rustc_lint::LateContext; use rustc_lint::LateContext;
use rustc_middle::ty::{self, DefIdTree}; use rustc_middle::ty;
use rustc_span::source_map::Span; use rustc_span::source_map::Span;
/// Check for unnecessary `if let` usage in a for loop where only the `Some` or `Ok` variant of the /// Check for unnecessary `if let` usage in a for loop where only the `Some` or `Ok` variant of the

View File

@ -8,7 +8,6 @@ use rustc_errors::Applicability;
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res}; use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
use rustc_hir::{self as hir, Expr, ExprKind, QPath}; use rustc_hir::{self as hir, Expr, ExprKind, QPath};
use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
use rustc_middle::ty::DefIdTree;
use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_span::def_id::{DefId, LocalDefId}; use rustc_span::def_id::{DefId, LocalDefId};
use rustc_span::{sym, Span}; use rustc_span::{sym, Span};

View File

@ -10,7 +10,6 @@ use rustc_hir::def::{DefKind, Res};
use rustc_hir::LangItem::{OptionNone, ResultErr}; use rustc_hir::LangItem::{OptionNone, ResultErr};
use rustc_hir::{Arm, Expr, PatKind}; use rustc_hir::{Arm, Expr, PatKind};
use rustc_lint::LateContext; use rustc_lint::LateContext;
use rustc_middle::ty::DefIdTree;
use rustc_span::sym; use rustc_span::sym;
use super::MANUAL_UNWRAP_OR; use super::MANUAL_UNWRAP_OR;

View File

@ -12,7 +12,7 @@ use rustc_hir::def::{DefKind, Res};
use rustc_hir::LangItem::{self, OptionNone, OptionSome, PollPending, PollReady, ResultErr, ResultOk}; use rustc_hir::LangItem::{self, OptionNone, OptionSome, PollPending, PollReady, ResultErr, ResultOk};
use rustc_hir::{Arm, Expr, ExprKind, Node, Pat, PatKind, QPath, UnOp}; use rustc_hir::{Arm, Expr, ExprKind, Node, Pat, PatKind, QPath, UnOp};
use rustc_lint::LateContext; use rustc_lint::LateContext;
use rustc_middle::ty::{self, subst::GenericArgKind, DefIdTree, Ty}; use rustc_middle::ty::{self, subst::GenericArgKind, Ty};
use rustc_span::{sym, Symbol}; use rustc_span::{sym, Symbol};
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {

View File

@ -8,7 +8,6 @@ use rustc_hir as hir;
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res}; use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
use rustc_hir::{LangItem, QPath}; use rustc_hir::{LangItem, QPath};
use rustc_lint::LateContext; use rustc_lint::LateContext;
use rustc_middle::ty::DefIdTree;
use rustc_span::Span; use rustc_span::Span;
pub(crate) struct OptionAndThenSome; pub(crate) struct OptionAndThenSome;

View File

@ -6,7 +6,7 @@ use rustc_errors::Applicability;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_lint::LateContext; use rustc_lint::LateContext;
use rustc_lint::Lint; use rustc_lint::Lint;
use rustc_middle::ty::{self, DefIdTree}; use rustc_middle::ty;
/// Wrapper fn for `CHARS_NEXT_CMP` and `CHARS_LAST_CMP` lints. /// Wrapper fn for `CHARS_NEXT_CMP` and `CHARS_LAST_CMP` lints.
pub(super) fn check( pub(super) fn check(

View File

@ -6,7 +6,6 @@ use rustc_errors::Applicability;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::LangItem::{OptionNone, OptionSome}; use rustc_hir::LangItem::{OptionNone, OptionSome};
use rustc_lint::LateContext; use rustc_lint::LateContext;
use rustc_middle::ty::DefIdTree;
use rustc_span::symbol::sym; use rustc_span::symbol::sym;
use super::OPTION_MAP_OR_NONE; use super::OPTION_MAP_OR_NONE;

View File

@ -13,7 +13,7 @@ use if_chain::if_chain;
use rustc_ast::ast::{self, MetaItem, MetaItemKind}; use rustc_ast::ast::{self, MetaItem, MetaItemKind};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_middle::ty::{DefIdTree, Visibility}; use rustc_middle::ty::Visibility;
use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_span::def_id::CRATE_DEF_ID; use rustc_span::def_id::CRATE_DEF_ID;
use rustc_span::source_map::Span; use rustc_span::source_map::Span;

View File

@ -6,7 +6,6 @@ use rustc_errors::Applicability;
use rustc_hir::def::{DefKind, Res}; use rustc_hir::def::{DefKind, Res};
use rustc_hir::{AsyncGeneratorKind, Block, Body, Expr, ExprKind, GeneratorKind, LangItem, MatchSource, QPath}; use rustc_hir::{AsyncGeneratorKind, Block, Body, Expr, ExprKind, GeneratorKind, LangItem, MatchSource, QPath};
use rustc_lint::{LateContext, LateLintPass}; use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::DefIdTree;
use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_session::{declare_lint_pass, declare_tool_lint};
declare_clippy_lint! { declare_clippy_lint! {

View File

@ -2,7 +2,6 @@ use clippy_utils::diagnostics::span_lint_and_help;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_hir::{def::Res, HirId, Path, PathSegment}; use rustc_hir::{def::Res, HirId, Path, PathSegment};
use rustc_lint::{LateContext, LateLintPass}; use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::DefIdTree;
use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_span::{sym, symbol::kw, Span}; use rustc_span::{sym, symbol::kw, Span};

View File

@ -11,7 +11,7 @@ use rustc_hir::def_id::DefId;
use rustc_hir::{BinOpKind, Expr, ExprKind, UnOp}; use rustc_hir::{BinOpKind, Expr, ExprKind, UnOp};
use rustc_lint::{LateContext, LateLintPass}; use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::mir::interpret::ConstValue; use rustc_middle::mir::interpret::ConstValue;
use rustc_middle::ty::{self}; use rustc_middle::ty;
use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_span::symbol::Symbol; use rustc_span::symbol::Symbol;

View File

@ -11,7 +11,7 @@ use rustc_hir::def_id::DefId;
use rustc_hir::{Expr, ExprKind, Local, Mutability, Node}; use rustc_hir::{Expr, ExprKind, Local, Mutability, Node};
use rustc_lint::{LateContext, LateLintPass}; use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::mir::interpret::{Allocation, ConstValue, GlobalAlloc}; use rustc_middle::mir::interpret::{Allocation, ConstValue, GlobalAlloc};
use rustc_middle::ty::{self, DefIdTree, Ty}; use rustc_middle::ty::{self, Ty};
use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_span::symbol::Symbol; use rustc_span::symbol::Symbol;
use rustc_span::Span; use rustc_span::Span;

View File

@ -104,7 +104,7 @@ use rustc_middle::ty::fast_reject::SimplifiedType::{
PtrSimplifiedType, SliceSimplifiedType, StrSimplifiedType, UintSimplifiedType, PtrSimplifiedType, SliceSimplifiedType, StrSimplifiedType, UintSimplifiedType,
}; };
use rustc_middle::ty::{ use rustc_middle::ty::{
layout::IntegerExt, BorrowKind, ClosureKind, DefIdTree, Ty, TyCtxt, TypeAndMut, TypeVisitableExt, UpvarCapture, layout::IntegerExt, BorrowKind, ClosureKind, Ty, TyCtxt, TypeAndMut, TypeVisitableExt, UpvarCapture,
}; };
use rustc_middle::ty::{FloatTy, IntTy, UintTy}; use rustc_middle::ty::{FloatTy, IntTy, UintTy};
use rustc_span::hygiene::{ExpnKind, MacroKind}; use rustc_span::hygiene::{ExpnKind, MacroKind};

View File

@ -16,7 +16,7 @@ use rustc_infer::infer::{
use rustc_lint::LateContext; use rustc_lint::LateContext;
use rustc_middle::mir::interpret::{ConstValue, Scalar}; use rustc_middle::mir::interpret::{ConstValue, Scalar};
use rustc_middle::ty::{ use rustc_middle::ty::{
self, AdtDef, AliasTy, AssocKind, Binder, BoundRegion, DefIdTree, FnSig, IntTy, List, ParamEnv, Predicate, self, AdtDef, AliasTy, AssocKind, Binder, BoundRegion, FnSig, IntTy, List, ParamEnv, Predicate,
PredicateKind, Region, RegionKind, SubstsRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, PredicateKind, Region, RegionKind, SubstsRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
TypeVisitor, UintTy, VariantDef, VariantDiscr, TypeVisitor, UintTy, VariantDef, VariantDiscr,
}; };