diff options
| author | bors <bors@rust-lang.org> | 2018-01-22 08:10:41 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-01-22 08:10:41 +0000 |
| commit | b887317da6ba0f70b34c0439ade8508e1b525fb0 (patch) | |
| tree | ce6ba8d360d4f6026f495694b15b31e4b9f86179 /src/libsyntax | |
| parent | bc072ed0ca8e2e9f8c79fb04e85b47b5c0e8d6ae (diff) | |
| parent | 2be697bc215f19b4bf17df6b9b56626ab7b1d994 (diff) | |
| download | rust-b887317da6ba0f70b34c0439ade8508e1b525fb0.tar.gz rust-b887317da6ba0f70b34c0439ade8508e1b525fb0.zip | |
Auto merge of #47158 - rkruppe:repr-transparent, r=eddyb
Implement repr(transparent) r? @eddyb for the functional changes. The bulk of the PR is error messages and docs, might be good to have a doc person look over those. cc #43036 cc @nox
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 0c4bcf4f6c7..ac5a10ec703 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"); + } } } } |
