Closed

Description
Summary
When this code is ran through clippy, it suggests invalid code.
Lint Name
zero_prefixed_literal
Reproducer
I tried this code:
fn main() {
let x = 08;
}
I saw this happen:
warning: this is a decimal constant
--> src/main.rs:2:13
|
2 | let x = 08;
| ^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal
= note: `#[warn(clippy::zero_prefixed_literal)]` on by default
help: if you mean to use a decimal constant, remove the `0` to avoid confusion
|
2 | let x = 8;
| ~
help: if you mean to use an octal constant, use `0o`
|
2 | let x = 0o8;
I expected to see this happen: Clippy to not suggest a borked suggestion. As running
fn main() {
let x = 0o8;
}
results in
error: invalid digit for a base 8 literal
--> src/main.rs:2:15
|
2 | let x = 0o8;
|
Version
rustc 1.66.0-nightly (bf15a9e52 2022-10-14)
binary: rustc
commit-hash: bf15a9e5263fcea065a7ae9c179b2d24c2deb670
commit-date: 2022-10-14
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.2
Additional Labels
@rustbot label +I-suggestion-causes-error