Skip to content

Commit

Permalink
Stabilize #[repr(transparent)]
Browse files Browse the repository at this point in the history
Tracking issue FCP: #43036 (comment)
Reference PR: rust-lang/reference#353
  • Loading branch information
SimonSapin committed Jun 12, 2018
1 parent 4367e41 commit e2aef92
Show file tree
Hide file tree
Showing 17 changed files with 9 additions and 237 deletions.
176 changes: 0 additions & 176 deletions src/doc/unstable-book/src/language-features/repr-transparent.md

This file was deleted.

2 changes: 1 addition & 1 deletion src/liballoc/lib.rs
Expand Up @@ -105,7 +105,7 @@
#![feature(pin)]
#![feature(ptr_internals)]
#![feature(ptr_offset_from)]
#![feature(repr_transparent)]
#![cfg_attr(stage0, feature(repr_transparent))]
#![feature(rustc_attrs)]
#![feature(specialization)]
#![feature(staged_api)]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/lib.rs
Expand Up @@ -100,7 +100,7 @@
#![feature(optin_builtin_traits)]
#![feature(prelude_import)]
#![feature(repr_simd, platform_intrinsics)]
#![feature(repr_transparent)]
#![cfg_attr(stage0, feature(repr_transparent))]
#![feature(rustc_attrs)]
#![feature(rustc_const_unstable)]
#![feature(simd_ffi)]
Expand Down
8 changes: 0 additions & 8 deletions src/librustc/diagnostics.rs
Expand Up @@ -1958,8 +1958,6 @@ representation hints.
Erroneous code example:
```compile_fail,E0692
#![feature(repr_transparent)]
#[repr(transparent, C)] // error: incompatible representation hints
struct Grams(f32);
```
Expand All @@ -1969,17 +1967,13 @@ another type, so adding more representation hints is contradictory. Remove
either the `transparent` hint or the other hints, like this:
```
#![feature(repr_transparent)]
#[repr(transparent)]
struct Grams(f32);
```
Alternatively, move the other attributes to the contained type:
```
#![feature(repr_transparent)]
#[repr(C)]
struct Foo {
x: i32,
Expand All @@ -1994,8 +1988,6 @@ Note that introducing another `struct` just to have a place for the other
attributes may have unintended side effects on the representation:
```
#![feature(repr_transparent)]
#[repr(transparent)]
struct Grams(f32);
Expand Down
10 changes: 2 additions & 8 deletions src/librustc_typeck/diagnostics.rs
Expand Up @@ -4581,8 +4581,6 @@ on fields that were not guaranteed to be zero-sized.
Erroneous code example:
```compile_fail,E0690
#![feature(repr_transparent)]
#[repr(transparent)]
struct LengthWithUnit<U> { // error: transparent struct needs exactly one
value: f32, // non-zero-sized field, but has 2
Expand All @@ -4602,8 +4600,6 @@ To combine `repr(transparent)` with type parameters, `PhantomData` may be
useful:
```
#![feature(repr_transparent)]
use std::marker::PhantomData;
#[repr(transparent)]
Expand All @@ -4621,7 +4617,7 @@ field that requires non-trivial alignment.
Erroneous code example:
```compile_fail,E0691
#![feature(repr_transparent, repr_align, attr_literals)]
#![feature(repr_align, attr_literals)]
#[repr(align(32))]
struct ForceAlign32;
Expand All @@ -4640,8 +4636,6 @@ requirement.
Consider removing the over-aligned zero-sized field:
```
#![feature(repr_transparent)]
#[repr(transparent)]
struct Wrapper(f32);
```
Expand All @@ -4650,7 +4644,7 @@ Alternatively, `PhantomData<T>` has alignment 1 for all `T`, so you can use it
if you need to keep the field for some reason:
```
#![feature(repr_transparent, repr_align, attr_literals)]
#![feature(repr_align, attr_literals)]
use std::marker::PhantomData;
Expand Down
10 changes: 2 additions & 8 deletions src/libsyntax/feature_gate.rs
Expand Up @@ -399,9 +399,6 @@ declare_features! (
// `extern` in paths
(active, extern_in_paths, "1.23.0", Some(44660), None),

// Allows `#[repr(transparent)]` attribute on newtype structs
(active, repr_transparent, "1.25.0", Some(43036), None),

// Use `?` as the Kleene "at most one" operator
(active, macro_at_most_once_rep, "1.25.0", Some(48075), None),

Expand Down Expand Up @@ -615,6 +612,8 @@ declare_features! (
(accepted, termination_trait_test, "1.27.0", Some(48854), None),
// The #[global_allocator] attribute
(accepted, global_allocator, "1.28.0", Some(27389), None),
// Allows `#[repr(transparent)]` attribute on newtype structs
(accepted, repr_transparent, "1.28.0", Some(43036), None),
);

// If you change this, please modify src/doc/unstable-book as well. You must
Expand Down Expand Up @@ -1595,11 +1594,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
gate_feature_post!(&self, repr_simd, attr.span,
"SIMD types are experimental and possibly buggy");
}
if item.check_name("transparent") {
gate_feature_post!(&self, repr_transparent, attr.span,
"the `#[repr(transparent)]` attribute \
is experimental");
}
if let Some((name, _)) = item.name_value_literal() {
if name == "packed" {
gate_feature_post!(&self, repr_packed, attr.span,
Expand Down
1 change: 0 additions & 1 deletion src/test/codegen/repr-transparent-aggregates-1.rs
Expand Up @@ -18,7 +18,6 @@
// See repr-transparent.rs

#![crate_type="lib"]
#![feature(repr_transparent)]


#[repr(C)]
Expand Down
1 change: 0 additions & 1 deletion src/test/codegen/repr-transparent-aggregates-2.rs
Expand Up @@ -22,7 +22,6 @@
// See repr-transparent.rs

#![crate_type="lib"]
#![feature(repr_transparent)]


#[repr(C)]
Expand Down
1 change: 0 additions & 1 deletion src/test/codegen/repr-transparent-aggregates-3.rs
Expand Up @@ -14,7 +14,6 @@
// See repr-transparent.rs

#![crate_type="lib"]
#![feature(repr_transparent)]


#[repr(C)]
Expand Down
1 change: 0 additions & 1 deletion src/test/codegen/repr-transparent-sysv64.rs
Expand Up @@ -13,7 +13,6 @@
// compile-flags: -C no-prepopulate-passes

#![crate_type="lib"]
#![feature(repr_transparent)]

#[repr(C)]
pub struct Rgb8 { r: u8, g: u8, b: u8 }
Expand Down
2 changes: 1 addition & 1 deletion src/test/codegen/repr-transparent.rs
Expand Up @@ -11,7 +11,7 @@
// compile-flags: -C no-prepopulate-passes

#![crate_type="lib"]
#![feature(repr_transparent, repr_simd)]
#![feature(repr_simd)]

use std::marker::PhantomData;

Expand Down
2 changes: 0 additions & 2 deletions src/test/compile-fail/repr-transparent-other-items.rs
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(repr_transparent)]

// See also repr-transparent.rs

#[repr(transparent)] //~ ERROR unsupported representation for zero-variant enum
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/repr-transparent-other-reprs.rs
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(repr_transparent, repr_align, attr_literals)]
#![feature(repr_align, attr_literals)]

// See also repr-transparent.rs

Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail/repr-transparent.rs
Expand Up @@ -14,7 +14,6 @@
// - repr-transparent-other-items.rs

#![feature(repr_align, attr_literals)]
#![feature(repr_transparent)]

use std::marker::PhantomData;

Expand Down
14 changes: 0 additions & 14 deletions src/test/ui/feature-gate-repr_transparent.rs

This file was deleted.

0 comments on commit e2aef92

Please sign in to comment.