Skip to content

Commit e2aef92

Browse files
committed
Stabilize #[repr(transparent)]
Tracking issue FCP: #43036 (comment) Reference PR: rust-lang/reference#353
1 parent 4367e41 commit e2aef92

17 files changed

+9
-237
lines changed

src/doc/unstable-book/src/language-features/repr-transparent.md

-176
This file was deleted.

src/liballoc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
#![feature(pin)]
106106
#![feature(ptr_internals)]
107107
#![feature(ptr_offset_from)]
108-
#![feature(repr_transparent)]
108+
#![cfg_attr(stage0, feature(repr_transparent))]
109109
#![feature(rustc_attrs)]
110110
#![feature(specialization)]
111111
#![feature(staged_api)]

src/libcore/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
#![feature(optin_builtin_traits)]
101101
#![feature(prelude_import)]
102102
#![feature(repr_simd, platform_intrinsics)]
103-
#![feature(repr_transparent)]
103+
#![cfg_attr(stage0, feature(repr_transparent))]
104104
#![feature(rustc_attrs)]
105105
#![feature(rustc_const_unstable)]
106106
#![feature(simd_ffi)]

src/librustc/diagnostics.rs

-8
Original file line numberDiff line numberDiff line change
@@ -1958,8 +1958,6 @@ representation hints.
19581958
Erroneous code example:
19591959
19601960
```compile_fail,E0692
1961-
#![feature(repr_transparent)]
1962-
19631961
#[repr(transparent, C)] // error: incompatible representation hints
19641962
struct Grams(f32);
19651963
```
@@ -1969,17 +1967,13 @@ another type, so adding more representation hints is contradictory. Remove
19691967
either the `transparent` hint or the other hints, like this:
19701968
19711969
```
1972-
#![feature(repr_transparent)]
1973-
19741970
#[repr(transparent)]
19751971
struct Grams(f32);
19761972
```
19771973
19781974
Alternatively, move the other attributes to the contained type:
19791975
19801976
```
1981-
#![feature(repr_transparent)]
1982-
19831977
#[repr(C)]
19841978
struct Foo {
19851979
x: i32,
@@ -1994,8 +1988,6 @@ Note that introducing another `struct` just to have a place for the other
19941988
attributes may have unintended side effects on the representation:
19951989
19961990
```
1997-
#![feature(repr_transparent)]
1998-
19991991
#[repr(transparent)]
20001992
struct Grams(f32);
20011993

src/librustc_typeck/diagnostics.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -4581,8 +4581,6 @@ on fields that were not guaranteed to be zero-sized.
45814581
Erroneous code example:
45824582
45834583
```compile_fail,E0690
4584-
#![feature(repr_transparent)]
4585-
45864584
#[repr(transparent)]
45874585
struct LengthWithUnit<U> { // error: transparent struct needs exactly one
45884586
value: f32, // non-zero-sized field, but has 2
@@ -4602,8 +4600,6 @@ To combine `repr(transparent)` with type parameters, `PhantomData` may be
46024600
useful:
46034601
46044602
```
4605-
#![feature(repr_transparent)]
4606-
46074603
use std::marker::PhantomData;
46084604
46094605
#[repr(transparent)]
@@ -4621,7 +4617,7 @@ field that requires non-trivial alignment.
46214617
Erroneous code example:
46224618
46234619
```compile_fail,E0691
4624-
#![feature(repr_transparent, repr_align, attr_literals)]
4620+
#![feature(repr_align, attr_literals)]
46254621
46264622
#[repr(align(32))]
46274623
struct ForceAlign32;
@@ -4640,8 +4636,6 @@ requirement.
46404636
Consider removing the over-aligned zero-sized field:
46414637
46424638
```
4643-
#![feature(repr_transparent)]
4644-
46454639
#[repr(transparent)]
46464640
struct Wrapper(f32);
46474641
```
@@ -4650,7 +4644,7 @@ Alternatively, `PhantomData<T>` has alignment 1 for all `T`, so you can use it
46504644
if you need to keep the field for some reason:
46514645
46524646
```
4653-
#![feature(repr_transparent, repr_align, attr_literals)]
4647+
#![feature(repr_align, attr_literals)]
46544648
46554649
use std::marker::PhantomData;
46564650

src/libsyntax/feature_gate.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,6 @@ declare_features! (
399399
// `extern` in paths
400400
(active, extern_in_paths, "1.23.0", Some(44660), None),
401401

402-
// Allows `#[repr(transparent)]` attribute on newtype structs
403-
(active, repr_transparent, "1.25.0", Some(43036), None),
404-
405402
// Use `?` as the Kleene "at most one" operator
406403
(active, macro_at_most_once_rep, "1.25.0", Some(48075), None),
407404

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

620619
// If you change this, please modify src/doc/unstable-book as well. You must
@@ -1595,11 +1594,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
15951594
gate_feature_post!(&self, repr_simd, attr.span,
15961595
"SIMD types are experimental and possibly buggy");
15971596
}
1598-
if item.check_name("transparent") {
1599-
gate_feature_post!(&self, repr_transparent, attr.span,
1600-
"the `#[repr(transparent)]` attribute \
1601-
is experimental");
1602-
}
16031597
if let Some((name, _)) = item.name_value_literal() {
16041598
if name == "packed" {
16051599
gate_feature_post!(&self, repr_packed, attr.span,

src/test/codegen/repr-transparent-aggregates-1.rs

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
// See repr-transparent.rs
1919

2020
#![crate_type="lib"]
21-
#![feature(repr_transparent)]
2221

2322

2423
#[repr(C)]

src/test/codegen/repr-transparent-aggregates-2.rs

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
// See repr-transparent.rs
2323

2424
#![crate_type="lib"]
25-
#![feature(repr_transparent)]
2625

2726

2827
#[repr(C)]

src/test/codegen/repr-transparent-aggregates-3.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
// See repr-transparent.rs
1515

1616
#![crate_type="lib"]
17-
#![feature(repr_transparent)]
1817

1918

2019
#[repr(C)]

src/test/codegen/repr-transparent-sysv64.rs

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// compile-flags: -C no-prepopulate-passes
1414

1515
#![crate_type="lib"]
16-
#![feature(repr_transparent)]
1716

1817
#[repr(C)]
1918
pub struct Rgb8 { r: u8, g: u8, b: u8 }

src/test/codegen/repr-transparent.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// compile-flags: -C no-prepopulate-passes
1212

1313
#![crate_type="lib"]
14-
#![feature(repr_transparent, repr_simd)]
14+
#![feature(repr_simd)]
1515

1616
use std::marker::PhantomData;
1717

src/test/compile-fail/repr-transparent-other-items.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(repr_transparent)]
12-
1311
// See also repr-transparent.rs
1412

1513
#[repr(transparent)] //~ ERROR unsupported representation for zero-variant enum

src/test/compile-fail/repr-transparent-other-reprs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(repr_transparent, repr_align, attr_literals)]
11+
#![feature(repr_align, attr_literals)]
1212

1313
// See also repr-transparent.rs
1414

src/test/compile-fail/repr-transparent.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
// - repr-transparent-other-items.rs
1515

1616
#![feature(repr_align, attr_literals)]
17-
#![feature(repr_transparent)]
1817

1918
use std::marker::PhantomData;
2019

src/test/ui/feature-gate-repr_transparent.rs

-14
This file was deleted.

0 commit comments

Comments
 (0)