Skip to content

Commit 83ee990

Browse files
authored
Unrolled build for #143240
Rollup merge of #143240 - JonathanBrouwer:object_lifetime_default_parser, r=oli-obk Port `#[rustc_object_lifetime_default]` to the new attribute parsing … Ports rustc_object_lifetime_default to the new attribute parsing infrastructure for #131229 (comment) r? `@oli-obk` cc `@jdonszelmann`
2 parents 4e97337 + 1e474c2 commit 83ee990

File tree

5 files changed

+27
-2
lines changed

5 files changed

+27
-2
lines changed

compiler/rustc_attr_data_structures/src/attributes.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@ pub enum AttributeKind {
296296
/// Represents `#[rustc_layout_scalar_valid_range_start]`.
297297
RustcLayoutScalarValidRangeStart(Box<u128>, Span),
298298

299+
/// Represents `#[rustc_object_lifetime_default]`.
300+
RustcObjectLifetimeDefault,
301+
299302
/// Represents `#[rustc_skip_during_method_dispatch]`.
300303
SkipDuringMethodDispatch { array: bool, boxed_slice: bool, span: Span },
301304

compiler/rustc_attr_data_structures/src/encode_cross_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ impl AttributeKind {
4040
PubTransparent(..) => Yes,
4141
RustcLayoutScalarValidRangeEnd(..) => Yes,
4242
RustcLayoutScalarValidRangeStart(..) => Yes,
43+
RustcObjectLifetimeDefault => No,
4344
SkipDuringMethodDispatch { .. } => No,
4445
TrackCaller(..) => Yes,
4546
Used { .. } => No,

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,21 @@ fn parse_rustc_layout_scalar_valid_range<S: Stage>(
5757
};
5858
Some(Box::new(num.0))
5959
}
60+
61+
pub(crate) struct RustcObjectLifetimeDefaultParser;
62+
63+
impl<S: Stage> SingleAttributeParser<S> for RustcObjectLifetimeDefaultParser {
64+
const PATH: &[rustc_span::Symbol] = &[sym::rustc_object_lifetime_default];
65+
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst;
66+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
67+
const TEMPLATE: AttributeTemplate = template!(Word);
68+
69+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
70+
if let Err(span) = args.no_args() {
71+
cx.expected_no_args(span);
72+
return None;
73+
}
74+
75+
Some(AttributeKind::RustcObjectLifetimeDefault)
76+
}
77+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use crate::attributes::must_use::MustUseParser;
2929
use crate::attributes::repr::{AlignParser, ReprParser};
3030
use crate::attributes::rustc_internal::{
3131
RustcLayoutScalarValidRangeEnd, RustcLayoutScalarValidRangeStart,
32+
RustcObjectLifetimeDefaultParser,
3233
};
3334
use crate::attributes::semantics::MayDangleParser;
3435
use crate::attributes::stability::{
@@ -136,6 +137,7 @@ attribute_parsers!(
136137
Single<RustcForceInlineParser>,
137138
Single<RustcLayoutScalarValidRangeEnd>,
138139
Single<RustcLayoutScalarValidRangeStart>,
140+
Single<RustcObjectLifetimeDefaultParser>,
139141
Single<SkipDuringMethodDispatchParser>,
140142
Single<TrackCallerParser>,
141143
Single<TransparencyParser>,

compiler/rustc_passes/src/check_attr.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
164164
}
165165
Attribute::Parsed(AttributeKind::Repr(_)) => { /* handled below this loop and elsewhere */
166166
}
167-
167+
Attribute::Parsed(AttributeKind::RustcObjectLifetimeDefault) => {
168+
self.check_object_lifetime_default(hir_id);
169+
}
168170
&Attribute::Parsed(AttributeKind::PubTransparent(attr_span)) => {
169171
self.check_rustc_pub_transparent(attr_span, span, attrs)
170172
}
@@ -303,7 +305,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
303305
[sym::no_implicit_prelude, ..] => {
304306
self.check_generic_attr(hir_id, attr, target, Target::Mod)
305307
}
306-
[sym::rustc_object_lifetime_default, ..] => self.check_object_lifetime_default(hir_id),
307308
[sym::proc_macro, ..] => {
308309
self.check_proc_macro(hir_id, target, ProcMacroKind::FunctionLike)
309310
}

0 commit comments

Comments
 (0)