Add of_trait
to DefKind::Impl.
This commit is contained in:
parent
9bb6e60d1f
commit
03dff82d59
28 changed files with 68 additions and 64 deletions
|
@ -1182,13 +1182,13 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let parent_did = tcx.parent(method_did);
|
let parent_did = tcx.parent(method_did);
|
||||||
let parent_self_ty = (tcx.def_kind(parent_did)
|
let parent_self_ty =
|
||||||
== rustc_hir::def::DefKind::Impl)
|
matches!(tcx.def_kind(parent_did), rustc_hir::def::DefKind::Impl { .. })
|
||||||
.then_some(parent_did)
|
.then_some(parent_did)
|
||||||
.and_then(|did| match tcx.type_of(did).kind() {
|
.and_then(|did| match tcx.type_of(did).kind() {
|
||||||
ty::Adt(def, ..) => Some(def.did()),
|
ty::Adt(def, ..) => Some(def.did()),
|
||||||
_ => None,
|
_ => None,
|
||||||
});
|
});
|
||||||
let is_option_or_result = parent_self_ty.map_or(false, |def_id| {
|
let is_option_or_result = parent_self_ty.map_or(false, |def_id| {
|
||||||
matches!(tcx.get_diagnostic_name(def_id), Some(sym::Option | sym::Result))
|
matches!(tcx.get_diagnostic_name(def_id), Some(sym::Option | sym::Result))
|
||||||
});
|
});
|
||||||
|
|
|
@ -852,9 +852,9 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
||||||
|
|
||||||
let tcx = self.infcx.tcx;
|
let tcx = self.infcx.tcx;
|
||||||
let region_parent = tcx.parent(region.def_id);
|
let region_parent = tcx.parent(region.def_id);
|
||||||
if tcx.def_kind(region_parent) != DefKind::Impl {
|
let DefKind::Impl { .. } = tcx.def_kind(region_parent) else {
|
||||||
return None;
|
return None;
|
||||||
}
|
};
|
||||||
|
|
||||||
let found = tcx
|
let found = tcx
|
||||||
.any_free_region_meets(&tcx.type_of(region_parent), |r| *r == ty::ReEarlyBound(region));
|
.any_free_region_meets(&tcx.type_of(region_parent), |r| *r == ty::ReEarlyBound(region));
|
||||||
|
|
|
@ -17,7 +17,8 @@ pub fn is_unstable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Symbol> {
|
||||||
|
|
||||||
pub fn is_parent_const_impl_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
|
pub fn is_parent_const_impl_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
|
||||||
let parent_id = tcx.local_parent(def_id);
|
let parent_id = tcx.local_parent(def_id);
|
||||||
tcx.def_kind(parent_id) == DefKind::Impl && tcx.constness(parent_id) == hir::Constness::Const
|
matches!(tcx.def_kind(parent_id), DefKind::Impl { .. })
|
||||||
|
&& tcx.constness(parent_id) == hir::Constness::Const
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks whether an item is considered to be `const`. If it is a constructor, it is const. If
|
/// Checks whether an item is considered to be `const`. If it is a constructor, it is const. If
|
||||||
|
|
|
@ -116,7 +116,9 @@ pub enum DefKind {
|
||||||
LifetimeParam,
|
LifetimeParam,
|
||||||
/// A use of `global_asm!`.
|
/// A use of `global_asm!`.
|
||||||
GlobalAsm,
|
GlobalAsm,
|
||||||
Impl,
|
Impl {
|
||||||
|
of_trait: bool,
|
||||||
|
},
|
||||||
Closure,
|
Closure,
|
||||||
Generator,
|
Generator,
|
||||||
}
|
}
|
||||||
|
@ -155,7 +157,7 @@ impl DefKind {
|
||||||
DefKind::AnonConst => "constant expression",
|
DefKind::AnonConst => "constant expression",
|
||||||
DefKind::InlineConst => "inline constant",
|
DefKind::InlineConst => "inline constant",
|
||||||
DefKind::Field => "field",
|
DefKind::Field => "field",
|
||||||
DefKind::Impl => "implementation",
|
DefKind::Impl { .. } => "implementation",
|
||||||
DefKind::Closure => "closure",
|
DefKind::Closure => "closure",
|
||||||
DefKind::Generator => "generator",
|
DefKind::Generator => "generator",
|
||||||
DefKind::ExternCrate => "extern crate",
|
DefKind::ExternCrate => "extern crate",
|
||||||
|
@ -171,7 +173,7 @@ impl DefKind {
|
||||||
| DefKind::AssocFn
|
| DefKind::AssocFn
|
||||||
| DefKind::Enum
|
| DefKind::Enum
|
||||||
| DefKind::OpaqueTy
|
| DefKind::OpaqueTy
|
||||||
| DefKind::Impl
|
| DefKind::Impl { .. }
|
||||||
| DefKind::Use
|
| DefKind::Use
|
||||||
| DefKind::InlineConst
|
| DefKind::InlineConst
|
||||||
| DefKind::ExternCrate => "an",
|
| DefKind::ExternCrate => "an",
|
||||||
|
@ -216,7 +218,7 @@ impl DefKind {
|
||||||
| DefKind::Use
|
| DefKind::Use
|
||||||
| DefKind::ForeignMod
|
| DefKind::ForeignMod
|
||||||
| DefKind::GlobalAsm
|
| DefKind::GlobalAsm
|
||||||
| DefKind::Impl
|
| DefKind::Impl { .. }
|
||||||
| DefKind::ImplTraitPlaceholder => None,
|
| DefKind::ImplTraitPlaceholder => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,7 +257,7 @@ impl DefKind {
|
||||||
| DefKind::ForeignMod
|
| DefKind::ForeignMod
|
||||||
| DefKind::OpaqueTy
|
| DefKind::OpaqueTy
|
||||||
| DefKind::ImplTraitPlaceholder
|
| DefKind::ImplTraitPlaceholder
|
||||||
| DefKind::Impl
|
| DefKind::Impl { .. }
|
||||||
| DefKind::Field
|
| DefKind::Field
|
||||||
| DefKind::TyParam
|
| DefKind::TyParam
|
||||||
| DefKind::ConstParam
|
| DefKind::ConstParam
|
||||||
|
|
|
@ -116,7 +116,7 @@ impl Target {
|
||||||
DefKind::Union => Target::Union,
|
DefKind::Union => Target::Union,
|
||||||
DefKind::Trait => Target::Trait,
|
DefKind::Trait => Target::Trait,
|
||||||
DefKind::TraitAlias => Target::TraitAlias,
|
DefKind::TraitAlias => Target::TraitAlias,
|
||||||
DefKind::Impl => Target::Impl,
|
DefKind::Impl { .. } => Target::Impl,
|
||||||
_ => panic!("impossible case reached"),
|
_ => panic!("impossible case reached"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -529,19 +529,21 @@ fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) {
|
||||||
check_enum(tcx, id.owner_id.def_id);
|
check_enum(tcx, id.owner_id.def_id);
|
||||||
}
|
}
|
||||||
DefKind::Fn => {} // entirely within check_item_body
|
DefKind::Fn => {} // entirely within check_item_body
|
||||||
DefKind::Impl => {
|
DefKind::Impl { of_trait } => {
|
||||||
let it = tcx.hir().item(id);
|
if of_trait {
|
||||||
let hir::ItemKind::Impl(impl_) = it.kind else { return };
|
let it = tcx.hir().item(id);
|
||||||
debug!("ItemKind::Impl {} with id {:?}", it.ident, it.owner_id);
|
let hir::ItemKind::Impl(impl_) = it.kind else { return };
|
||||||
if let Some(impl_trait_ref) = tcx.impl_trait_ref(it.owner_id) {
|
debug!("ItemKind::Impl {} with id {:?}", it.ident, it.owner_id);
|
||||||
check_impl_items_against_trait(
|
if let Some(impl_trait_ref) = tcx.impl_trait_ref(it.owner_id) {
|
||||||
tcx,
|
check_impl_items_against_trait(
|
||||||
it.span,
|
tcx,
|
||||||
it.owner_id.def_id,
|
it.span,
|
||||||
impl_trait_ref.subst_identity(),
|
it.owner_id.def_id,
|
||||||
&impl_.items,
|
impl_trait_ref.subst_identity(),
|
||||||
);
|
&impl_.items,
|
||||||
check_on_unimplemented(tcx, it);
|
);
|
||||||
|
check_on_unimplemented(tcx, it);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DefKind::Trait => {
|
DefKind::Trait => {
|
||||||
|
|
|
@ -177,7 +177,7 @@ impl<'tcx> InherentCollect<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_item(&mut self, id: hir::ItemId) {
|
fn check_item(&mut self, id: hir::ItemId) {
|
||||||
if !matches!(self.tcx.def_kind(id.owner_id), DefKind::Impl) {
|
if !matches!(self.tcx.def_kind(id.owner_id), DefKind::Impl { of_trait: false }) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1563,7 +1563,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
// See issue #83753. If someone writes an associated type on a non-trait, just treat it as
|
// See issue #83753. If someone writes an associated type on a non-trait, just treat it as
|
||||||
// there being no supertrait HRTBs.
|
// there being no supertrait HRTBs.
|
||||||
match tcx.def_kind(def_id) {
|
match tcx.def_kind(def_id) {
|
||||||
DefKind::Trait | DefKind::TraitAlias | DefKind::Impl => {}
|
DefKind::Trait | DefKind::TraitAlias | DefKind::Impl { .. } => {}
|
||||||
_ => break None,
|
_ => break None,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ fn check_mod_impl_wf(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
||||||
let min_specialization = tcx.features().min_specialization;
|
let min_specialization = tcx.features().min_specialization;
|
||||||
let module = tcx.hir_module_items(module_def_id);
|
let module = tcx.hir_module_items(module_def_id);
|
||||||
for id in module.items() {
|
for id in module.items() {
|
||||||
if matches!(tcx.def_kind(id.owner_id), DefKind::Impl) {
|
if matches!(tcx.def_kind(id.owner_id), DefKind::Impl { .. }) {
|
||||||
enforce_impl_params_are_constrained(tcx, id.owner_id.def_id);
|
enforce_impl_params_are_constrained(tcx, id.owner_id.def_id);
|
||||||
if min_specialization {
|
if min_specialization {
|
||||||
check_min_specialization(tcx, id.owner_id.def_id);
|
check_min_specialization(tcx, id.owner_id.def_id);
|
||||||
|
|
|
@ -1061,7 +1061,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let parent_def_id = generics.parent.unwrap();
|
let parent_def_id = generics.parent.unwrap();
|
||||||
if tcx.def_kind(parent_def_id) == DefKind::Impl {
|
if let DefKind::Impl { .. } = tcx.def_kind(parent_def_id) {
|
||||||
let parent_ty = tcx.bound_type_of(parent_def_id).subst(tcx, substs);
|
let parent_ty = tcx.bound_type_of(parent_def_id).subst(tcx, substs);
|
||||||
match (parent_ty.kind(), &ty.kind) {
|
match (parent_ty.kind(), &ty.kind) {
|
||||||
(
|
(
|
||||||
|
|
|
@ -838,7 +838,7 @@ fn should_encode_visibility(def_kind: DefKind) -> bool {
|
||||||
| DefKind::ForeignMod
|
| DefKind::ForeignMod
|
||||||
| DefKind::OpaqueTy
|
| DefKind::OpaqueTy
|
||||||
| DefKind::ImplTraitPlaceholder
|
| DefKind::ImplTraitPlaceholder
|
||||||
| DefKind::Impl
|
| DefKind::Impl { .. }
|
||||||
| DefKind::Field => true,
|
| DefKind::Field => true,
|
||||||
DefKind::TyParam
|
DefKind::TyParam
|
||||||
| DefKind::ConstParam
|
| DefKind::ConstParam
|
||||||
|
@ -873,7 +873,7 @@ fn should_encode_stability(def_kind: DefKind) -> bool {
|
||||||
| DefKind::ImplTraitPlaceholder
|
| DefKind::ImplTraitPlaceholder
|
||||||
| DefKind::Enum
|
| DefKind::Enum
|
||||||
| DefKind::Union
|
| DefKind::Union
|
||||||
| DefKind::Impl
|
| DefKind::Impl { .. }
|
||||||
| DefKind::Trait
|
| DefKind::Trait
|
||||||
| DefKind::TraitAlias
|
| DefKind::TraitAlias
|
||||||
| DefKind::Macro(..)
|
| DefKind::Macro(..)
|
||||||
|
@ -951,7 +951,7 @@ fn should_encode_variances(def_kind: DefKind) -> bool {
|
||||||
| DefKind::Const
|
| DefKind::Const
|
||||||
| DefKind::ForeignMod
|
| DefKind::ForeignMod
|
||||||
| DefKind::TyAlias
|
| DefKind::TyAlias
|
||||||
| DefKind::Impl
|
| DefKind::Impl { .. }
|
||||||
| DefKind::Trait
|
| DefKind::Trait
|
||||||
| DefKind::TraitAlias
|
| DefKind::TraitAlias
|
||||||
| DefKind::Macro(..)
|
| DefKind::Macro(..)
|
||||||
|
@ -988,7 +988,7 @@ fn should_encode_generics(def_kind: DefKind) -> bool {
|
||||||
| DefKind::InlineConst
|
| DefKind::InlineConst
|
||||||
| DefKind::OpaqueTy
|
| DefKind::OpaqueTy
|
||||||
| DefKind::ImplTraitPlaceholder
|
| DefKind::ImplTraitPlaceholder
|
||||||
| DefKind::Impl
|
| DefKind::Impl { .. }
|
||||||
| DefKind::Field
|
| DefKind::Field
|
||||||
| DefKind::TyParam
|
| DefKind::TyParam
|
||||||
| DefKind::Closure
|
| DefKind::Closure
|
||||||
|
@ -1018,7 +1018,7 @@ fn should_encode_type(tcx: TyCtxt<'_>, def_id: LocalDefId, def_kind: DefKind) ->
|
||||||
| DefKind::TyAlias
|
| DefKind::TyAlias
|
||||||
| DefKind::OpaqueTy
|
| DefKind::OpaqueTy
|
||||||
| DefKind::ForeignTy
|
| DefKind::ForeignTy
|
||||||
| DefKind::Impl
|
| DefKind::Impl { .. }
|
||||||
| DefKind::AssocFn
|
| DefKind::AssocFn
|
||||||
| DefKind::AssocConst
|
| DefKind::AssocConst
|
||||||
| DefKind::Closure
|
| DefKind::Closure
|
||||||
|
@ -1081,7 +1081,7 @@ fn should_encode_const(def_kind: DefKind) -> bool {
|
||||||
| DefKind::OpaqueTy
|
| DefKind::OpaqueTy
|
||||||
| DefKind::ImplTraitPlaceholder
|
| DefKind::ImplTraitPlaceholder
|
||||||
| DefKind::ForeignTy
|
| DefKind::ForeignTy
|
||||||
| DefKind::Impl
|
| DefKind::Impl { .. }
|
||||||
| DefKind::AssocFn
|
| DefKind::AssocFn
|
||||||
| DefKind::Closure
|
| DefKind::Closure
|
||||||
| DefKind::Generator
|
| DefKind::Generator
|
||||||
|
@ -1860,7 +1860,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
FxHashMap::default();
|
FxHashMap::default();
|
||||||
|
|
||||||
for id in tcx.hir().items() {
|
for id in tcx.hir().items() {
|
||||||
if matches!(tcx.def_kind(id.owner_id), DefKind::Impl) {
|
if matches!(tcx.def_kind(id.owner_id), DefKind::Impl { .. }) {
|
||||||
if let Some(trait_ref) = tcx.impl_trait_ref(id.owner_id) {
|
if let Some(trait_ref) = tcx.impl_trait_ref(id.owner_id) {
|
||||||
let trait_ref = trait_ref.subst_identity();
|
let trait_ref = trait_ref.subst_identity();
|
||||||
|
|
||||||
|
@ -2261,7 +2261,7 @@ pub fn provide(providers: &mut Providers) {
|
||||||
|
|
||||||
let mut trait_impls = Vec::new();
|
let mut trait_impls = Vec::new();
|
||||||
for id in tcx.hir().items() {
|
for id in tcx.hir().items() {
|
||||||
if matches!(tcx.def_kind(id.owner_id), DefKind::Impl)
|
if matches!(tcx.def_kind(id.owner_id), DefKind::Impl { .. })
|
||||||
&& tcx.impl_trait_ref(id.owner_id).is_some()
|
&& tcx.impl_trait_ref(id.owner_id).is_some()
|
||||||
{
|
{
|
||||||
trait_impls.push(id.owner_id.to_def_id())
|
trait_impls.push(id.owner_id.to_def_id())
|
||||||
|
|
|
@ -136,7 +136,8 @@ fixed_size_enum! {
|
||||||
( Field )
|
( Field )
|
||||||
( LifetimeParam )
|
( LifetimeParam )
|
||||||
( GlobalAsm )
|
( GlobalAsm )
|
||||||
( Impl )
|
( Impl { of_trait: false } )
|
||||||
|
( Impl { of_trait: true } )
|
||||||
( Closure )
|
( Closure )
|
||||||
( Generator )
|
( Generator )
|
||||||
( Static(ast::Mutability::Not) )
|
( Static(ast::Mutability::Not) )
|
||||||
|
|
|
@ -203,7 +203,7 @@ impl<'hir> Map<'hir> {
|
||||||
ItemKind::Use(..) => DefKind::Use,
|
ItemKind::Use(..) => DefKind::Use,
|
||||||
ItemKind::ForeignMod { .. } => DefKind::ForeignMod,
|
ItemKind::ForeignMod { .. } => DefKind::ForeignMod,
|
||||||
ItemKind::GlobalAsm(..) => DefKind::GlobalAsm,
|
ItemKind::GlobalAsm(..) => DefKind::GlobalAsm,
|
||||||
ItemKind::Impl { .. } => DefKind::Impl,
|
ItemKind::Impl(impl_) => DefKind::Impl { of_trait: impl_.of_trait.is_some() },
|
||||||
},
|
},
|
||||||
Node::ForeignItem(item) => match item.kind {
|
Node::ForeignItem(item) => match item.kind {
|
||||||
ForeignItemKind::Fn(..) => DefKind::Fn,
|
ForeignItemKind::Fn(..) => DefKind::Fn,
|
||||||
|
|
|
@ -2427,7 +2427,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
pub fn impl_of_method(self, def_id: DefId) -> Option<DefId> {
|
pub fn impl_of_method(self, def_id: DefId) -> Option<DefId> {
|
||||||
if let DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy = self.def_kind(def_id) {
|
if let DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy = self.def_kind(def_id) {
|
||||||
let parent = self.parent(def_id);
|
let parent = self.parent(def_id);
|
||||||
if let DefKind::Impl = self.def_kind(parent) {
|
if let DefKind::Impl { .. } = self.def_kind(parent) {
|
||||||
return Some(parent);
|
return Some(parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
| DefKind::Fn
|
| DefKind::Fn
|
||||||
| DefKind::AssocFn
|
| DefKind::AssocFn
|
||||||
| DefKind::AssocConst
|
| DefKind::AssocConst
|
||||||
| DefKind::Impl,
|
| DefKind::Impl { .. },
|
||||||
def_id,
|
def_id,
|
||||||
) => Some(def_id),
|
) => Some(def_id),
|
||||||
Res::Err => None,
|
Res::Err => None,
|
||||||
|
|
|
@ -1238,7 +1238,7 @@ impl<'v> RootCollector<'_, 'v> {
|
||||||
collect_const_value(self.tcx, val, &mut self.output);
|
collect_const_value(self.tcx, val, &mut self.output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DefKind::Impl => {
|
DefKind::Impl { .. } => {
|
||||||
if self.mode == MonoItemCollectionMode::Eager {
|
if self.mode == MonoItemCollectionMode::Eager {
|
||||||
let item = self.tcx.hir().item(id);
|
let item = self.tcx.hir().item(id);
|
||||||
create_mono_items_for_default_impls(self.tcx, item, self.output);
|
create_mono_items_for_default_impls(self.tcx, item, self.output);
|
||||||
|
|
|
@ -172,7 +172,7 @@ fn mark_used_by_default_parameters<'tcx>(
|
||||||
| DefKind::Field
|
| DefKind::Field
|
||||||
| DefKind::LifetimeParam
|
| DefKind::LifetimeParam
|
||||||
| DefKind::GlobalAsm
|
| DefKind::GlobalAsm
|
||||||
| DefKind::Impl => {
|
| DefKind::Impl { .. } => {
|
||||||
for param in &generics.params {
|
for param in &generics.params {
|
||||||
debug!(?param, "(other)");
|
debug!(?param, "(other)");
|
||||||
if let ty::GenericParamDefKind::Lifetime = param.kind {
|
if let ty::GenericParamDefKind::Lifetime = param.kind {
|
||||||
|
|
|
@ -526,10 +526,8 @@ fn check_item<'tcx>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DefKind::Impl => {
|
DefKind::Impl { of_trait } => {
|
||||||
let of_trait = tcx.impl_trait_ref(id.owner_id);
|
if of_trait {
|
||||||
|
|
||||||
if of_trait.is_some() {
|
|
||||||
worklist.push(id.owner_id.def_id);
|
worklist.push(id.owner_id.def_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,7 +539,7 @@ fn check_item<'tcx>(
|
||||||
|
|
||||||
// And we access the Map here to get HirId from LocalDefId
|
// And we access the Map here to get HirId from LocalDefId
|
||||||
for id in local_def_ids {
|
for id in local_def_ids {
|
||||||
if of_trait.is_some() || has_allow_dead_code_or_lang_attr(tcx, id) {
|
if of_trait || has_allow_dead_code_or_lang_attr(tcx, id) {
|
||||||
worklist.push(id);
|
worklist.push(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,7 +145,7 @@ fn check_liveness(tcx: TyCtxt<'_>, def_id: DefId) {
|
||||||
|
|
||||||
// Don't run unused pass for #[derive()]
|
// Don't run unused pass for #[derive()]
|
||||||
let parent = tcx.local_parent(local_def_id);
|
let parent = tcx.local_parent(local_def_id);
|
||||||
if let DefKind::Impl = tcx.def_kind(parent)
|
if let DefKind::Impl { .. } = tcx.def_kind(parent)
|
||||||
&& tcx.has_attr(parent.to_def_id(), sym::automatically_derived)
|
&& tcx.has_attr(parent.to_def_id(), sym::automatically_derived)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -320,7 +320,7 @@ fn check_item<'tcx>(
|
||||||
worklist.push(id.owner_id.def_id);
|
worklist.push(id.owner_id.def_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if !matches!(tcx.def_kind(id.owner_id), DefKind::Impl) {
|
if !matches!(tcx.def_kind(id.owner_id), DefKind::Impl { of_trait: true }) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -593,7 +593,7 @@ impl<'tcx> EmbargoVisitor<'tcx> {
|
||||||
| DefKind::InlineConst
|
| DefKind::InlineConst
|
||||||
| DefKind::Field
|
| DefKind::Field
|
||||||
| DefKind::GlobalAsm
|
| DefKind::GlobalAsm
|
||||||
| DefKind::Impl
|
| DefKind::Impl { .. }
|
||||||
| DefKind::Closure
|
| DefKind::Closure
|
||||||
| DefKind::Generator => (),
|
| DefKind::Generator => (),
|
||||||
}
|
}
|
||||||
|
@ -1997,7 +1997,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'tcx> {
|
||||||
// Subitems of inherent impls have their own publicity.
|
// Subitems of inherent impls have their own publicity.
|
||||||
// A trait impl is public when both its type and its trait are public
|
// A trait impl is public when both its type and its trait are public
|
||||||
// Subitems of trait impls have inherited publicity.
|
// Subitems of trait impls have inherited publicity.
|
||||||
DefKind::Impl => {
|
DefKind::Impl { .. } => {
|
||||||
let item = tcx.hir().item(id);
|
let item = tcx.hir().item(id);
|
||||||
if let hir::ItemKind::Impl(ref impl_) = item.kind {
|
if let hir::ItemKind::Impl(ref impl_) = item.kind {
|
||||||
let impl_vis =
|
let impl_vis =
|
||||||
|
|
|
@ -987,7 +987,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
||||||
| DefKind::LifetimeParam
|
| DefKind::LifetimeParam
|
||||||
| DefKind::GlobalAsm
|
| DefKind::GlobalAsm
|
||||||
| DefKind::Closure
|
| DefKind::Closure
|
||||||
| DefKind::Impl
|
| DefKind::Impl { .. }
|
||||||
| DefKind::Generator,
|
| DefKind::Generator,
|
||||||
_,
|
_,
|
||||||
)
|
)
|
||||||
|
|
|
@ -733,7 +733,7 @@ impl<'tcx> SaveContext<'tcx> {
|
||||||
| HirDefKind::Use
|
| HirDefKind::Use
|
||||||
| HirDefKind::Field
|
| HirDefKind::Field
|
||||||
| HirDefKind::GlobalAsm
|
| HirDefKind::GlobalAsm
|
||||||
| HirDefKind::Impl
|
| HirDefKind::Impl { .. }
|
||||||
| HirDefKind::Closure
|
| HirDefKind::Closure
|
||||||
| HirDefKind::Generator,
|
| HirDefKind::Generator,
|
||||||
_,
|
_,
|
||||||
|
|
|
@ -21,7 +21,7 @@ fn assumed_wf_types(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::List<Ty<'_>> {
|
||||||
assumed_wf_types.extend(liberated_sig.inputs_and_output);
|
assumed_wf_types.extend(liberated_sig.inputs_and_output);
|
||||||
tcx.intern_type_list(&assumed_wf_types)
|
tcx.intern_type_list(&assumed_wf_types)
|
||||||
}
|
}
|
||||||
DefKind::Impl => {
|
DefKind::Impl { .. } => {
|
||||||
match tcx.impl_trait_ref(def_id) {
|
match tcx.impl_trait_ref(def_id) {
|
||||||
Some(trait_ref) => {
|
Some(trait_ref) => {
|
||||||
let types: Vec<_> = trait_ref.skip_binder().substs.types().collect();
|
let types: Vec<_> = trait_ref.skip_binder().substs.types().collect();
|
||||||
|
|
|
@ -140,7 +140,7 @@ impl From<DefKind> for ItemType {
|
||||||
| DefKind::Field
|
| DefKind::Field
|
||||||
| DefKind::LifetimeParam
|
| DefKind::LifetimeParam
|
||||||
| DefKind::GlobalAsm
|
| DefKind::GlobalAsm
|
||||||
| DefKind::Impl
|
| DefKind::Impl { .. }
|
||||||
| DefKind::Closure
|
| DefKind::Closure
|
||||||
| DefKind::Generator => Self::ForeignType,
|
| DefKind::Generator => Self::ForeignType,
|
||||||
}
|
}
|
||||||
|
|
|
@ -359,7 +359,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
|
||||||
_ => def_id,
|
_ => def_id,
|
||||||
})
|
})
|
||||||
.and_then(|self_id| match tcx.def_kind(self_id) {
|
.and_then(|self_id| match tcx.def_kind(self_id) {
|
||||||
DefKind::Impl => self.def_id_to_res(self_id),
|
DefKind::Impl { .. } => self.def_id_to_res(self_id),
|
||||||
DefKind::Use => None,
|
DefKind::Use => None,
|
||||||
def_kind => Some(Res::Def(def_kind, self_id)),
|
def_kind => Some(Res::Def(def_kind, self_id)),
|
||||||
})
|
})
|
||||||
|
@ -1761,7 +1761,7 @@ fn resolution_failure(
|
||||||
}
|
}
|
||||||
Trait | TyAlias | ForeignTy | OpaqueTy | ImplTraitPlaceholder
|
Trait | TyAlias | ForeignTy | OpaqueTy | ImplTraitPlaceholder
|
||||||
| TraitAlias | TyParam | Static(_) => "associated item",
|
| TraitAlias | TyParam | Static(_) => "associated item",
|
||||||
Impl | GlobalAsm => unreachable!("not a path"),
|
Impl { .. } | GlobalAsm => unreachable!("not a path"),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
"associated item"
|
"associated item"
|
||||||
|
|
|
@ -52,7 +52,7 @@ impl<'tcx> LateLintPass<'tcx> for SameNameMethod {
|
||||||
let mut map = FxHashMap::<Res, ExistingName>::default();
|
let mut map = FxHashMap::<Res, ExistingName>::default();
|
||||||
|
|
||||||
for id in cx.tcx.hir().items() {
|
for id in cx.tcx.hir().items() {
|
||||||
if matches!(cx.tcx.def_kind(id.owner_id), DefKind::Impl)
|
if matches!(cx.tcx.def_kind(id.owner_id), DefKind::Impl { .. })
|
||||||
&& let item = cx.tcx.hir().item(id)
|
&& let item = cx.tcx.hir().item(id)
|
||||||
&& let ItemKind::Impl(Impl {
|
&& let ItemKind::Impl(Impl {
|
||||||
items,
|
items,
|
||||||
|
|
|
@ -552,7 +552,7 @@ fn non_local_item_children_by_name(tcx: TyCtxt<'_>, def_id: DefId, name: Symbol)
|
||||||
.filter(|item| item.ident.name == name)
|
.filter(|item| item.ident.name == name)
|
||||||
.map(|child| child.res.expect_non_local())
|
.map(|child| child.res.expect_non_local())
|
||||||
.collect(),
|
.collect(),
|
||||||
DefKind::Impl => tcx
|
DefKind::Impl { .. } => tcx
|
||||||
.associated_item_def_ids(def_id)
|
.associated_item_def_ids(def_id)
|
||||||
.iter()
|
.iter()
|
||||||
.copied()
|
.copied()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue