diff options
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/attr.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 8 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 4291f811f3f..d18d6f5e6bd 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -992,7 +992,8 @@ pub fn find_deprecation(diagnostic: &Handler, attrs: &[Attribute], /// Valid repr contents: any of the primitive integral type names (see /// `int_type_of_word`, below) to specify enum discriminant type; `C`, to use /// the same discriminant size that the corresponding C enum would or C -/// structure layout, and `packed` to remove padding. +/// structure layout, `packed` to remove padding, and `transparent` to elegate representation +/// concerns to the only non-ZST field. pub fn find_repr_attrs(diagnostic: &Handler, attr: &Attribute) -> Vec<ReprAttr> { let mut acc = Vec::new(); if attr.path == "repr" { @@ -1011,6 +1012,7 @@ pub fn find_repr_attrs(diagnostic: &Handler, attr: &Attribute) -> Vec<ReprAttr> "C" => Some(ReprC), "packed" => Some(ReprPacked), "simd" => Some(ReprSimd), + "transparent" => Some(ReprTransparent), _ => match int_type_of_word(word) { Some(ity) => Some(ReprInt(ity)), None => { @@ -1082,6 +1084,7 @@ pub enum ReprAttr { ReprC, ReprPacked, ReprSimd, + ReprTransparent, ReprAlign(u32), } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 196fadcc997..953b2deb877 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -452,6 +452,9 @@ declare_features! ( // `extern` in paths (active, extern_in_paths, "1.23.0", Some(44660)), + + // Allows `#[repr(transparent)]` attribute on newtype structs + (active, repr_transparent, "1.25.0", Some(43036)), ); declare_features! ( @@ -1524,6 +1527,11 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { "the struct `#[repr(align(u16))]` attribute \ is experimental"); } + if item.check_name("transparent") { + gate_feature_post!(&self, repr_transparent, attr.span, + "the `#[repr(transparent)]` attribute \ + is experimental"); + } } } } |
