Skip to content

Commit

Permalink
Do not account for inner/outer attr
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Jun 7, 2018
1 parent 3cc09c8 commit 0e3f19d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
12 changes: 1 addition & 11 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,18 +687,8 @@ impl EarlyLintPass for BadRepr {
fn check_attribute(&mut self, cx: &EarlyContext, attr: &ast::Attribute) {
if attr.name() == "repr" {
let list = attr.meta_item_list();
let outer = match attr.style {
ast::AttrStyle::Outer => true,
ast::AttrStyle::Inner => false,
};

let repr_str = move |lit: &str| {
if outer {
format!("#[repr({})]", lit)
} else {
format!("#![repr({})]", lit)
}
};
let repr_str = |lit: &str| { format!("#[repr({})]", lit) };

// Emit warnings with `repr` either has a literal assignment (`#[repr = "C"]`) or
// no hints (``#[repr]`)
Expand Down
Original file line number Diff line number Diff line change
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)]`, `#![repr(rust)]` and `#![repr(transparent)]`
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]`
= note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html>

warning: `repr` attribute isn't configurable with a literal
Expand Down Expand Up @@ -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)]`, `#![repr(rust)]` and `#![repr(transparent)]`
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]`
= note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html>

warning: unused attribute
Expand Down

0 comments on commit 0e3f19d

Please sign in to comment.