Skip to content

Commit 67be07d

Browse files
committed
address review comments
1 parent 562389d commit 67be07d

17 files changed

+94
-119
lines changed

src/librustc/hir/check_attr.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ use crate::hir::def_id::DefId;
88
use crate::hir::intravisit::{self, NestedVisitorMap, Visitor};
99
use crate::hir::DUMMY_HIR_ID;
1010
use crate::hir::{self, Attribute, HirId, Item, ItemKind, TraitItem, TraitItemKind};
11-
use crate::lint::builtin::{CONFLICTING_REPR_HINTS, UNUSED_ATTRIBUTES};
11+
use crate::lint::builtin::UNUSED_ATTRIBUTES;
1212
use crate::ty::query::Providers;
1313
use crate::ty::TyCtxt;
1414

15-
use errors::{error_code, struct_span_err};
15+
use errors::struct_span_err;
1616
use rustc_span::Span;
1717

1818
use std::fmt::{self, Display};
@@ -194,7 +194,7 @@ impl CheckAttrVisitor<'tcx> {
194194
self.tcx.codegen_fn_attrs(self.tcx.hir().local_def_id(hir_id));
195195
}
196196

197-
self.check_repr(attrs, span, target, item, hir_id);
197+
self.check_repr(attrs, span, target, item);
198198
self.check_used(attrs, target);
199199
}
200200

@@ -355,7 +355,6 @@ impl CheckAttrVisitor<'tcx> {
355355
span: &Span,
356356
target: Target,
357357
item: Option<&Item<'_>>,
358-
hir_id: HirId,
359358
) {
360359
// Extract the names of all repr hints, e.g., [foo, bar, align] for:
361360
// ```
@@ -445,15 +444,13 @@ impl CheckAttrVisitor<'tcx> {
445444
|| (is_simd && is_c)
446445
|| (int_reprs == 1 && is_c && item.map_or(false, |item| is_c_like_enum(item)))
447446
{
448-
self.tcx
449-
.struct_span_lint_hir(
450-
CONFLICTING_REPR_HINTS,
451-
hir_id,
452-
hint_spans.collect::<Vec<Span>>(),
453-
"conflicting representation hints",
454-
)
455-
.code(error_code!(E0566))
456-
.emit();
447+
struct_span_err!(
448+
self.tcx.sess,
449+
hint_spans.collect::<Vec<Span>>(),
450+
E0566,
451+
"conflicting representation hints",
452+
)
453+
.emit();
457454
}
458455
}
459456

src/librustc/lint/builtin.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,11 @@ declare_lint! {
9696
}
9797

9898
declare_lint! {
99-
pub BINDING_VARIANT_NAME,
99+
pub BINDINGS_WITH_VARIANT_NAME,
100100
Warn,
101101
"detects pattern bindings with the same name as one of the matched variants"
102102
}
103103

104-
declare_lint! {
105-
pub CONFLICTING_REPR_HINTS,
106-
Warn,
107-
"detects when more than one `#[repr(..)]` attribute, with different meaning, is applied"
108-
}
109-
110104
declare_lint! {
111105
pub UNUSED_MACROS,
112106
Warn,
@@ -471,7 +465,7 @@ declare_lint_pass! {
471465
UNREACHABLE_CODE,
472466
UNREACHABLE_PATTERNS,
473467
OVERLAPPING_PATTERNS,
474-
BINDING_VARIANT_NAME,
468+
BINDINGS_WITH_VARIANT_NAME,
475469
UNUSED_MACROS,
476470
WARNINGS,
477471
UNUSED_FEATURES,

src/librustc_error_codes/error_codes/E0566.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Conflicting representation hints have been used on a same item.
22

33
Erroneous code example:
44

5-
```
6-
#[repr(u32, u64)] // warning!
5+
```compile_fail,E0566
6+
#[repr(u32, u64)]
77
enum Repr { A }
88
```
99

src/librustc_mir/hair/pattern/check_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ fn check_for_bindings_named_same_as_variants(cx: &MatchVisitor<'_, '_>, pat: &Pa
294294
let ty_path = cx.tcx.def_path_str(edef.did);
295295
cx.tcx
296296
.struct_span_lint_hir(
297-
lint::builtin::BINDING_VARIANT_NAME,
297+
lint::builtin::BINDINGS_WITH_VARIANT_NAME,
298298
p.hir_id,
299299
p.span,
300300
&format!(

src/test/run-make-fulldeps/simd-ffi/simd.rs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,28 @@
44
// cross-compiled standard libraries.
55
#![feature(no_core, optin_builtin_traits)]
66
#![no_core]
7-
87
#![feature(repr_simd, simd_ffi, link_llvm_intrinsics, lang_items, rustc_attrs)]
98

10-
11-
#[repr(C)]
129
#[derive(Copy)]
1310
#[repr(simd)]
1411
pub struct f32x4(f32, f32, f32, f32);
1512

16-
17-
extern {
13+
extern "C" {
1814
#[link_name = "llvm.sqrt.v4f32"]
1915
fn vsqrt(x: f32x4) -> f32x4;
2016
}
2117

2218
pub fn foo(x: f32x4) -> f32x4 {
23-
unsafe {vsqrt(x)}
19+
unsafe { vsqrt(x) }
2420
}
2521

26-
#[repr(C)]
2722
#[derive(Copy)]
2823
#[repr(simd)]
2924
pub struct i32x4(i32, i32, i32, i32);
3025

31-
32-
extern {
26+
extern "C" {
3327
// _mm_sll_epi32
34-
#[cfg(any(target_arch = "x86",
35-
target_arch = "x86-64"))]
28+
#[cfg(any(target_arch = "x86", target_arch = "x86-64"))]
3629
#[link_name = "llvm.x86.sse2.psll.d"]
3730
fn integer(a: i32x4, b: i32x4) -> i32x4;
3831

@@ -48,22 +41,24 @@ extern {
4841
// just some substitute foreign symbol, not an LLVM intrinsic; so
4942
// we still get type checking, but not as detailed as (ab)using
5043
// LLVM.
51-
#[cfg(not(any(target_arch = "x86",
52-
target_arch = "x86-64",
53-
target_arch = "arm",
54-
target_arch = "aarch64")))]
44+
#[cfg(not(any(
45+
target_arch = "x86",
46+
target_arch = "x86-64",
47+
target_arch = "arm",
48+
target_arch = "aarch64"
49+
)))]
5550
fn integer(a: i32x4, b: i32x4) -> i32x4;
5651
}
5752

5853
pub fn bar(a: i32x4, b: i32x4) -> i32x4 {
59-
unsafe {integer(a, b)}
54+
unsafe { integer(a, b) }
6055
}
6156

6257
#[lang = "sized"]
63-
pub trait Sized { }
58+
pub trait Sized {}
6459

6560
#[lang = "copy"]
66-
pub trait Copy { }
61+
pub trait Copy {}
6762

6863
impl Copy for f32 {}
6964
impl Copy for i32 {}
@@ -77,4 +72,6 @@ auto trait Freeze {}
7772

7873
#[macro_export]
7974
#[rustc_builtin_macro]
80-
macro_rules! Copy { () => () }
75+
macro_rules! Copy {
76+
() => {};
77+
}

src/test/ui/conflicting-repr-hints.rs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
#![allow(dead_code)]
22

33
#[repr(C)]
4-
enum A { A }
4+
enum A {
5+
A,
6+
}
57

68
#[repr(u64)]
7-
enum B { B }
9+
enum B {
10+
B,
11+
}
812

9-
#[repr(C, u64)] //~ WARNING conflicting representation hints
10-
enum C { C }
13+
#[repr(C, u64)] //~ ERROR conflicting representation hints
14+
enum C {
15+
C,
16+
}
1117

12-
#[repr(u32, u64)] //~ WARNING conflicting representation hints
13-
enum D { D }
18+
#[repr(u32, u64)] //~ ERROR conflicting representation hints
19+
enum D {
20+
D,
21+
}
1422

1523
#[repr(C, packed)]
1624
struct E(i32);
@@ -37,20 +45,23 @@ struct J(i32); //~ ERROR type has conflicting packed representation hints
3745
struct K(i32);
3846

3947
#[repr(packed, align(8))]
40-
union X { //~ ERROR type has conflicting packed and align representation hints
41-
i: i32
48+
union X {
49+
//~^ ERROR type has conflicting packed and align representation hints
50+
i: i32,
4251
}
4352

4453
#[repr(packed)]
4554
#[repr(align(8))]
46-
union Y { //~ ERROR type has conflicting packed and align representation hints
47-
i: i32
55+
union Y {
56+
//~^ ERROR type has conflicting packed and align representation hints
57+
i: i32,
4858
}
4959

5060
#[repr(align(8))]
5161
#[repr(packed)]
52-
union Z { //~ ERROR type has conflicting packed and align representation hints
53-
i: i32
62+
union Z {
63+
//~^ ERROR type has conflicting packed and align representation hints
64+
i: i32,
5465
}
5566

5667
fn main() {}
Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,73 @@
1-
warning[E0566]: conflicting representation hints
2-
--> $DIR/conflicting-repr-hints.rs:9:8
1+
error[E0566]: conflicting representation hints
2+
--> $DIR/conflicting-repr-hints.rs:13:8
33
|
44
LL | #[repr(C, u64)]
55
| ^ ^^^
6-
|
7-
= note: `#[warn(conflicting_repr_hints)]` on by default
86

9-
warning[E0566]: conflicting representation hints
10-
--> $DIR/conflicting-repr-hints.rs:12:8
7+
error[E0566]: conflicting representation hints
8+
--> $DIR/conflicting-repr-hints.rs:18:8
119
|
1210
LL | #[repr(u32, u64)]
1311
| ^^^ ^^^
1412

1513
error[E0587]: type has conflicting packed and align representation hints
16-
--> $DIR/conflicting-repr-hints.rs:19:1
14+
--> $DIR/conflicting-repr-hints.rs:27:1
1715
|
1816
LL | struct F(i32);
1917
| ^^^^^^^^^^^^^^
2018

2119
error[E0587]: type has conflicting packed and align representation hints
22-
--> $DIR/conflicting-repr-hints.rs:23:1
20+
--> $DIR/conflicting-repr-hints.rs:31:1
2321
|
2422
LL | struct G(i32);
2523
| ^^^^^^^^^^^^^^
2624

2725
error[E0587]: type has conflicting packed and align representation hints
28-
--> $DIR/conflicting-repr-hints.rs:27:1
26+
--> $DIR/conflicting-repr-hints.rs:35:1
2927
|
3028
LL | struct H(i32);
3129
| ^^^^^^^^^^^^^^
3230

3331
error[E0634]: type has conflicting packed representation hints
34-
--> $DIR/conflicting-repr-hints.rs:30:1
32+
--> $DIR/conflicting-repr-hints.rs:38:1
3533
|
3634
LL | struct I(i32);
3735
| ^^^^^^^^^^^^^^
3836

3937
error[E0634]: type has conflicting packed representation hints
40-
--> $DIR/conflicting-repr-hints.rs:34:1
38+
--> $DIR/conflicting-repr-hints.rs:42:1
4139
|
4240
LL | struct J(i32);
4341
| ^^^^^^^^^^^^^^
4442

4543
error[E0587]: type has conflicting packed and align representation hints
46-
--> $DIR/conflicting-repr-hints.rs:40:1
44+
--> $DIR/conflicting-repr-hints.rs:48:1
4745
|
4846
LL | / union X {
49-
LL | | i: i32
47+
LL | |
48+
LL | | i: i32,
5049
LL | | }
5150
| |_^
5251

5352
error[E0587]: type has conflicting packed and align representation hints
54-
--> $DIR/conflicting-repr-hints.rs:46:1
53+
--> $DIR/conflicting-repr-hints.rs:55:1
5554
|
5655
LL | / union Y {
57-
LL | | i: i32
56+
LL | |
57+
LL | | i: i32,
5858
LL | | }
5959
| |_^
6060

6161
error[E0587]: type has conflicting packed and align representation hints
62-
--> $DIR/conflicting-repr-hints.rs:52:1
62+
--> $DIR/conflicting-repr-hints.rs:62:1
6363
|
6464
LL | / union Z {
65-
LL | | i: i32
65+
LL | |
66+
LL | | i: i32,
6667
LL | | }
6768
| |_^
6869

69-
error: aborting due to 8 previous errors
70+
error: aborting due to 10 previous errors
7071

7172
Some errors have detailed explanations: E0566, E0587.
7273
For more information about an error, try `rustc --explain E0566`.

src/test/ui/feature-gates/feature-gate-repr-simd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[repr(simd)] //~ error: SIMD types are experimental
22
struct Foo(u64, u64);
33

4-
#[repr(C)] //~ warn: conflicting representation hints
4+
#[repr(C)] //~ ERROR conflicting representation hints
55
#[repr(simd)] //~ error: SIMD types are experimental
66
struct Bar(u64, u64);
77

src/test/ui/feature-gates/feature-gate-repr-simd.stderr

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,15 @@ LL | #[repr(simd)]
1616
= note: for more information, see https://github.com/rust-lang/rust/issues/27731
1717
= help: add `#![feature(repr_simd)]` to the crate attributes to enable
1818

19-
warning[E0566]: conflicting representation hints
19+
error[E0566]: conflicting representation hints
2020
--> $DIR/feature-gate-repr-simd.rs:4:8
2121
|
2222
LL | #[repr(C)]
2323
| ^
2424
LL | #[repr(simd)]
2525
| ^^^^
26-
|
27-
= note: `#[warn(conflicting_repr_hints)]` on by default
2826

29-
error: aborting due to 2 previous errors
27+
error: aborting due to 3 previous errors
3028

3129
Some errors have detailed explanations: E0566, E0658.
3230
For more information about an error, try `rustc --explain E0566`.

src/test/ui/issues/issue-14221.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning[E0170]: pattern binding `A` is named the same as one of the variants of
44
LL | A => "A",
55
| ^ help: to match on the variant, qualify the path: `E::A`
66
|
7-
= note: `#[warn(binding_variant_name)]` on by default
7+
= note: `#[warn(bindings_with_variant_name)]` on by default
88

99
warning[E0170]: pattern binding `B` is named the same as one of the variants of the type `E`
1010
--> $DIR/issue-14221.rs:15:13

src/test/ui/issues/issue-19100.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning[E0170]: pattern binding `Bar` is named the same as one of the variants o
44
LL | Bar if true
55
| ^^^ help: to match on the variant, qualify the path: `Foo::Bar`
66
|
7-
= note: `#[warn(binding_variant_name)]` on by default
7+
= note: `#[warn(bindings_with_variant_name)]` on by default
88

99
warning[E0170]: pattern binding `Baz` is named the same as one of the variants of the type `Foo`
1010
--> $DIR/issue-19100.rs:22:1

src/test/ui/issues/issue-30302.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning[E0170]: pattern binding `Nil` is named the same as one of the variants o
44
LL | Nil => true,
55
| ^^^ help: to match on the variant, qualify the path: `Stack::Nil`
66
|
7-
= note: `#[warn(binding_variant_name)]` on by default
7+
= note: `#[warn(bindings_with_variant_name)]` on by default
88

99
error: unreachable pattern
1010
--> $DIR/issue-30302.rs:15:9

0 commit comments

Comments
 (0)