Skip to content

Commit a1cfc95

Browse files
committed
add the lint back to the list, and fix tests
1 parent 760f3af commit a1cfc95

23 files changed

+74
-285
lines changed

src/librustc_lint/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
150150
UnreachablePub: UnreachablePub,
151151
UnnameableTestItems: UnnameableTestItems::new(),
152152
TypeAliasBounds: TypeAliasBounds,
153+
UnusedBrokenConst: UnusedBrokenConst,
153154
TrivialConstraints: TrivialConstraints,
154155
TypeLimits: TypeLimits::new(),
155156
MissingDoc: MissingDoc::new(),

src/test/ui/array_const_index-0.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ const B: i32 = (&A)[1];
1414
//~| ERROR any use of this value will cause an error
1515

1616
fn main() {
17-
let _ = B; //~ ERROR erroneous constant used
17+
let _ = B;
1818
}

src/test/ui/array_const_index-0.stderr

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,5 @@ LL | const B: i32 = (&A)[1];
88
|
99
= note: #[deny(const_err)] on by default
1010

11-
error[E0080]: erroneous constant used
12-
--> $DIR/array_const_index-0.rs:17:13
13-
|
14-
LL | let _ = B; //~ ERROR erroneous constant used
15-
| ^ referenced constant has errors
16-
17-
error: aborting due to 2 previous errors
11+
error: aborting due to previous error
1812

19-
For more information about this error, try `rustc --explain E0080`.

src/test/ui/array_const_index-1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ const B: i32 = A[1];
1414
//~| ERROR any use of this value will cause an error
1515

1616
fn main() {
17-
let _ = B; //~ ERROR erroneous constant used
17+
let _ = B;
1818
}

src/test/ui/array_const_index-1.stderr

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,5 @@ LL | const B: i32 = A[1];
88
|
99
= note: #[deny(const_err)] on by default
1010

11-
error[E0080]: erroneous constant used
12-
--> $DIR/array_const_index-1.rs:17:13
13-
|
14-
LL | let _ = B; //~ ERROR erroneous constant used
15-
| ^ referenced constant has errors
16-
17-
error: aborting due to 2 previous errors
11+
error: aborting due to previous error
1812

19-
For more information about this error, try `rustc --explain E0080`.

src/test/ui/consts/const-err-early.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR const_err
1717
pub const E: u8 = [5u8][1]; //~ ERROR const_err
1818

1919
fn main() {
20-
let _a = A; //~ ERROR erroneous constant used
21-
let _b = B; //~ ERROR erroneous constant used
22-
let _c = C; //~ ERROR erroneous constant used
23-
let _d = D; //~ ERROR erroneous constant used
24-
let _e = E; //~ ERROR erroneous constant used
25-
let _e = [6u8][1]; //~ ERROR index out of bounds
20+
let _a = A;
21+
let _b = B;
22+
let _c = C;
23+
let _d = D;
24+
let _e = E;
25+
let _e = [6u8][1];
2626
}

src/test/ui/consts/const-err-early.stderr

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -44,42 +44,5 @@ LL | pub const E: u8 = [5u8][1]; //~ ERROR const_err
4444
| |
4545
| index out of bounds: the len is 1 but the index is 1
4646

47-
error[E0080]: erroneous constant used
48-
--> $DIR/const-err-early.rs:20:14
49-
|
50-
LL | let _a = A; //~ ERROR erroneous constant used
51-
| ^ referenced constant has errors
52-
53-
error[E0080]: erroneous constant used
54-
--> $DIR/const-err-early.rs:21:14
55-
|
56-
LL | let _b = B; //~ ERROR erroneous constant used
57-
| ^ referenced constant has errors
58-
59-
error[E0080]: erroneous constant used
60-
--> $DIR/const-err-early.rs:22:14
61-
|
62-
LL | let _c = C; //~ ERROR erroneous constant used
63-
| ^ referenced constant has errors
64-
65-
error[E0080]: erroneous constant used
66-
--> $DIR/const-err-early.rs:23:14
67-
|
68-
LL | let _d = D; //~ ERROR erroneous constant used
69-
| ^ referenced constant has errors
70-
71-
error[E0080]: erroneous constant used
72-
--> $DIR/const-err-early.rs:24:14
73-
|
74-
LL | let _e = E; //~ ERROR erroneous constant used
75-
| ^ referenced constant has errors
76-
77-
error: index out of bounds: the len is 1 but the index is 1
78-
--> $DIR/const-err-early.rs:25:14
79-
|
80-
LL | let _e = [6u8][1]; //~ ERROR index out of bounds
81-
| ^^^^^^^^
82-
83-
error: aborting due to 11 previous errors
47+
error: aborting due to 5 previous errors
8448

85-
For more information about this error, try `rustc --explain E0080`.

src/test/ui/consts/const-err-multi.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,4 @@ pub const D: i8 = 50 - A;
2121

2222
fn main() {
2323
let _ = (A, B, C, D);
24-
//~^ ERROR erroneous constant used
2524
}

src/test/ui/consts/const-err-multi.stderr

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,5 @@ LL | pub const D: i8 = 50 - A;
3636
| |
3737
| referenced constant has errors
3838

39-
error[E0080]: erroneous constant used
40-
--> $DIR/const-err-multi.rs:23:13
41-
|
42-
LL | let _ = (A, B, C, D);
43-
| ^^^^^^^^^^^^ referenced constant has errors
44-
45-
error: aborting due to 5 previous errors
39+
error: aborting due to 4 previous errors
4640

47-
For more information about this error, try `rustc --explain E0080`.

src/test/ui/consts/const-eval/const-eval-overflow2.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error
6060
);
6161

6262
fn main() {
63-
foo(VALS_I8); //~ ERROR erroneous constant used
64-
foo(VALS_I16); //~ ERROR erroneous constant used
65-
foo(VALS_I32); //~ ERROR erroneous constant used
66-
foo(VALS_I64); //~ ERROR erroneous constant used
63+
foo(VALS_I8);
64+
foo(VALS_I16);
65+
foo(VALS_I32);
66+
foo(VALS_I64);
6767

68-
foo(VALS_U8); //~ ERROR erroneous constant used
69-
foo(VALS_U16); //~ ERROR erroneous constant used
70-
foo(VALS_U32); //~ ERROR erroneous constant used
71-
foo(VALS_U64); //~ ERROR erroneous constant used
68+
foo(VALS_U8);
69+
foo(VALS_U16);
70+
foo(VALS_U32);
71+
foo(VALS_U64);
7272
}
7373

7474
fn foo<T>(_: T) {

src/test/ui/consts/const-eval/const-eval-overflow2.stderr

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -82,54 +82,5 @@ LL | | u64::MIN - 1,
8282
LL | | );
8383
| |_______^
8484

85-
error[E0080]: erroneous constant used
86-
--> $DIR/const-eval-overflow2.rs:63:5
87-
|
88-
LL | foo(VALS_I8); //~ ERROR erroneous constant used
89-
| ^^^^^^^^^^^^ referenced constant has errors
90-
91-
error[E0080]: erroneous constant used
92-
--> $DIR/const-eval-overflow2.rs:64:5
93-
|
94-
LL | foo(VALS_I16); //~ ERROR erroneous constant used
95-
| ^^^^^^^^^^^^^ referenced constant has errors
96-
97-
error[E0080]: erroneous constant used
98-
--> $DIR/const-eval-overflow2.rs:65:5
99-
|
100-
LL | foo(VALS_I32); //~ ERROR erroneous constant used
101-
| ^^^^^^^^^^^^^ referenced constant has errors
102-
103-
error[E0080]: erroneous constant used
104-
--> $DIR/const-eval-overflow2.rs:66:5
105-
|
106-
LL | foo(VALS_I64); //~ ERROR erroneous constant used
107-
| ^^^^^^^^^^^^^ referenced constant has errors
108-
109-
error[E0080]: erroneous constant used
110-
--> $DIR/const-eval-overflow2.rs:68:5
111-
|
112-
LL | foo(VALS_U8); //~ ERROR erroneous constant used
113-
| ^^^^^^^^^^^^ referenced constant has errors
114-
115-
error[E0080]: erroneous constant used
116-
--> $DIR/const-eval-overflow2.rs:69:5
117-
|
118-
LL | foo(VALS_U16); //~ ERROR erroneous constant used
119-
| ^^^^^^^^^^^^^ referenced constant has errors
120-
121-
error[E0080]: erroneous constant used
122-
--> $DIR/const-eval-overflow2.rs:70:5
123-
|
124-
LL | foo(VALS_U32); //~ ERROR erroneous constant used
125-
| ^^^^^^^^^^^^^ referenced constant has errors
126-
127-
error[E0080]: erroneous constant used
128-
--> $DIR/const-eval-overflow2.rs:71:5
129-
|
130-
LL | foo(VALS_U64); //~ ERROR erroneous constant used
131-
| ^^^^^^^^^^^^^ referenced constant has errors
132-
133-
error: aborting due to 16 previous errors
85+
error: aborting due to 8 previous errors
13486

135-
For more information about this error, try `rustc --explain E0080`.

src/test/ui/consts/const-eval/const-eval-overflow2b.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error
6060
);
6161

6262
fn main() {
63-
foo(VALS_I8); //~ ERROR erroneous constant used
64-
foo(VALS_I16); //~ ERROR erroneous constant used
65-
foo(VALS_I32); //~ ERROR erroneous constant used
66-
foo(VALS_I64); //~ ERROR erroneous constant used
63+
foo(VALS_I8);
64+
foo(VALS_I16);
65+
foo(VALS_I32);
66+
foo(VALS_I64);
6767

68-
foo(VALS_U8); //~ ERROR erroneous constant used
69-
foo(VALS_U16); //~ ERROR erroneous constant used
70-
foo(VALS_U32); //~ ERROR erroneous constant used
71-
foo(VALS_U64); //~ ERROR erroneous constant used
68+
foo(VALS_U8);
69+
foo(VALS_U16);
70+
foo(VALS_U32);
71+
foo(VALS_U64);
7272
}
7373

7474
fn foo<T>(_: T) {

src/test/ui/consts/const-eval/const-eval-overflow2b.stderr

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -82,54 +82,5 @@ LL | | u64::MAX + 1,
8282
LL | | );
8383
| |_______^
8484

85-
error[E0080]: erroneous constant used
86-
--> $DIR/const-eval-overflow2b.rs:63:5
87-
|
88-
LL | foo(VALS_I8); //~ ERROR erroneous constant used
89-
| ^^^^^^^^^^^^ referenced constant has errors
90-
91-
error[E0080]: erroneous constant used
92-
--> $DIR/const-eval-overflow2b.rs:64:5
93-
|
94-
LL | foo(VALS_I16); //~ ERROR erroneous constant used
95-
| ^^^^^^^^^^^^^ referenced constant has errors
96-
97-
error[E0080]: erroneous constant used
98-
--> $DIR/const-eval-overflow2b.rs:65:5
99-
|
100-
LL | foo(VALS_I32); //~ ERROR erroneous constant used
101-
| ^^^^^^^^^^^^^ referenced constant has errors
102-
103-
error[E0080]: erroneous constant used
104-
--> $DIR/const-eval-overflow2b.rs:66:5
105-
|
106-
LL | foo(VALS_I64); //~ ERROR erroneous constant used
107-
| ^^^^^^^^^^^^^ referenced constant has errors
108-
109-
error[E0080]: erroneous constant used
110-
--> $DIR/const-eval-overflow2b.rs:68:5
111-
|
112-
LL | foo(VALS_U8); //~ ERROR erroneous constant used
113-
| ^^^^^^^^^^^^ referenced constant has errors
114-
115-
error[E0080]: erroneous constant used
116-
--> $DIR/const-eval-overflow2b.rs:69:5
117-
|
118-
LL | foo(VALS_U16); //~ ERROR erroneous constant used
119-
| ^^^^^^^^^^^^^ referenced constant has errors
120-
121-
error[E0080]: erroneous constant used
122-
--> $DIR/const-eval-overflow2b.rs:70:5
123-
|
124-
LL | foo(VALS_U32); //~ ERROR erroneous constant used
125-
| ^^^^^^^^^^^^^ referenced constant has errors
126-
127-
error[E0080]: erroneous constant used
128-
--> $DIR/const-eval-overflow2b.rs:71:5
129-
|
130-
LL | foo(VALS_U64); //~ ERROR erroneous constant used
131-
| ^^^^^^^^^^^^^ referenced constant has errors
132-
133-
error: aborting due to 16 previous errors
85+
error: aborting due to 8 previous errors
13486

135-
For more information about this error, try `rustc --explain E0080`.

src/test/ui/consts/const-eval/const-eval-overflow2c.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error
6060
);
6161

6262
fn main() {
63-
foo(VALS_I8); //~ ERROR erroneous constant used
64-
foo(VALS_I16); //~ ERROR erroneous constant used
65-
foo(VALS_I32); //~ ERROR erroneous constant used
66-
foo(VALS_I64); //~ ERROR erroneous constant used
63+
foo(VALS_I8);
64+
foo(VALS_I16);
65+
foo(VALS_I32);
66+
foo(VALS_I64);
6767

68-
foo(VALS_U8); //~ ERROR erroneous constant used
69-
foo(VALS_U16); //~ ERROR erroneous constant used
70-
foo(VALS_U32); //~ ERROR erroneous constant used
71-
foo(VALS_U64); //~ ERROR erroneous constant used
68+
foo(VALS_U8);
69+
foo(VALS_U16);
70+
foo(VALS_U32);
71+
foo(VALS_U64);
7272
}
7373

7474
fn foo<T>(_: T) {

src/test/ui/consts/const-eval/const-eval-overflow2c.stderr

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -82,54 +82,5 @@ LL | | u64::MAX * 2,
8282
LL | | );
8383
| |_______^
8484

85-
error[E0080]: erroneous constant used
86-
--> $DIR/const-eval-overflow2c.rs:63:5
87-
|
88-
LL | foo(VALS_I8); //~ ERROR erroneous constant used
89-
| ^^^^^^^^^^^^ referenced constant has errors
90-
91-
error[E0080]: erroneous constant used
92-
--> $DIR/const-eval-overflow2c.rs:64:5
93-
|
94-
LL | foo(VALS_I16); //~ ERROR erroneous constant used
95-
| ^^^^^^^^^^^^^ referenced constant has errors
96-
97-
error[E0080]: erroneous constant used
98-
--> $DIR/const-eval-overflow2c.rs:65:5
99-
|
100-
LL | foo(VALS_I32); //~ ERROR erroneous constant used
101-
| ^^^^^^^^^^^^^ referenced constant has errors
102-
103-
error[E0080]: erroneous constant used
104-
--> $DIR/const-eval-overflow2c.rs:66:5
105-
|
106-
LL | foo(VALS_I64); //~ ERROR erroneous constant used
107-
| ^^^^^^^^^^^^^ referenced constant has errors
108-
109-
error[E0080]: erroneous constant used
110-
--> $DIR/const-eval-overflow2c.rs:68:5
111-
|
112-
LL | foo(VALS_U8); //~ ERROR erroneous constant used
113-
| ^^^^^^^^^^^^ referenced constant has errors
114-
115-
error[E0080]: erroneous constant used
116-
--> $DIR/const-eval-overflow2c.rs:69:5
117-
|
118-
LL | foo(VALS_U16); //~ ERROR erroneous constant used
119-
| ^^^^^^^^^^^^^ referenced constant has errors
120-
121-
error[E0080]: erroneous constant used
122-
--> $DIR/const-eval-overflow2c.rs:70:5
123-
|
124-
LL | foo(VALS_U32); //~ ERROR erroneous constant used
125-
| ^^^^^^^^^^^^^ referenced constant has errors
126-
127-
error[E0080]: erroneous constant used
128-
--> $DIR/const-eval-overflow2c.rs:71:5
129-
|
130-
LL | foo(VALS_U64); //~ ERROR erroneous constant used
131-
| ^^^^^^^^^^^^^ referenced constant has errors
132-
133-
error: aborting due to 16 previous errors
85+
error: aborting due to 8 previous errors
13486

135-
For more information about this error, try `rustc --explain E0080`.

src/test/ui/consts/const-eval/pub_const_err.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,3 @@
1515

1616
pub const Z: u32 = 0 - 1;
1717
//~^ WARN this constant cannot be used
18-
19-
pub type Foo = [i32; 0 - 1];
20-
//~^ WARN attempt to subtract with overflow
21-
//~| WARN this array length cannot be used

src/test/ui/consts/const-eval/pub_const_err_bin.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,4 @@
1414
pub const Z: u32 = 0 - 1;
1515
//~^ WARN this constant cannot be used
1616

17-
pub type Foo = [i32; 0 - 1];
18-
//~^ WARN attempt to subtract with overflow
19-
//~| WARN this array length cannot be used
20-
2117
fn main() {}

0 commit comments

Comments
 (0)