Skip to content

Commit

Permalink
Add transparent as valid repr hint
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Jun 6, 2018
1 parent 3580de8 commit 48e45ee
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/librustc_lint/builtin.rs
Expand Up @@ -696,7 +696,7 @@ impl EarlyLintPass for BadRepr {
let mut warn = if let Some(ref lit) = attr.value_str() {
// avoid warning about empty `repr` on `#[repr = "foo"]`
let sp = match format!("{}", lit).as_ref() {
"C" | "packed" | "rust" | "u*" | "i*" => {
"C" | "packed" | "rust" | "u*" | "i*" | "transparent" => {
let lo = attr.span.lo() + BytePos(2);
let hi = attr.span.hi() - BytePos(1);
suggested = true;
Expand Down Expand Up @@ -731,8 +731,8 @@ impl EarlyLintPass for BadRepr {
warn
};
if !suggested {
warn.help("valid hints include `#[repr(C)]`, `#[repr(packed)]` and \
`#[repr(rust)]`");
warn.help("valid hints include `#[repr(C)]`, `#[repr(packed)]`, \
`#[repr(rust)]` and `#[repr(transparent)]`");
warn.note("for more information, visit \
<https://doc.rust-lang.org/nomicon/other-reprs.html>");
}
Expand Down
Expand Up @@ -193,7 +193,7 @@ LL | mod inner { #![repr="3900"] }
| ^^^^^^^^^^^^^^^ needs a hint
|
= note: #[warn(bad_repr)] on by default
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]` and `#[repr(rust)]`
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]`
= note: for more information, visit <https://doc.rust-lang.org/nomicon/other-reprs.html>

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

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

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

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

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

warning: unused attribute
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/suggestions/repr.stderr
Expand Up @@ -5,7 +5,7 @@ LL | #[repr]
| ^^^^^^^ needs a hint
|
= note: #[warn(bad_repr)] on by default
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]` and `#[repr(rust)]`
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]`
= note: for more information, visit <https://doc.rust-lang.org/nomicon/other-reprs.html>

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

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

0 comments on commit 48e45ee

Please sign in to comment.