Requested changes

This commit is contained in:
Jamie McClymont 2019-08-19 14:18:05 +12:00
parent 802a6d33da
commit 4ee9d02efa

View File

@ -1,4 +1,6 @@
use crate::utils::{constants, snippet, snippet_opt, span_help_and_lint, span_lint, span_lint_and_then}; use crate::utils::{
constants, snippet, snippet_opt, span_help_and_lint, span_lint, span_lint_and_sugg, span_lint_and_then,
};
use if_chain::if_chain; use if_chain::if_chain;
use rustc::lint::{in_external_macro, EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass}; use rustc::lint::{in_external_macro, EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass};
use rustc::{declare_lint_pass, declare_tool_lint}; use rustc::{declare_lint_pass, declare_tool_lint};
@ -399,20 +401,15 @@ impl MiscEarlyLints {
for (idx, ch) in src.chars().enumerate() { for (idx, ch) in src.chars().enumerate() {
if ch == 'i' || ch == 'u' { if ch == 'i' || ch == 'u' {
if prev != '_' { if prev != '_' {
span_lint_and_then( span_lint_and_sugg(
cx, cx,
UNSEPARATED_LITERAL_SUFFIX, UNSEPARATED_LITERAL_SUFFIX,
lit.span, lit.span,
"integer type suffix should be separated by an underscore", "integer type suffix should be separated by an underscore",
|db| {
db.span_suggestion(
lit.span,
"add an underscore", "add an underscore",
format!("{}_{}", &src[0..idx], &src[idx..]), format!("{}_{}", &src[0..idx], &src[idx..]),
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
},
);
} }
break; break;
} }
@ -466,20 +463,15 @@ impl MiscEarlyLints {
for (idx, ch) in src.chars().enumerate() { for (idx, ch) in src.chars().enumerate() {
if ch == 'f' { if ch == 'f' {
if prev != '_' { if prev != '_' {
span_lint_and_then( span_lint_and_sugg(
cx, cx,
UNSEPARATED_LITERAL_SUFFIX, UNSEPARATED_LITERAL_SUFFIX,
lit.span, lit.span,
"float type suffix should be separated by an underscore", "float type suffix should be separated by an underscore",
|db| {
db.span_suggestion(
lit.span,
"add an underscore", "add an underscore",
format!("{}_{}", &src[0..idx], &src[idx..]), format!("{}_{}", &src[0..idx], &src[idx..]),
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
},
);
} }
break; break;
} }