Skip to content

Commit 743e183

Browse files
Rollup merge of #143878 - JonathanBrouwer:pointee_parser, r=jdonszelmann
Port `#[pointee]` to the new attribute parsing infrastructure Ports `#[pointee]` to the new attribute parsing infrastructure for #131229 (comment) r? ``@jdonszelmann``
2 parents b89c63d + f0d0afa commit 743e183

File tree

6 files changed

+16
-3
lines changed

6 files changed

+16
-3
lines changed

compiler/rustc_attr_data_structures/src/attributes.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,9 @@ pub enum AttributeKind {
349349
/// Represents `#[path]`
350350
Path(Symbol, Span),
351351

352+
/// Represents `#[pointee]`
353+
Pointee(Span),
354+
352355
/// Represents `#[rustc_pub_transparent]` (used by the `repr_transparent_external_private_fields` lint).
353356
PubTransparent(Span),
354357

compiler/rustc_attr_data_structures/src/encode_cross_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ impl AttributeKind {
5757
ParenSugar(..) => No,
5858
PassByValue(..) => Yes,
5959
Path(..) => No,
60+
Pointee(..) => No,
6061
PubTransparent(..) => Yes,
6162
Repr { .. } => No,
6263
RustcLayoutScalarValidRangeEnd(..) => Yes,

compiler/rustc_attr_parsing/src/attributes/traits.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,10 @@ impl<S: Stage> NoArgsAttributeParser<S> for FundamentalParser {
145145
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
146146
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::Fundamental;
147147
}
148+
149+
pub(crate) struct PointeeParser;
150+
impl<S: Stage> NoArgsAttributeParser<S> for PointeeParser {
151+
const PATH: &[Symbol] = &[sym::pointee];
152+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
153+
const CREATE: fn(Span) -> AttributeKind = AttributeKind::Pointee;
154+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ use crate::attributes::test_attrs::IgnoreParser;
4848
use crate::attributes::traits::{
4949
AllowIncoherentImplParser, CoherenceIsCoreParser, CoinductiveParser, ConstTraitParser,
5050
DenyExplicitImplParser, DoNotImplementViaObjectParser, FundamentalParser, MarkerParser,
51-
ParenSugarParser, SkipDuringMethodDispatchParser, SpecializationTraitParser, TypeConstParser,
52-
UnsafeSpecializationMarkerParser,
51+
ParenSugarParser, PointeeParser, SkipDuringMethodDispatchParser, SpecializationTraitParser,
52+
TypeConstParser, UnsafeSpecializationMarkerParser,
5353
};
5454
use crate::attributes::transparency::TransparencyParser;
5555
use crate::attributes::{AttributeParser as _, Combine, Single, WithoutArgs};
@@ -178,6 +178,7 @@ attribute_parsers!(
178178
Single<WithoutArgs<OmitGdbPrettyPrinterSectionParser>>,
179179
Single<WithoutArgs<ParenSugarParser>>,
180180
Single<WithoutArgs<PassByValueParser>>,
181+
Single<WithoutArgs<PointeeParser>>,
181182
Single<WithoutArgs<PubTransparentParser>>,
182183
Single<WithoutArgs<SpecializationTraitParser>>,
183184
Single<WithoutArgs<StdInternalSymbolParser>>,

compiler/rustc_parse/src/validate_attr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ pub fn check_builtin_meta_item(
299299
| sym::align
300300
| sym::deprecated
301301
| sym::optimize
302+
| sym::pointee
302303
| sym::cold
303304
| sym::target_feature
304305
| sym::rustc_allow_const_fn_unstable

compiler/rustc_passes/src/check_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
251251
AttributeKind::BodyStability { .. }
252252
| AttributeKind::ConstStabilityIndirect
253253
| AttributeKind::MacroTransparency(_)
254+
| AttributeKind::Pointee(..)
254255
| AttributeKind::Dummy
255256
| AttributeKind::OmitGdbPrettyPrinterSection,
256257
) => { /* do nothing */ }
@@ -381,7 +382,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
381382
| sym::cfg_attr_trace
382383
// need to be fixed
383384
| sym::cfi_encoding // FIXME(cfi_encoding)
384-
| sym::pointee // FIXME(derive_coerce_pointee)
385385
| sym::instruction_set // broken on stable!!!
386386
| sym::windows_subsystem // broken on stable!!!
387387
| sym::patchable_function_entry // FIXME(patchable_function_entry)

0 commit comments

Comments
 (0)