Skip to content

Commit 4ad2959

Browse files
Port #[pointee] to the new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
1 parent d2baa49 commit 4ad2959

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
@@ -340,6 +340,9 @@ pub enum AttributeKind {
340340
/// Represents `#[path]`
341341
Path(Symbol, Span),
342342

343+
/// Represents `#[pointee]`
344+
Pointee(Span),
345+
343346
/// Represents `#[rustc_pub_transparent]` (used by the `repr_transparent_external_private_fields` lint).
344347
PubTransparent(Span),
345348

compiler/rustc_attr_data_structures/src/encode_cross_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ impl AttributeKind {
5454
ParenSugar(..) => No,
5555
PassByValue(..) => Yes,
5656
Path(..) => No,
57+
Pointee(..) => No,
5758
PubTransparent(..) => Yes,
5859
Repr { .. } => No,
5960
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
@@ -46,8 +46,8 @@ use crate::attributes::test_attrs::IgnoreParser;
4646
use crate::attributes::traits::{
4747
AllowIncoherentImplParser, CoherenceIsCoreParser, CoinductiveParser, ConstTraitParser,
4848
DenyExplicitImplParser, DoNotImplementViaObjectParser, FundamentalParser, MarkerParser,
49-
ParenSugarParser, SkipDuringMethodDispatchParser, SpecializationTraitParser, TypeConstParser,
50-
UnsafeSpecializationMarkerParser,
49+
ParenSugarParser, PointeeParser, SkipDuringMethodDispatchParser, SpecializationTraitParser,
50+
TypeConstParser, UnsafeSpecializationMarkerParser,
5151
};
5252
use crate::attributes::transparency::TransparencyParser;
5353
use crate::attributes::{AttributeParser as _, Combine, Single, WithoutArgs};
@@ -173,6 +173,7 @@ attribute_parsers!(
173173
Single<WithoutArgs<NonExhaustiveParser>>,
174174
Single<WithoutArgs<ParenSugarParser>>,
175175
Single<WithoutArgs<PassByValueParser>>,
176+
Single<WithoutArgs<PointeeParser>>,
176177
Single<WithoutArgs<PubTransparentParser>>,
177178
Single<WithoutArgs<SpecializationTraitParser>>,
178179
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
@@ -240,6 +240,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
240240
AttributeKind::BodyStability { .. }
241241
| AttributeKind::ConstStabilityIndirect
242242
| AttributeKind::MacroTransparency(_)
243+
| AttributeKind::Pointee(..)
243244
| AttributeKind::Dummy,
244245
) => { /* do nothing */ }
245246
Attribute::Parsed(AttributeKind::AsPtr(attr_span)) => {
@@ -368,7 +369,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
368369
| sym::cfg_attr_trace
369370
// need to be fixed
370371
| sym::cfi_encoding // FIXME(cfi_encoding)
371-
| sym::pointee // FIXME(derive_coerce_pointee)
372372
| sym::omit_gdb_pretty_printer_section // FIXME(omit_gdb_pretty_printer_section)
373373
| sym::instruction_set // broken on stable!!!
374374
| sym::windows_subsystem // broken on stable!!!

0 commit comments

Comments
 (0)