Rollup merge of #112165 - fee1-dead-contrib:rn-defualtness, r=compiler-errors
Rename `impl_defaultness` to `defaultness` Since this isn't just about the `impl`.
This commit is contained in:
commit
f121f77d8a
@ -704,7 +704,7 @@ pub(super) fn check_specialization_validity<'tcx>(
|
||||
// grandparent. In that case, if parent is a `default impl`, inherited items use the
|
||||
// "defaultness" from the grandparent, else they are final.
|
||||
None => {
|
||||
if tcx.impl_defaultness(parent_impl.def_id()).is_default() {
|
||||
if tcx.defaultness(parent_impl.def_id()).is_default() {
|
||||
None
|
||||
} else {
|
||||
Some(Err(parent_impl.def_id()))
|
||||
@ -803,7 +803,7 @@ fn check_impl_items_against_trait<'tcx>(
|
||||
.as_ref()
|
||||
.is_some_and(|node_item| node_item.item.defaultness(tcx).has_value());
|
||||
|
||||
if !is_implemented && tcx.impl_defaultness(impl_id).is_final() {
|
||||
if !is_implemented && tcx.defaultness(impl_id).is_final() {
|
||||
missing_items.push(tcx.associated_item(trait_item_id));
|
||||
}
|
||||
|
||||
|
@ -941,7 +941,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
|
||||
|
||||
match item {
|
||||
Some(item) if matches!(item.kind, hir::AssocItemKind::Fn { .. }) => {
|
||||
if !tcx.impl_defaultness(item.id.owner_id).has_value() {
|
||||
if !tcx.defaultness(item.id.owner_id).has_value() {
|
||||
tcx.sess.emit_err(errors::FunctionNotHaveDefaultImplementation {
|
||||
span: item.span,
|
||||
note_span: attr_span,
|
||||
|
@ -435,7 +435,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<Ty
|
||||
in_trait,
|
||||
..
|
||||
}) => {
|
||||
if in_trait && !tcx.impl_defaultness(owner).has_value() {
|
||||
if in_trait && !tcx.defaultness(owner).has_value() {
|
||||
span_bug!(
|
||||
tcx.def_span(def_id),
|
||||
"tried to get type of this RPITIT with no definition"
|
||||
|
@ -586,7 +586,7 @@ fn point_at_associated_type(
|
||||
// FIXME: account for returning some type in a trait fn impl that has
|
||||
// an assoc type as a return type (#72076).
|
||||
if let hir::Defaultness::Default { has_value: true } =
|
||||
tcx.impl_defaultness(item.id.owner_id)
|
||||
tcx.defaultness(item.id.owner_id)
|
||||
{
|
||||
let assoc_ty = tcx.type_of(item.id.owner_id).subst_identity();
|
||||
if self.infcx.can_eq(param_env, assoc_ty, found) {
|
||||
|
@ -231,7 +231,7 @@ fn into_args(self) -> (DefId, SimplifiedType) {
|
||||
opt_def_kind => { table_direct }
|
||||
impl_parent => { table }
|
||||
impl_polarity => { table_direct }
|
||||
impl_defaultness => { table_direct }
|
||||
defaultness => { table_direct }
|
||||
constness => { table_direct }
|
||||
coerce_unsized_info => { table }
|
||||
mir_const_qualif => { table }
|
||||
|
@ -1437,8 +1437,8 @@ fn encode_info_for_trait_item(&mut self, def_id: DefId) {
|
||||
debug!("EncodeContext::encode_info_for_trait_item({:?})", def_id);
|
||||
let tcx = self.tcx;
|
||||
|
||||
let impl_defaultness = tcx.impl_defaultness(def_id.expect_local());
|
||||
self.tables.impl_defaultness.set_some(def_id.index, impl_defaultness);
|
||||
let defaultness = tcx.defaultness(def_id.expect_local());
|
||||
self.tables.defaultness.set_some(def_id.index, defaultness);
|
||||
let trait_item = tcx.associated_item(def_id);
|
||||
self.tables.assoc_container.set_some(def_id.index, trait_item.container);
|
||||
|
||||
@ -1466,8 +1466,8 @@ fn encode_info_for_impl_item(&mut self, def_id: DefId) {
|
||||
debug!("EncodeContext::encode_info_for_impl_item({:?})", def_id);
|
||||
let tcx = self.tcx;
|
||||
|
||||
let defaultness = self.tcx.impl_defaultness(def_id.expect_local());
|
||||
self.tables.impl_defaultness.set_some(def_id.index, defaultness);
|
||||
let defaultness = self.tcx.defaultness(def_id.expect_local());
|
||||
self.tables.defaultness.set_some(def_id.index, defaultness);
|
||||
let impl_item = self.tcx.associated_item(def_id);
|
||||
self.tables.assoc_container.set_some(def_id.index, impl_item.container);
|
||||
|
||||
@ -1653,7 +1653,7 @@ fn encode_info_for_item(&mut self, item: &'tcx hir::Item<'tcx>) {
|
||||
);
|
||||
}
|
||||
hir::ItemKind::Impl(hir::Impl { defaultness, constness, .. }) => {
|
||||
self.tables.impl_defaultness.set_some(def_id.index, *defaultness);
|
||||
self.tables.defaultness.set_some(def_id.index, *defaultness);
|
||||
self.tables.constness.set_some(def_id.index, *constness);
|
||||
self.tables.impl_polarity.set_some(def_id.index, self.tcx.impl_polarity(def_id));
|
||||
|
||||
|
@ -420,7 +420,7 @@ fn encode(&self, buf: &mut FileEncoder) -> LazyTables {
|
||||
impl_parent: Table<DefIndex, RawDefId>,
|
||||
impl_polarity: Table<DefIndex, ty::ImplPolarity>,
|
||||
constness: Table<DefIndex, hir::Constness>,
|
||||
impl_defaultness: Table<DefIndex, hir::Defaultness>,
|
||||
defaultness: Table<DefIndex, hir::Defaultness>,
|
||||
// FIXME(eddyb) perhaps compute this on the fly if cheap enough?
|
||||
coerce_unsized_info: Table<DefIndex, LazyValue<ty::adjustment::CoerceUnsizedInfo>>,
|
||||
mir_const_qualif: Table<DefIndex, LazyValue<mir::ConstQualifs>>,
|
||||
|
@ -1475,8 +1475,9 @@
|
||||
desc { "getting traits in scope at a block" }
|
||||
}
|
||||
|
||||
query impl_defaultness(def_id: DefId) -> hir::Defaultness {
|
||||
desc { |tcx| "looking up whether `{}` is a default impl", tcx.def_path_str(def_id) }
|
||||
/// Returns whether the impl or associated function has the `default` keyword.
|
||||
query defaultness(def_id: DefId) -> hir::Defaultness {
|
||||
desc { |tcx| "looking up whether `{}` has `default`", tcx.def_path_str(def_id) }
|
||||
separate_provide_extern
|
||||
feedable
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ pub fn leaf_def(mut self, tcx: TyCtxt<'tcx>, trait_item_def_id: DefId) -> Option
|
||||
if let Some(item) = node.item(tcx, trait_item_def_id) {
|
||||
if finalizing_node.is_none() {
|
||||
let is_specializable = item.defaultness(tcx).is_default()
|
||||
|| tcx.impl_defaultness(node.def_id()).is_default();
|
||||
|| tcx.defaultness(node.def_id()).is_default();
|
||||
|
||||
if !is_specializable {
|
||||
finalizing_node = Some(node);
|
||||
|
@ -48,7 +48,7 @@ pub fn ident(&self, tcx: TyCtxt<'_>) -> Ident {
|
||||
///
|
||||
/// [`type_of`]: crate::ty::TyCtxt::type_of
|
||||
pub fn defaultness(&self, tcx: TyCtxt<'_>) -> hir::Defaultness {
|
||||
tcx.impl_defaultness(self.def_id)
|
||||
tcx.defaultness(self.def_id)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -751,7 +751,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
|
||||
reach.generics().predicates();
|
||||
|
||||
if trait_item_ref.kind == AssocItemKind::Type
|
||||
&& !tcx.impl_defaultness(trait_item_ref.id.owner_id).has_value()
|
||||
&& !tcx.defaultness(trait_item_ref.id.owner_id).has_value()
|
||||
{
|
||||
// No type to visit.
|
||||
} else {
|
||||
@ -1927,7 +1927,7 @@ fn check_assoc_item(
|
||||
|
||||
let (check_ty, is_assoc_ty) = match assoc_item_kind {
|
||||
AssocItemKind::Const | AssocItemKind::Fn { .. } => (true, false),
|
||||
AssocItemKind::Type => (self.tcx.impl_defaultness(def_id).has_value(), true),
|
||||
AssocItemKind::Type => (self.tcx.defaultness(def_id).has_value(), true),
|
||||
};
|
||||
check.in_assoc_ty = is_assoc_ty;
|
||||
check.generics().predicates();
|
||||
|
@ -295,7 +295,7 @@ pub fn future_trait_ref_and_outputs<'tcx>(
|
||||
|
||||
pub fn impl_item_is_final(tcx: TyCtxt<'_>, assoc_item: &ty::AssocItem) -> bool {
|
||||
assoc_item.defaultness(tcx).is_final()
|
||||
&& tcx.impl_defaultness(assoc_item.container_id(tcx)).is_final()
|
||||
&& tcx.defaultness(assoc_item.container_id(tcx)).is_final()
|
||||
}
|
||||
|
||||
pub enum TupleArgumentsFlag {
|
||||
|
@ -297,8 +297,8 @@ fn associated_type_for_impl_trait_in_trait(
|
||||
// Copy visility of the containing function.
|
||||
trait_assoc_ty.visibility(tcx.visibility(fn_def_id));
|
||||
|
||||
// Copy impl_defaultness of the containing function.
|
||||
trait_assoc_ty.impl_defaultness(tcx.impl_defaultness(fn_def_id));
|
||||
// Copy defaultness of the containing function.
|
||||
trait_assoc_ty.defaultness(tcx.defaultness(fn_def_id));
|
||||
|
||||
// Copy type_of of the opaque.
|
||||
trait_assoc_ty.type_of(ty::EarlyBinder::bind(tcx.mk_opaque(
|
||||
@ -393,8 +393,8 @@ fn associated_type_for_impl_trait_in_impl(
|
||||
// Copy visility of the containing function.
|
||||
impl_assoc_ty.visibility(tcx.visibility(impl_fn_def_id));
|
||||
|
||||
// Copy impl_defaultness of the containing function.
|
||||
impl_assoc_ty.impl_defaultness(tcx.impl_defaultness(impl_fn_def_id));
|
||||
// Copy defaultness of the containing function.
|
||||
impl_assoc_ty.defaultness(tcx.defaultness(impl_fn_def_id));
|
||||
|
||||
// Copy generics_of the trait's associated item but the impl as the parent.
|
||||
// FIXME(-Zlower-impl-trait-in-trait-to-assoc-ty) resolves to the trait instead of the impl
|
||||
|
@ -204,7 +204,7 @@ fn resolve_associated_item<'tcx>(
|
||||
} else {
|
||||
// All other methods are default methods of the `Future` trait.
|
||||
// (this assumes that `ImplSource::Future` is only used for methods on `Future`)
|
||||
debug_assert!(tcx.impl_defaultness(trait_item_id).has_value());
|
||||
debug_assert!(tcx.defaultness(trait_item_id).has_value());
|
||||
Some(Instance::new(trait_item_id, rcvr_substs))
|
||||
}
|
||||
}
|
||||
|
@ -75,13 +75,13 @@ fn sized_constraint_for_ty<'tcx>(
|
||||
result
|
||||
}
|
||||
|
||||
fn impl_defaultness(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::Defaultness {
|
||||
fn defaultness(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::Defaultness {
|
||||
match tcx.hir().get_by_def_id(def_id) {
|
||||
hir::Node::Item(hir::Item { kind: hir::ItemKind::Impl(impl_), .. }) => impl_.defaultness,
|
||||
hir::Node::ImplItem(hir::ImplItem { defaultness, .. })
|
||||
| hir::Node::TraitItem(hir::TraitItem { defaultness, .. }) => *defaultness,
|
||||
node => {
|
||||
bug!("`impl_defaultness` called on {:?}", node);
|
||||
bug!("`defaultness` called on {:?}", node);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -574,7 +574,7 @@ pub fn provide(providers: &mut Providers) {
|
||||
param_env_reveal_all_normalized,
|
||||
instance_def_size_estimate,
|
||||
issue33140_self_ty,
|
||||
impl_defaultness,
|
||||
defaultness,
|
||||
unsizing_params_for_adt,
|
||||
..*providers
|
||||
};
|
||||
|
@ -1224,7 +1224,7 @@ pub(crate) fn clean_impl_item<'tcx>(
|
||||
}
|
||||
hir::ImplItemKind::Fn(ref sig, body) => {
|
||||
let m = clean_function(cx, sig, impl_.generics, FunctionArgs::Body(body));
|
||||
let defaultness = cx.tcx.impl_defaultness(impl_.owner_id);
|
||||
let defaultness = cx.tcx.defaultness(impl_.owner_id);
|
||||
MethodItem(m, Some(defaultness))
|
||||
}
|
||||
hir::ImplItemKind::Type(hir_ty) => {
|
||||
@ -1258,7 +1258,7 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
|
||||
|
||||
let provided = match assoc_item.container {
|
||||
ty::ImplContainer => true,
|
||||
ty::TraitContainer => tcx.impl_defaultness(assoc_item.def_id).has_value(),
|
||||
ty::TraitContainer => tcx.defaultness(assoc_item.def_id).has_value(),
|
||||
};
|
||||
if provided {
|
||||
AssocConstItem(ty, ConstantKind::Extern { def_id: assoc_item.def_id })
|
||||
@ -1440,7 +1440,7 @@ fn param_eq_arg(param: &GenericParamDef, arg: &GenericArg) -> bool {
|
||||
}
|
||||
generics.where_predicates = where_predicates;
|
||||
|
||||
if tcx.impl_defaultness(assoc_item.def_id).has_value() {
|
||||
if tcx.defaultness(assoc_item.def_id).has_value() {
|
||||
AssocTypeItem(
|
||||
Box::new(Typedef {
|
||||
type_: clean_middle_ty(
|
||||
|
@ -205,7 +205,7 @@ pub(crate) fn render(&self, s: &mut String, tcx: TyCtxt<'_>) {
|
||||
&UrlFragment::Item(def_id) => {
|
||||
let kind = match tcx.def_kind(def_id) {
|
||||
DefKind::AssocFn => {
|
||||
if tcx.impl_defaultness(def_id).has_value() {
|
||||
if tcx.defaultness(def_id).has_value() {
|
||||
"method."
|
||||
} else {
|
||||
"tymethod."
|
||||
|
@ -105,7 +105,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx hir::Item<'_>) {
|
||||
match tit_.kind {
|
||||
hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => {},
|
||||
hir::TraitItemKind::Fn(..) => {
|
||||
if cx.tcx.impl_defaultness(tit.id.owner_id).has_value() {
|
||||
if cx.tcx.defaultness(tit.id.owner_id).has_value() {
|
||||
// trait method with default body needs inline in case
|
||||
// an impl is not provided
|
||||
let desc = "a default trait method";
|
||||
|
Loading…
Reference in New Issue
Block a user