Skip to content

Commit 48e45ee

Browse files
committed
Add transparent as valid repr hint
1 parent 3580de8 commit 48e45ee

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/librustc_lint/builtin.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ impl EarlyLintPass for BadRepr {
696696
let mut warn = if let Some(ref lit) = attr.value_str() {
697697
// avoid warning about empty `repr` on `#[repr = "foo"]`
698698
let sp = match format!("{}", lit).as_ref() {
699-
"C" | "packed" | "rust" | "u*" | "i*" => {
699+
"C" | "packed" | "rust" | "u*" | "i*" | "transparent" => {
700700
let lo = attr.span.lo() + BytePos(2);
701701
let hi = attr.span.hi() - BytePos(1);
702702
suggested = true;
@@ -731,8 +731,8 @@ impl EarlyLintPass for BadRepr {
731731
warn
732732
};
733733
if !suggested {
734-
warn.help("valid hints include `#[repr(C)]`, `#[repr(packed)]` and \
735-
`#[repr(rust)]`");
734+
warn.help("valid hints include `#[repr(C)]`, `#[repr(packed)]`, \
735+
`#[repr(rust)]` and `#[repr(transparent)]`");
736736
warn.note("for more information, visit \
737737
<https://doc.rust-lang.org/nomicon/other-reprs.html>");
738738
}

src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ LL | mod inner { #![repr="3900"] }
193193
| ^^^^^^^^^^^^^^^ needs a hint
194194
|
195195
= note: #[warn(bad_repr)] on by default
196-
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]` and `#[repr(rust)]`
196+
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]`
197197
= note: for more information, visit <https://doc.rust-lang.org/nomicon/other-reprs.html>
198198

199199
warning: `repr` attribute isn't configurable with a literal
@@ -202,7 +202,7 @@ warning: `repr` attribute isn't configurable with a literal
202202
LL | #[repr = "3900"] fn f() { }
203203
| ^^^^^^^^^^^^^^^^ needs a hint
204204
|
205-
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]` and `#[repr(rust)]`
205+
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]`
206206
= note: for more information, visit <https://doc.rust-lang.org/nomicon/other-reprs.html>
207207

208208
warning: `repr` attribute isn't configurable with a literal
@@ -211,7 +211,7 @@ warning: `repr` attribute isn't configurable with a literal
211211
LL | #[repr = "3900"] type T = S;
212212
| ^^^^^^^^^^^^^^^^ needs a hint
213213
|
214-
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]` and `#[repr(rust)]`
214+
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]`
215215
= note: for more information, visit <https://doc.rust-lang.org/nomicon/other-reprs.html>
216216

217217
warning: `repr` attribute isn't configurable with a literal
@@ -220,7 +220,7 @@ warning: `repr` attribute isn't configurable with a literal
220220
LL | #[repr = "3900"] impl S { }
221221
| ^^^^^^^^^^^^^^^^ needs a hint
222222
|
223-
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]` and `#[repr(rust)]`
223+
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]`
224224
= note: for more information, visit <https://doc.rust-lang.org/nomicon/other-reprs.html>
225225

226226
warning: `repr` attribute isn't configurable with a literal
@@ -229,7 +229,7 @@ warning: `repr` attribute isn't configurable with a literal
229229
LL | #[repr = "3900"]
230230
| ^^^^^^^^^^^^^^^^ needs a hint
231231
|
232-
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]` and `#[repr(rust)]`
232+
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]`
233233
= note: for more information, visit <https://doc.rust-lang.org/nomicon/other-reprs.html>
234234

235235
warning: `repr` attribute isn't configurable with a literal
@@ -238,7 +238,7 @@ warning: `repr` attribute isn't configurable with a literal
238238
LL | #![repr = "3900"]
239239
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ needs a hint
240240
|
241-
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]` and `#[repr(rust)]`
241+
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]`
242242
= note: for more information, visit <https://doc.rust-lang.org/nomicon/other-reprs.html>
243243

244244
warning: unused attribute

src/test/ui/suggestions/repr.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | #[repr]
55
| ^^^^^^^ needs a hint
66
|
77
= note: #[warn(bad_repr)] on by default
8-
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]` and `#[repr(rust)]`
8+
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]`
99
= note: for more information, visit <https://doc.rust-lang.org/nomicon/other-reprs.html>
1010

1111
warning: `repr` attribute isn't configurable with a literal
@@ -14,7 +14,7 @@ warning: `repr` attribute isn't configurable with a literal
1414
LL | #[repr = "B"]
1515
| ^^^^^^^^^^^^^ needs a hint
1616
|
17-
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]` and `#[repr(rust)]`
17+
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]`
1818
= note: for more information, visit <https://doc.rust-lang.org/nomicon/other-reprs.html>
1919

2020
warning: `repr` attribute isn't configurable with a literal

0 commit comments

Comments
 (0)