From e922fa80ce5847be4c1cf9926313a02ba6a2b7ae Mon Sep 17 00:00:00 2001 From: mcarton Date: Sun, 28 Aug 2016 17:59:01 +0200 Subject: [PATCH] Fix FP in `ZERO_PREFIXED_LITERAL` and `0b`/`Oo` --- CHANGELOG.md | 3 +++ clippy_lints/src/misc_early.rs | 2 ++ tests/compile-fail/literals.rs | 3 +++ 3 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 185072debab..636ca3f4f2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Change Log All notable changes to this project will be documented in this file. +## 0.0.87 — ?? +* Fix FP in [`zero_prefixed_literal`] and `0b`/`Oo` + ## 0.0.86 — 2016-08-28 * Rustup to *rustc 1.13.0-nightly (a23064af5 2016-08-27)* * New lints: [`missing_docs_in_private_items`], [`zero_prefixed_literal`] diff --git a/clippy_lints/src/misc_early.rs b/clippy_lints/src/misc_early.rs index 916801943b7..83ba980334a 100644 --- a/clippy_lints/src/misc_early.rs +++ b/clippy_lints/src/misc_early.rs @@ -287,6 +287,8 @@ impl EarlyLintPass for MiscEarly { span_lint(cx, MIXED_CASE_HEX_LITERALS, lit.span, "inconsistent casing in hexadecimal literal"); } + } else if src.starts_with("0b") || src.starts_with("0o") { + /* nothing to do */ } else if value != 0 && src.starts_with('0') { span_lint_and_then(cx, ZERO_PREFIXED_LITERAL, diff --git a/tests/compile-fail/literals.rs b/tests/compile-fail/literals.rs index 91a63646998..6c8a27c2ed4 100644 --- a/tests/compile-fail/literals.rs +++ b/tests/compile-fail/literals.rs @@ -32,4 +32,7 @@ fn main() { //~|SUGGESTION = 123; //~|HELP use `0o` //~|SUGGESTION = 0o123; + + let ok11 = 0o123; + let ok12 = 0b101010; }