mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
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:
parent
7e966bcd03
commit
c83553da31
@ -13,7 +13,7 @@ use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
|
||||
use rustc_hir::PredicateOrigin;
|
||||
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::source_map::DesugaringKind;
|
||||
use rustc_span::symbol::{kw, sym, Ident};
|
||||
|
@ -13,7 +13,7 @@ use rustc_middle::mir::{
|
||||
Place, PlaceRef, ProjectionElem, Rvalue, Statement, StatementKind, Terminator, TerminatorKind,
|
||||
};
|
||||
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_span::def_id::LocalDefId;
|
||||
use rustc_span::{symbol::sym, Span, Symbol, DUMMY_SP};
|
||||
|
@ -6,7 +6,7 @@ use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_middle::ty::print::RegionHighlightMode;
|
||||
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::{Span, DUMMY_SP};
|
||||
|
||||
|
@ -22,9 +22,7 @@ use rustc_hir::BodyOwnerKind;
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_infer::infer::NllRegionVariableOrigin;
|
||||
use rustc_middle::ty::fold::TypeFoldable;
|
||||
use rustc_middle::ty::{
|
||||
self, DefIdTree, InlineConstSubsts, InlineConstSubstsParts, RegionVid, Ty, TyCtxt,
|
||||
};
|
||||
use rustc_middle::ty::{self, InlineConstSubsts, InlineConstSubstsParts, RegionVid, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{InternalSubsts, SubstsRef};
|
||||
use rustc_span::Symbol;
|
||||
use std::iter;
|
||||
|
@ -5,7 +5,7 @@ use super::CodegenUnitDebugContext;
|
||||
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::ty::layout::{HasParamEnv, LayoutOf};
|
||||
use rustc_middle::ty::{self, DefIdTree, Ty};
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use trace;
|
||||
|
||||
use crate::common::CodegenCx;
|
||||
|
@ -11,7 +11,7 @@ use rustc_middle::middle::exported_symbols::{
|
||||
use rustc_middle::ty::query::{ExternProviders, Providers};
|
||||
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
|
||||
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_target::spec::SanitizerSet;
|
||||
|
||||
|
@ -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::mir::mono::Linkage;
|
||||
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_span::{sym, Span};
|
||||
use rustc_target::spec::{abi, SanitizerSet};
|
||||
|
@ -8,7 +8,7 @@ use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_hir::def_id::LOCAL_CRATE;
|
||||
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::Session;
|
||||
use rustc_span::symbol::sym;
|
||||
|
@ -2,7 +2,7 @@ use rustc_hir as hir;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::{DefIdTree, TyCtxt};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_span::symbol::Symbol;
|
||||
|
||||
/// Whether the `def_id` is an unstable const fn and what feature gate is necessary to enable it
|
||||
|
@ -12,9 +12,7 @@ use rustc_infer::traits::{ImplSource, Obligation, ObligationCause};
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
|
||||
use rustc_middle::ty::{
|
||||
suggest_constraining_type_param, Adt, Closure, DefIdTree, FnDef, FnPtr, Param, Ty,
|
||||
};
|
||||
use rustc_middle::ty::{suggest_constraining_type_param, Adt, Closure, FnDef, FnPtr, Param, Ty};
|
||||
use rustc_middle::ty::{Binder, TraitRef};
|
||||
use rustc_session::parse::feature_err;
|
||||
use rustc_span::symbol::sym;
|
||||
|
@ -35,7 +35,7 @@ use rustc_middle::middle::stability::AllowUnstable;
|
||||
use rustc_middle::ty::subst::{self, GenericArgKind, InternalSubsts, SubstsRef};
|
||||
use rustc_middle::ty::DynKind;
|
||||
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_span::edit_distance::find_best_match_for_name;
|
||||
use rustc_span::edition::Edition;
|
||||
|
@ -22,8 +22,7 @@ use rustc_middle::ty::layout::{LayoutError, MAX_SIMD_LANES};
|
||||
use rustc_middle::ty::subst::GenericArgKind;
|
||||
use rustc_middle::ty::util::{Discr, IntTypeExt};
|
||||
use rustc_middle::ty::{
|
||||
self, AdtDef, DefIdTree, ParamEnv, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable,
|
||||
TypeVisitableExt,
|
||||
self, AdtDef, ParamEnv, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
|
||||
};
|
||||
use rustc_session::lint::builtin::{UNINHABITED_STATIC, UNSUPPORTED_CALLING_CONVENTIONS};
|
||||
use rustc_span::symbol::sym;
|
||||
|
@ -16,8 +16,7 @@ use rustc_infer::traits::util;
|
||||
use rustc_middle::ty::error::{ExpectedFound, TypeError};
|
||||
use rustc_middle::ty::util::ExplicitSelf;
|
||||
use rustc_middle::ty::{
|
||||
self, DefIdTree, InternalSubsts, Ty, TypeFoldable, TypeFolder, TypeSuperFoldable,
|
||||
TypeVisitableExt,
|
||||
self, InternalSubsts, Ty, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt,
|
||||
};
|
||||
use rustc_middle::ty::{GenericParamDefKind, ToPredicate, TyCtxt};
|
||||
use rustc_span::Span;
|
||||
|
@ -3,7 +3,7 @@ use crate::astconv::AstConv;
|
||||
use rustc_hir as hir;
|
||||
use rustc_infer::traits::util;
|
||||
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::Span;
|
||||
|
||||
|
@ -17,7 +17,7 @@ use rustc_hir::{GenericArg, GenericParam, GenericParamKind, HirIdMap, LifetimeNa
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::hir::nested_filter;
|
||||
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_span::def_id::DefId;
|
||||
use rustc_span::symbol::{sym, Ident};
|
||||
|
@ -9,7 +9,7 @@ use rustc_middle::ty::print::with_forced_trimmed_paths;
|
||||
use rustc_middle::ty::subst::InternalSubsts;
|
||||
use rustc_middle::ty::util::IntTypeExt;
|
||||
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::{Span, DUMMY_SP};
|
||||
|
@ -1,7 +1,7 @@
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_hir::def::DefKind;
|
||||
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_span::Span;
|
||||
|
||||
|
@ -8,7 +8,7 @@ use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_middle::ty::query::Providers;
|
||||
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;
|
||||
|
||||
/// Defines the `TermsContext` basically houses an arena where we can
|
||||
|
@ -25,7 +25,7 @@ use rustc_middle::ty::error::TypeError;
|
||||
use rustc_middle::ty::fold::TypeFoldable;
|
||||
use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt};
|
||||
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_session::lint;
|
||||
|
@ -3,9 +3,7 @@ use rustc_hir as hir;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_infer::traits::ObligationCauseCode;
|
||||
use rustc_middle::ty::{
|
||||
self, DefIdTree, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor,
|
||||
};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor};
|
||||
use rustc_span::{self, Span};
|
||||
use rustc_trait_selection::traits;
|
||||
|
||||
|
@ -28,7 +28,7 @@ use rustc_infer::infer::InferOk;
|
||||
use rustc_infer::infer::TypeTrace;
|
||||
use rustc_middle::ty::adjustment::AllowTwoPhase;
|
||||
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_span::symbol::{kw, Ident};
|
||||
use rustc_span::{self, sym, Span};
|
||||
|
@ -16,7 +16,7 @@ use rustc_infer::traits::{self, StatementAsExpression};
|
||||
use rustc_middle::lint::in_external_macro;
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
use rustc_middle::ty::{
|
||||
self, suggest_constraining_type_params, Binder, DefIdTree, IsSuggestable, ToPredicate, Ty,
|
||||
self, suggest_constraining_type_params, Binder, IsSuggestable, ToPredicate, Ty,
|
||||
TypeVisitableExt,
|
||||
};
|
||||
use rustc_session::errors::ExprParenthesesNeeded;
|
||||
|
@ -27,7 +27,7 @@ use rustc_middle::traits::util::supertraits;
|
||||
use rustc_middle::ty::fast_reject::DeepRejectCtxt;
|
||||
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::{self, DefIdTree, GenericArgKind, Ty, TyCtxt, TypeVisitableExt};
|
||||
use rustc_middle::ty::{self, GenericArgKind, Ty, TyCtxt, TypeVisitableExt};
|
||||
use rustc_middle::ty::{IsSuggestable, ToPolyTraitRef};
|
||||
use rustc_span::symbol::{kw, sym, Ident};
|
||||
use rustc_span::Symbol;
|
||||
|
@ -13,7 +13,7 @@ use rustc_middle::ty::adjustment::{
|
||||
};
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
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_span::source_map::Spanned;
|
||||
|
@ -17,7 +17,7 @@ use rustc_middle::hir::nested_filter;
|
||||
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind};
|
||||
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow};
|
||||
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::{IsSuggestable, Ty, TyCtxt, TypeckResults};
|
||||
use rustc_span::symbol::{kw, sym, Ident};
|
||||
|
@ -5,7 +5,7 @@ use crate::infer::error_reporting::nice_region_error::NiceRegionError;
|
||||
use crate::infer::TyCtxt;
|
||||
use rustc_hir as hir;
|
||||
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;
|
||||
|
||||
/// Information about the anonymous region we are searching for.
|
||||
|
@ -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::subst::SubstsRef;
|
||||
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::source_map;
|
||||
|
@ -14,7 +14,7 @@ use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_infer::traits::util::elaborate_predicates_with_span;
|
||||
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::{kw, sym};
|
||||
use rustc_span::{BytePos, Span};
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::hir::{ModuleItems, Owner};
|
||||
use crate::ty::{DefIdTree, TyCtxt};
|
||||
use crate::ty::TyCtxt;
|
||||
use rustc_ast as ast;
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
|
@ -7,7 +7,7 @@ pub mod nested_filter;
|
||||
pub mod place;
|
||||
|
||||
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::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_data_structures::sync::{par_for_each_in, Send, Sync};
|
||||
|
@ -1,7 +1,7 @@
|
||||
//! 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
|
||||
//! 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::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_macros::HashStable;
|
||||
@ -112,7 +112,7 @@ impl EffectiveVisibilities {
|
||||
&mut self,
|
||||
def_id: LocalDefId,
|
||||
eff_vis: &EffectiveVisibility,
|
||||
tree: impl DefIdTree,
|
||||
tcx: TyCtxt<'_>,
|
||||
) {
|
||||
use std::collections::hash_map::Entry;
|
||||
match self.map.entry(def_id) {
|
||||
@ -122,7 +122,7 @@ impl EffectiveVisibilities {
|
||||
let vis_at_level = eff_vis.at_level(l);
|
||||
let old_vis_at_level = old_eff_vis.at_level_mut(l);
|
||||
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
|
||||
}
|
||||
@ -219,7 +219,7 @@ impl<Id: Eq + Hash> EffectiveVisibilities<Id> {
|
||||
lazy_private_vis: impl FnOnce() -> Visibility,
|
||||
inherited_effective_vis: EffectiveVisibility,
|
||||
level: Level,
|
||||
tree: impl DefIdTree,
|
||||
tcx: TyCtxt<'_>,
|
||||
) -> bool {
|
||||
let mut changed = false;
|
||||
let mut current_effective_vis = self
|
||||
@ -240,7 +240,7 @@ impl<Id: Eq + Hash> EffectiveVisibilities<Id> {
|
||||
&& level != l)
|
||||
{
|
||||
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
|
||||
} else {
|
||||
nominal_vis
|
||||
@ -249,7 +249,7 @@ impl<Id: Eq + Hash> EffectiveVisibilities<Id> {
|
||||
// effective visibility can't be decreased at next update call for the
|
||||
// same id
|
||||
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;
|
||||
*current_effective_vis_at_level = calculated_effective_vis;
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
pub use self::StabilityLevel::*;
|
||||
|
||||
use crate::ty::{self, DefIdTree, TyCtxt};
|
||||
use crate::ty::{self, TyCtxt};
|
||||
use rustc_ast::NodeId;
|
||||
use rustc_attr::{self as attr, ConstStability, DefaultBodyStability, Deprecation, Stability};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
|
@ -10,7 +10,7 @@ use crate::ty::codec::{TyDecoder, TyEncoder};
|
||||
use crate::ty::fold::{FallibleTypeFolder, TypeFoldable};
|
||||
use crate::ty::print::{FmtPrinter, Printer};
|
||||
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::{GenericArg, InternalSubsts, SubstsRef};
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
pub use self::AssocItemContainer::*;
|
||||
|
||||
use crate::ty::{self, DefIdTree};
|
||||
use crate::ty;
|
||||
use rustc_data_structures::sorted_map::SortedIndexMultiMap;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Namespace};
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::middle::resolve_bound_vars as rbv;
|
||||
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_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
|
@ -20,11 +20,10 @@ use crate::traits;
|
||||
use crate::traits::solve::{ExternalConstraints, ExternalConstraintsData};
|
||||
use crate::ty::query::{self, TyCtxtAt};
|
||||
use crate::ty::{
|
||||
self, AdtDef, AdtDefData, AdtKind, Binder, Const, ConstData, DefIdTree, FloatTy, FloatVar,
|
||||
FloatVid, GenericParamDefKind, ImplPolarity, InferTy, IntTy, IntVar, IntVid, List, ParamConst,
|
||||
ParamTy, PolyExistentialPredicate, PolyFnSig, Predicate, PredicateKind, Region, RegionKind,
|
||||
ReprOptions, TraitObjectVisitor, Ty, TyKind, TyVar, TyVid, TypeAndMut, TypeckResults, UintTy,
|
||||
Visibility,
|
||||
self, AdtDef, AdtDefData, AdtKind, Binder, Const, ConstData, FloatTy, FloatVar, FloatVid,
|
||||
GenericParamDefKind, ImplPolarity, InferTy, IntTy, IntVar, IntVid, List, ParamConst, ParamTy,
|
||||
PolyExistentialPredicate, PolyFnSig, Predicate, PredicateKind, Region, RegionKind, ReprOptions,
|
||||
TraitObjectVisitor, Ty, TyKind, TyVar, TyVid, TypeAndMut, TypeckResults, UintTy, Visibility,
|
||||
};
|
||||
use crate::ty::{GenericArg, InternalSubsts, SubstsRef};
|
||||
use rustc_ast as ast;
|
||||
|
@ -3,9 +3,9 @@
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
use crate::ty::{
|
||||
AliasTy, Const, ConstKind, DefIdTree, FallibleTypeFolder, InferConst, InferTy, Opaque,
|
||||
PolyTraitPredicate, Projection, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable,
|
||||
TypeSuperVisitable, TypeVisitable, TypeVisitor,
|
||||
AliasTy, Const, ConstKind, FallibleTypeFolder, InferConst, InferTy, Opaque, PolyTraitPredicate,
|
||||
Projection, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, TypeSuperVisitable, TypeVisitable,
|
||||
TypeVisitor,
|
||||
};
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
|
@ -1,5 +1,5 @@
|
||||
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.
|
||||
/// Examples of uninhabited types are `!`, `enum Void {}`, or a struct
|
||||
|
@ -325,12 +325,15 @@ pub struct ClosureSizeProfileData<'tcx> {
|
||||
pub after_feature_tys: Ty<'tcx>,
|
||||
}
|
||||
|
||||
pub trait DefIdTree: Copy {
|
||||
fn opt_parent(self, id: DefId) -> Option<DefId>;
|
||||
impl TyCtxt<'_> {
|
||||
#[inline]
|
||||
pub fn opt_parent(self, id: DefId) -> Option<DefId> {
|
||||
self.def_key(id).parent.map(|index| DefId { index, ..id })
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
fn parent(self, id: DefId) -> DefId {
|
||||
pub fn parent(self, id: DefId) -> DefId {
|
||||
match self.opt_parent(id) {
|
||||
Some(id) => id,
|
||||
// not `unwrap_or_else` to avoid breaking caller tracking
|
||||
@ -340,17 +343,17 @@ pub trait DefIdTree: Copy {
|
||||
|
||||
#[inline]
|
||||
#[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)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[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()
|
||||
}
|
||||
|
||||
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 {
|
||||
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> {
|
||||
pub fn is_public(self) -> bool {
|
||||
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.
|
||||
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 {
|
||||
// Public items are visible everywhere.
|
||||
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
|
||||
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 {
|
||||
Visibility::Public => self.is_public(),
|
||||
Visibility::Restricted(id) => self.is_accessible_from(id, tree),
|
||||
Visibility::Restricted(id) => self.is_accessible_from(id, tcx),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
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::sso::SsoHashSet;
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::mir::interpret::{AllocRange, GlobalAlloc, Pointer, Provenance, Scalar};
|
||||
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,
|
||||
};
|
||||
use crate::ty::{GenericArg, GenericArgKind};
|
||||
|
@ -7,7 +7,7 @@ use crate::ty::subst::{GenericArg, InternalSubsts, SubstsRef};
|
||||
use crate::ty::visit::ValidateBoundVars;
|
||||
use crate::ty::InferTy::*;
|
||||
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,
|
||||
};
|
||||
use crate::ty::{List, ParamEnv};
|
||||
|
@ -4,8 +4,8 @@ use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
use crate::mir;
|
||||
use crate::ty::layout::IntegerExt;
|
||||
use crate::ty::{
|
||||
self, DefIdTree, FallibleTypeFolder, ToPredicate, Ty, TyCtxt, TypeFoldable, TypeFolder,
|
||||
TypeSuperFoldable, TypeVisitableExt,
|
||||
self, FallibleTypeFolder, ToPredicate, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable,
|
||||
TypeVisitableExt,
|
||||
};
|
||||
use crate::ty::{GenericArgKind, SubstsRef};
|
||||
use rustc_apfloat::Float as _;
|
||||
|
@ -4,7 +4,7 @@ use rustc_errors::{pluralize, struct_span_err, Applicability, MultiSpan};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
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::Value;
|
||||
use rustc_span::def_id::LocalDefId;
|
||||
|
@ -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::ty::subst::{GenericArg, SubstsRef};
|
||||
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 std::cmp::Ordering;
|
||||
|
@ -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::{InstantiationMode, MonoItem};
|
||||
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 super::PartitioningCx;
|
||||
|
@ -13,7 +13,7 @@ use rustc_hir::{Node, PatKind, TyKind};
|
||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
use rustc_middle::middle::privacy::Level;
|
||||
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_span::symbol::{sym, Symbol};
|
||||
use std::mem;
|
||||
|
@ -4,7 +4,7 @@ use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID, LOCAL_CRATE};
|
||||
use rustc_hir::{ItemId, Node, CRATE_HIR_ID};
|
||||
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::parse::feature_err;
|
||||
use rustc_span::symbol::sym;
|
||||
|
@ -5,7 +5,7 @@ use rustc_hir::intravisit;
|
||||
use rustc_hir::{HirId, ItemLocalId};
|
||||
use rustc_index::bit_set::GrowableBitSet;
|
||||
use rustc_middle::hir::nested_filter;
|
||||
use rustc_middle::ty::{DefIdTree, TyCtxt};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
|
||||
pub fn check_crate(tcx: TyCtxt<'_>) {
|
||||
tcx.dep_graph.assert_ignored();
|
||||
|
@ -95,7 +95,7 @@ use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_hir::{Expr, HirId, HirIdMap, HirIdSet};
|
||||
use rustc_index::vec::IndexVec;
|
||||
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_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::{BytePos, Span};
|
||||
|
@ -14,7 +14,7 @@ use rustc_hir::Node;
|
||||
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
|
||||
use rustc_middle::middle::privacy::{self, Level};
|
||||
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_target::spec::abi::Abi;
|
||||
|
||||
|
@ -29,7 +29,7 @@ use rustc_middle::middle::privacy::{EffectiveVisibilities, Level};
|
||||
use rustc_middle::span_bug;
|
||||
use rustc_middle::ty::query::Providers;
|
||||
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_session::lint;
|
||||
use rustc_span::hygiene::Transparency;
|
||||
|
@ -25,9 +25,8 @@ use rustc_expand::expand::AstFragment;
|
||||
use rustc_hir::def::{self, *};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID};
|
||||
use rustc_metadata::creader::LoadedMacro;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::metadata::ModChild;
|
||||
use rustc_middle::ty::{self, DefIdTree};
|
||||
use rustc_middle::{bug, ty};
|
||||
use rustc_session::cstore::CrateStore;
|
||||
use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind};
|
||||
use rustc_span::source_map::respan;
|
||||
@ -99,7 +98,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
loop {
|
||||
match self.get_module(def_id) {
|
||||
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
|
||||
.try_resolve_visibility(&field.vis, false)
|
||||
.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;
|
||||
}
|
||||
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
|
||||
&& matches!(item.vis.kind, ast::VisibilityKind::Inherited)
|
||||
&& self
|
||||
.r
|
||||
.trait_impl_items
|
||||
.contains(&ty::DefIdTree::local_parent(&*self.r, local_def_id)))
|
||||
&& self.r.trait_impl_items.contains(&self.r.tcx.local_parent(local_def_id)))
|
||||
{
|
||||
// Trait impl item visibility is inherited from its trait when not specified
|
||||
// explicitly. In that case we cannot determine it here in early resolve,
|
||||
|
@ -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::PrimTy;
|
||||
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::MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS;
|
||||
use rustc_session::lint::BuiltinLintDiagnostics;
|
||||
@ -1197,7 +1197,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
segms.push(ast::PathSegment::from_ident(ident));
|
||||
let path = Path { span: name_binding.span, segments: segms, tokens: None };
|
||||
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(),
|
||||
};
|
||||
|
||||
@ -1591,7 +1591,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
ctor_def_id,
|
||||
)) = 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)?;
|
||||
return fields.iter().map(|name| name.span).reduce(Span::to); // None for `struct Foo()`
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_hir::def_id::CRATE_DEF_ID;
|
||||
use rustc_middle::middle::privacy::Level;
|
||||
use rustc_middle::middle::privacy::{EffectiveVisibilities, EffectiveVisibility};
|
||||
use rustc_middle::ty::{DefIdTree, Visibility};
|
||||
use rustc_middle::ty::Visibility;
|
||||
use std::mem;
|
||||
|
||||
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.
|
||||
let normal_mod_id = self.nearest_normal_mod(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 {
|
||||
Visibility::Restricted(normal_mod_id)
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
import: &'a Import<'a>,
|
||||
) -> &'a NameBinding<'a> {
|
||||
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)
|
||||
{
|
||||
import_vis
|
||||
@ -255,7 +255,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
|
||||
if let ImportKind::Glob { ref max_vis, .. } = import.kind {
|
||||
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()))
|
||||
}
|
||||
@ -294,7 +294,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
old_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.
|
||||
resolution.binding = Some(binding);
|
||||
}
|
||||
@ -786,7 +786,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
}
|
||||
if !is_prelude
|
||||
&& 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";
|
||||
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;
|
||||
self.per_ns(|this, ns| {
|
||||
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));
|
||||
if let ty::Visibility::Restricted(binding_def_id) = binding.vis {
|
||||
if binding_def_id.is_top_level_module() {
|
||||
|
@ -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::{BindingAnnotation, PrimTy, TraitCandidate};
|
||||
use rustc_middle::middle::resolve_bound_vars::Set1;
|
||||
use rustc_middle::ty::DefIdTree;
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_session::config::{CrateType, ResolveDocLinks};
|
||||
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,
|
||||
// which may need lifetime elision performed.
|
||||
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::Variant, def_id) if i + 1 == proj_start => self.r.parent(def_id),
|
||||
Res::Def(DefKind::AssocTy, def_id) if i + 2 == proj_start => {
|
||||
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::Union, def_id)
|
||||
| Res::Def(DefKind::Enum, def_id)
|
||||
|
@ -21,7 +21,6 @@ use rustc_hir::def::Namespace::{self, *};
|
||||
use rustc_hir::def::{self, CtorKind, CtorOf, DefKind};
|
||||
use rustc_hir::def_id::{DefId, CRATE_DEF_ID, LOCAL_CRATE};
|
||||
use rustc_hir::PrimTy;
|
||||
use rustc_middle::ty::DefIdTree;
|
||||
use rustc_session::lint;
|
||||
use rustc_session::parse::feature_err;
|
||||
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 => {
|
||||
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) {
|
||||
err.span_label(span, &format!("`{}` defined here", path_str));
|
||||
}
|
||||
@ -1999,7 +1998,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
||||
}
|
||||
} else {
|
||||
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());
|
||||
match kind {
|
||||
CtorKind::Const => false,
|
||||
|
@ -44,7 +44,7 @@ use rustc_metadata::creader::{CStore, CrateLoader};
|
||||
use rustc_middle::metadata::ModChild;
|
||||
use rustc_middle::middle::privacy::EffectiveVisibilities;
|
||||
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_query_system::ich::StableHashingContext;
|
||||
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> {
|
||||
fn opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId> {
|
||||
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>>,
|
||||
module: Module<'a>,
|
||||
) -> 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>) {
|
||||
|
@ -30,7 +30,7 @@ use rustc_middle::hir::map;
|
||||
use rustc_middle::ty::error::TypeError::{self, Sorts};
|
||||
use rustc_middle::ty::relate::TypeRelation;
|
||||
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,
|
||||
IsSuggestable, ToPredicate, Ty, TyCtxt, TypeAndMut, TypeFoldable, TypeFolder,
|
||||
TypeSuperFoldable, TypeVisitableExt, TypeckResults,
|
||||
|
@ -28,7 +28,7 @@ use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_middle::ty::fold::TypeFoldable;
|
||||
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_span::def_id::{DefId, CRATE_DEF_ID};
|
||||
use rustc_span::Span;
|
||||
|
@ -32,7 +32,6 @@ use rustc_infer::traits::ImplSourceBuiltinData;
|
||||
use rustc_middle::traits::select::OverflowError;
|
||||
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
|
||||
use rustc_middle::ty::visit::{MaxUniverse, TypeVisitable, TypeVisitableExt};
|
||||
use rustc_middle::ty::DefIdTree;
|
||||
use rustc_middle::ty::{self, Term, ToPredicate, Ty, TyCtxt};
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
|
@ -58,9 +58,7 @@ mod rustc {
|
||||
use rustc_middle::ty;
|
||||
|
||||
let parent = if let ty::Adt(adt_def, ..) = scope.kind() {
|
||||
use rustc_middle::ty::DefIdTree;
|
||||
let parent = self.parent(adt_def.did());
|
||||
parent
|
||||
self.parent(adt_def.did())
|
||||
} else {
|
||||
// Is this always how we want to handle a non-ADT scope?
|
||||
return false;
|
||||
|
@ -4,7 +4,7 @@ use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::definitions::DefPathData;
|
||||
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;
|
||||
|
||||
pub fn provide(providers: &mut ty::query::Providers) {
|
||||
|
@ -1,4 +1,3 @@
|
||||
use crate::rustc_middle::ty::DefIdTree;
|
||||
use rustc_hir::{def::DefKind, def_id::DefId};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
|
||||
|
@ -25,7 +25,7 @@ use rustc_middle::middle::resolve_bound_vars as rbv;
|
||||
use rustc_middle::ty::fold::TypeFolder;
|
||||
use rustc_middle::ty::InternalSubsts;
|
||||
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_span::hygiene::{AstPass, MacroKind};
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
|
@ -22,7 +22,7 @@ use rustc_hir::{BodyId, Mutability};
|
||||
use rustc_hir_analysis::check::intrinsic::intrinsic_operation_unsafety;
|
||||
use rustc_index::vec::IndexVec;
|
||||
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_session::Session;
|
||||
use rustc_span::hygiene::MacroKind;
|
||||
|
@ -17,7 +17,7 @@ use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::ConstValue;
|
||||
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 std::fmt::Write as _;
|
||||
use std::mem;
|
||||
|
@ -19,7 +19,6 @@ use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_metadata::creader::{CStore, LoadedMacro};
|
||||
use rustc_middle::ty;
|
||||
use rustc_middle::ty::DefIdTree;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_span::symbol::kw;
|
||||
use rustc_span::{sym, Symbol};
|
||||
|
@ -8,7 +8,6 @@ use crate::visit::DocVisitor;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::builtin::MISSING_DOCS;
|
||||
use rustc_middle::lint::LintLevelSource;
|
||||
use rustc_middle::ty::DefIdTree;
|
||||
use rustc_session::lint;
|
||||
use rustc_span::FileName;
|
||||
use serde::Serialize;
|
||||
|
@ -14,7 +14,6 @@ use crate::visit::DocVisitor;
|
||||
use crate::visit_ast::inherits_doc_hidden;
|
||||
use rustc_hir as hir;
|
||||
use rustc_middle::lint::LintLevelSource;
|
||||
use rustc_middle::ty::DefIdTree;
|
||||
use rustc_session::lint;
|
||||
|
||||
pub(crate) const CHECK_DOC_TEST_VISIBILITY: Pass = Pass {
|
||||
|
@ -13,7 +13,7 @@ use rustc_hir::def::Namespace::*;
|
||||
use rustc_hir::def::{DefKind, Namespace, PerNS};
|
||||
use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
|
||||
use rustc_hir::Mutability;
|
||||
use rustc_middle::ty::{DefIdTree, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{Ty, TyCtxt};
|
||||
use rustc_middle::{bug, ty};
|
||||
use rustc_resolve::rustdoc::MalformedGenerics;
|
||||
use rustc_resolve::rustdoc::{prepare_to_doc_link_resolution, strip_generics_from_path};
|
||||
|
@ -9,7 +9,7 @@ use crate::visit::DocVisitor;
|
||||
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
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;
|
||||
|
||||
pub(crate) const COLLECT_TRAIT_IMPLS: Pass = Pass {
|
||||
|
@ -9,7 +9,6 @@ use crate::fold::DocFolder;
|
||||
use crate::passes::Pass;
|
||||
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_middle::ty::DefIdTree;
|
||||
|
||||
pub(crate) const PROPAGATE_DOC_CFG: Pass = Pass {
|
||||
name: "propagate-doc-cfg",
|
||||
|
@ -8,7 +8,7 @@ use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId, LocalDefIdSet};
|
||||
use rustc_hir::intravisit::{walk_item, Visitor};
|
||||
use rustc_hir::{Node, CRATE_HIR_ID};
|
||||
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::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::Span;
|
||||
|
@ -8,7 +8,7 @@ use rustc_hir::{
|
||||
Body, Expr, ExprKind, GenericArg, Impl, ImplItemKind, Item, ItemKind, Node, PathSegment, QPath, Ty, TyKind,
|
||||
};
|
||||
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_span::sym;
|
||||
|
||||
|
@ -9,7 +9,7 @@ use rustc_errors::Applicability;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::{Expr, Pat, PatKind};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ty::{self, DefIdTree};
|
||||
use rustc_middle::ty;
|
||||
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
|
||||
|
@ -8,7 +8,6 @@ use rustc_errors::Applicability;
|
||||
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
|
||||
use rustc_hir::{self as hir, Expr, ExprKind, QPath};
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
|
||||
use rustc_middle::ty::DefIdTree;
|
||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||
use rustc_span::def_id::{DefId, LocalDefId};
|
||||
use rustc_span::{sym, Span};
|
||||
|
@ -10,7 +10,6 @@ use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::LangItem::{OptionNone, ResultErr};
|
||||
use rustc_hir::{Arm, Expr, PatKind};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ty::DefIdTree;
|
||||
use rustc_span::sym;
|
||||
|
||||
use super::MANUAL_UNWRAP_OR;
|
||||
|
@ -12,7 +12,7 @@ use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::LangItem::{self, OptionNone, OptionSome, PollPending, PollReady, ResultErr, ResultOk};
|
||||
use rustc_hir::{Arm, Expr, ExprKind, Node, Pat, PatKind, QPath, UnOp};
|
||||
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};
|
||||
|
||||
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||
|
@ -8,7 +8,6 @@ use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
|
||||
use rustc_hir::{LangItem, QPath};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ty::DefIdTree;
|
||||
use rustc_span::Span;
|
||||
|
||||
pub(crate) struct OptionAndThenSome;
|
||||
|
@ -6,7 +6,7 @@ use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::LateContext;
|
||||
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.
|
||||
pub(super) fn check(
|
||||
|
@ -6,7 +6,6 @@ use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::LangItem::{OptionNone, OptionSome};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ty::DefIdTree;
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
use super::OPTION_MAP_OR_NONE;
|
||||
|
@ -13,7 +13,7 @@ use if_chain::if_chain;
|
||||
use rustc_ast::ast::{self, MetaItem, MetaItemKind};
|
||||
use rustc_hir as hir;
|
||||
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_span::def_id::CRATE_DEF_ID;
|
||||
use rustc_span::source_map::Span;
|
||||
|
@ -6,7 +6,6 @@ use rustc_errors::Applicability;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::{AsyncGeneratorKind, Block, Body, Expr, ExprKind, GeneratorKind, LangItem, MatchSource, QPath};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty::DefIdTree;
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
|
||||
declare_clippy_lint! {
|
||||
|
@ -2,7 +2,6 @@ use clippy_utils::diagnostics::span_lint_and_help;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{def::Res, HirId, Path, PathSegment};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty::DefIdTree;
|
||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||
use rustc_span::{sym, symbol::kw, Span};
|
||||
|
||||
|
@ -11,7 +11,7 @@ use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{BinOpKind, Expr, ExprKind, UnOp};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
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_span::symbol::Symbol;
|
||||
|
||||
|
@ -11,7 +11,7 @@ use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{Expr, ExprKind, Local, Mutability, Node};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
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_span::symbol::Symbol;
|
||||
use rustc_span::Span;
|
||||
|
@ -104,7 +104,7 @@ use rustc_middle::ty::fast_reject::SimplifiedType::{
|
||||
PtrSimplifiedType, SliceSimplifiedType, StrSimplifiedType, UintSimplifiedType,
|
||||
};
|
||||
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_span::hygiene::{ExpnKind, MacroKind};
|
||||
|
@ -16,7 +16,7 @@ use rustc_infer::infer::{
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::mir::interpret::{ConstValue, Scalar};
|
||||
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,
|
||||
TypeVisitor, UintTy, VariantDef, VariantDiscr,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user