Skip to content

Commit 7ed7fc8

Browse files
RalfJungoli-obk
authored andcommitted
add the lint back to the list, and fix tests
1 parent 94586bc commit 7ed7fc8

24 files changed

+74
-296
lines changed

src/librustc_lint/builtin.rs

-15
Original file line numberDiff line numberDiff line change
@@ -1607,17 +1607,6 @@ fn check_const(cx: &LateContext, body_id: hir::BodyId) {
16071607
let _ = cx.tcx.const_eval(param_env.and(cid));
16081608
}
16091609

1610-
struct UnusedBrokenConstVisitor<'a, 'tcx: 'a>(&'a LateContext<'a, 'tcx>);
1611-
1612-
impl<'a, 'tcx, 'v> hir::intravisit::Visitor<'v> for UnusedBrokenConstVisitor<'a, 'tcx> {
1613-
fn visit_nested_body(&mut self, id: hir::BodyId) {
1614-
check_const(self.0, id);
1615-
}
1616-
fn nested_visit_map<'this>(&'this mut self) -> hir::intravisit::NestedVisitorMap<'this, 'v> {
1617-
hir::intravisit::NestedVisitorMap::None
1618-
}
1619-
}
1620-
16211610
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedBrokenConst {
16221611
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
16231612
match it.node {
@@ -1627,10 +1616,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedBrokenConst {
16271616
hir::ItemKind::Static(_, _, body_id) => {
16281617
check_const(cx, body_id);
16291618
},
1630-
hir::ItemKind::Ty(ref ty, _) => hir::intravisit::walk_ty(
1631-
&mut UnusedBrokenConstVisitor(cx),
1632-
ty
1633-
),
16341619
_ => {},
16351620
}
16361621
}

src/librustc_lint/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
152152
UnreachablePub: UnreachablePub,
153153
UnnameableTestItems: UnnameableTestItems::new(),
154154
TypeAliasBounds: TypeAliasBounds,
155+
UnusedBrokenConst: UnusedBrokenConst,
155156
TrivialConstraints: TrivialConstraints,
156157
TypeLimits: TypeLimits::new(),
157158
MissingDoc: MissingDoc::new(),

src/test/ui/array_const_index-0.rs

+1-1
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

+1-8
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

+1-1
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

+1-8
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

+6-6
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

+1-38
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

-1
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

+1-8
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

+8-8
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

+1-50
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

+8-8
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

+1-50
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

+8-8
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

+1-50
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`.

0 commit comments

Comments
 (0)