Rename #[rustc_object_lifetime_default] to #[rustc_dump_object_lifetime_defaults]

This commit is contained in:
León Orell Valerian Liehr
2026-03-02 18:33:02 +01:00
parent 6af78890bc
commit 722fcbb72e
12 changed files with 48 additions and 56 deletions

View File

@@ -48,6 +48,33 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpItemBoundsParser {
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpItemBounds;
}
pub(crate) struct RustcDumpObjectLifetimeDefaultsParser;
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpObjectLifetimeDefaultsParser {
const PATH: &[Symbol] = &[sym::rustc_dump_object_lifetime_defaults];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::AssocConst),
Allow(Target::AssocTy),
Allow(Target::Const),
Allow(Target::Enum),
Allow(Target::Fn),
Allow(Target::ForeignFn),
Allow(Target::Impl { of_trait: false }),
Allow(Target::Impl { of_trait: true }),
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::Method(MethodKind::Trait { body: false })),
Allow(Target::Method(MethodKind::Trait { body: true })),
Allow(Target::Method(MethodKind::TraitImpl)),
Allow(Target::Struct),
Allow(Target::Trait),
Allow(Target::TraitAlias),
Allow(Target::TyAlias),
Allow(Target::Union),
]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpObjectLifetimeDefaults;
}
pub(crate) struct RustcDumpPredicatesParser;
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpPredicatesParser {

View File

@@ -588,33 +588,6 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcLintUntrackedQueryInformationPa
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcLintUntrackedQueryInformation;
}
pub(crate) struct RustcObjectLifetimeDefaultParser;
impl<S: Stage> NoArgsAttributeParser<S> for RustcObjectLifetimeDefaultParser {
const PATH: &[Symbol] = &[sym::rustc_object_lifetime_default];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::AssocConst),
Allow(Target::AssocTy),
Allow(Target::Const),
Allow(Target::Enum),
Allow(Target::Fn),
Allow(Target::ForeignFn),
Allow(Target::Impl { of_trait: false }),
Allow(Target::Impl { of_trait: true }),
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::Method(MethodKind::Trait { body: false })),
Allow(Target::Method(MethodKind::Trait { body: true })),
Allow(Target::Method(MethodKind::TraitImpl)),
Allow(Target::Struct),
Allow(Target::Trait),
Allow(Target::TraitAlias),
Allow(Target::TyAlias),
Allow(Target::Union),
]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcObjectLifetimeDefault;
}
pub(crate) struct RustcSimdMonomorphizeLaneLimitParser;
impl<S: Stage> SingleAttributeParser<S> for RustcSimdMonomorphizeLaneLimitParser {

View File

@@ -283,6 +283,7 @@ attribute_parsers!(
Single<WithoutArgs<RustcDumpDefParentsParser>>,
Single<WithoutArgs<RustcDumpInferredOutlivesParser>>,
Single<WithoutArgs<RustcDumpItemBoundsParser>>,
Single<WithoutArgs<RustcDumpObjectLifetimeDefaultsParser>>,
Single<WithoutArgs<RustcDumpPredicatesParser>>,
Single<WithoutArgs<RustcDumpUserArgsParser>>,
Single<WithoutArgs<RustcDumpVariancesOfOpaquesParser>>,
@@ -309,7 +310,6 @@ attribute_parsers!(
Single<WithoutArgs<RustcNonConstTraitMethodParser>>,
Single<WithoutArgs<RustcNonnullOptimizationGuaranteedParser>>,
Single<WithoutArgs<RustcNounwindParser>>,
Single<WithoutArgs<RustcObjectLifetimeDefaultParser>>,
Single<WithoutArgs<RustcOffloadKernelParser>>,
Single<WithoutArgs<RustcParenSugarParser>>,
Single<WithoutArgs<RustcPassByValueParser>>,

View File

@@ -1531,7 +1531,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
WarnFollowing, EncodeCrossCrate::No
),
rustc_attr!(
TEST, rustc_object_lifetime_default, Normal, template!(Word),
TEST, rustc_dump_object_lifetime_defaults, Normal, template!(Word),
WarnFollowing, EncodeCrossCrate::No
),
rustc_attr!(

View File

@@ -1372,6 +1372,9 @@ pub enum AttributeKind {
/// Represents `#[rustc_dump_item_bounds]`
RustcDumpItemBounds,
/// Represents `#[rustc_dump_object_lifetime_defaults]`.
RustcDumpObjectLifetimeDefaults,
/// Represents `#[rustc_dump_predicates]`
RustcDumpPredicates,
@@ -1502,9 +1505,6 @@ pub enum AttributeKind {
span: Span,
},
/// Represents `#[rustc_object_lifetime_default]`.
RustcObjectLifetimeDefault,
/// Represents `#[rustc_offload_kernel]`
RustcOffloadKernel,

View File

@@ -126,6 +126,7 @@ impl AttributeKind {
RustcDumpDefParents => No,
RustcDumpInferredOutlives => No,
RustcDumpItemBounds => No,
RustcDumpObjectLifetimeDefaults => No,
RustcDumpPredicates => No,
RustcDumpUserArgs => No,
RustcDumpVariances => No,
@@ -164,7 +165,6 @@ impl AttributeKind {
RustcNounwind => No,
RustcObjcClass { .. } => No,
RustcObjcSelector { .. } => No,
RustcObjectLifetimeDefault => No,
RustcOffloadKernel => Yes,
RustcParenSugar(..) => No,
RustcPassByValue(..) => Yes,

View File

@@ -2119,7 +2119,7 @@ rustc_queries! {
/// Returns the *default lifetime* to be used if a trait object type were to be passed for
/// the type parameter given by `DefId`.
///
/// **Tip**: You can use `#[rustc_object_lifetime_default]` on an item to basically
/// **Tip**: You can use `#[rustc_dump_object_lifetime_defaults]` on an item to basically
/// print the result of this query for use in UI tests or for debugging purposes.
///
/// # Examples

View File

@@ -184,8 +184,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
Attribute::Parsed(AttributeKind::TargetFeature{ attr_span, ..}) => {
self.check_target_feature(hir_id, *attr_span, target, attrs)
}
Attribute::Parsed(AttributeKind::RustcObjectLifetimeDefault) => {
self.check_object_lifetime_default(hir_id);
Attribute::Parsed(AttributeKind::RustcDumpObjectLifetimeDefaults) => {
self.check_dump_object_lifetime_defaults(hir_id);
}
&Attribute::Parsed(AttributeKind::RustcPubTransparent(attr_span)) => {
self.check_rustc_pub_transparent(attr_span, span, attrs)
@@ -781,8 +781,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
}
}
/// Debugging aid for `object_lifetime_default` query.
fn check_object_lifetime_default(&self, hir_id: HirId) {
/// Debugging aid for the `object_lifetime_default` query.
fn check_dump_object_lifetime_defaults(&self, hir_id: HirId) {
let tcx = self.tcx;
if let Some(owner_id) = hir_id.as_owner()
&& let Some(generics) = tcx.hir_get_generics(owner_id.def_id)
@@ -796,7 +796,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
ObjectLifetimeDefault::Param(def_id) => tcx.item_name(def_id).to_string(),
ObjectLifetimeDefault::Ambiguous => "Ambiguous".to_owned(),
};
tcx.dcx().emit_err(errors::ObjectLifetimeErr { span: p.span, repr });
tcx.dcx().span_err(p.span, repr);
}
}
}

View File

@@ -814,14 +814,6 @@ pub(crate) struct UselessAssignment<'a> {
)]
pub(crate) struct InlineIgnoredForExported;
#[derive(Diagnostic)]
#[diag("{$repr}")]
pub(crate) struct ObjectLifetimeErr {
#[primary_span]
pub span: Span,
pub repr: String,
}
#[derive(Diagnostic)]
pub(crate) enum AttrApplication {
#[diag("attribute should be applied to an enum", code = E0517)]

View File

@@ -1723,6 +1723,7 @@ symbols! {
rustc_dump_def_parents,
rustc_dump_inferred_outlives,
rustc_dump_item_bounds,
rustc_dump_object_lifetime_defaults,
rustc_dump_predicates,
rustc_dump_user_args,
rustc_dump_variances,
@@ -1763,7 +1764,6 @@ symbols! {
rustc_nounwind,
rustc_objc_class,
rustc_objc_selector,
rustc_object_lifetime_default,
rustc_offload_kernel,
rustc_on_unimplemented,
rustc_paren_sugar,

View File

@@ -277,12 +277,12 @@ Here are some notable ones:
| `rustc_dump_def_parents` | Dumps the chain of `DefId` parents of certain definitions. |
| `rustc_dump_inferred_outlives` | Dumps implied bounds of an item. More precisely, the [`inferred_outlives_of`] an item. |
| `rustc_dump_item_bounds` | Dumps the [`item_bounds`] of an item. |
| `rustc_dump_object_lifetime_defaults` | Dumps the [object lifetime defaults] of an item. |
| `rustc_dump_predicates` | Dumps the [`predicates_of`] an item. |
| `rustc_dump_variances` | Dumps the [variances] of an item. |
| `rustc_dump_vtable` | Dumps the vtable layout of an impl, or a type alias of a dyn type. |
| `rustc_hidden_type_of_opaques` | Dumps the [hidden type of each opaque types][opaq] in the crate. |
| `rustc_layout` | [See this section](#debugging-type-layouts). |
| `rustc_object_lifetime_default` | Dumps the [object lifetime defaults] of an item. |
| `rustc_regions` | Dumps NLL closure region requirements. |
| `rustc_symbol_name` | Dumps the mangled & demangled [`symbol_name`] of an item. |

View File

@@ -1,37 +1,37 @@
#![feature(rustc_attrs)]
#[rustc_object_lifetime_default]
#[rustc_dump_object_lifetime_defaults]
struct A<
T, //~ ERROR BaseDefault
>(T);
#[rustc_object_lifetime_default]
#[rustc_dump_object_lifetime_defaults]
struct B<
'a,
T, //~ ERROR BaseDefault
>(&'a (), T);
#[rustc_object_lifetime_default]
#[rustc_dump_object_lifetime_defaults]
struct C<
'a,
T: 'a, //~ ERROR 'a
>(&'a T);
#[rustc_object_lifetime_default]
#[rustc_dump_object_lifetime_defaults]
struct D<
'a,
'b,
T: 'a + 'b, //~ ERROR Ambiguous
>(&'a T, &'b T);
#[rustc_object_lifetime_default]
#[rustc_dump_object_lifetime_defaults]
struct E<
'a,
'b: 'a,
T: 'b, //~ ERROR 'b
>(&'a T, &'b T);
#[rustc_object_lifetime_default]
#[rustc_dump_object_lifetime_defaults]
struct F<
'a,
'b,
@@ -39,7 +39,7 @@ struct F<
U: 'b, //~ ERROR 'b
>(&'a T, &'b U);
#[rustc_object_lifetime_default]
#[rustc_dump_object_lifetime_defaults]
struct G<
'a,
'b,