Skip to content

Commit 99f404a

Browse files
authored
Rollup merge of #114051 - Enselic:const-local-var, r=cjgillot
Add regression test for invalid "unused const" in method The warning can be reproduced with 1.63 but not with 1.64. $ rustc +1.63 tests/ui/lint/unused/const-local-var.rs warning: constant `F` is never used --> tests/ui/lint/unused/const-local-var.rs:14:9 | 14 | const F: i32 = 2; | ^^^^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default $ rustc +1.64 tests/ui/lint/unused/const-local-var.rs Add a regression test to prevent the problem from re-appearing. Closes #69016
2 parents 91d1d7a + 5d32fd1 commit 99f404a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// regression test for https://github.com/rust-lang/rust/issues/69016
2+
// check-pass
3+
4+
#![warn(unused)]
5+
#![deny(warnings)]
6+
7+
fn _unused1(x: i32) -> i32 {
8+
const F: i32 = 2;
9+
let g = 1;
10+
x * F + g
11+
}
12+
13+
pub struct Foo {}
14+
15+
impl Foo {
16+
fn _unused2(x: i32) -> i32 {
17+
const F: i32 = 2;
18+
let g = 1;
19+
x * F + g
20+
}
21+
}
22+
23+
fn main() {}

0 commit comments

Comments
 (0)