replace lit_snip type with &str

This commit is contained in:
Takayuki 2021-05-05 06:53:04 +09:00
parent 2dfb246d8e
commit 3fbb060379
4 changed files with 5 additions and 5 deletions

View File

@ -4,7 +4,7 @@ use rustc_lint::EarlyContext;
use super::MIXED_CASE_HEX_LITERALS;
pub(super) fn check(cx: &EarlyContext<'_>, lit: &Lit, suffix: &str, lit_snip: String) {
pub(super) fn check(cx: &EarlyContext<'_>, lit: &Lit, suffix: &str, lit_snip: &str) {
let maybe_last_sep_idx = if let Some(val) = lit_snip.len().checked_sub(suffix.len() + 1) {
val
} else {

View File

@ -334,11 +334,11 @@ impl MiscEarlyLints {
};
unseparated_literal_suffix::check(cx, lit, &lit_snip, suffix, "integer");
if lit_snip.starts_with("0x") {
mixed_case_hex_literals::check(cx, lit, suffix, lit_snip)
mixed_case_hex_literals::check(cx, lit, suffix, &lit_snip)
} else if lit_snip.starts_with("0b") || lit_snip.starts_with("0o") {
/* nothing to do */
} else if value != 0 && lit_snip.starts_with('0') {
zero_prefixed_literal::check(cx, lit, lit_snip)
zero_prefixed_literal::check(cx, lit, &lit_snip)
}
} else if let LitKind::Float(_, LitFloatType::Suffixed(float_ty)) = lit.kind {
let suffix = float_ty.name_str();

View File

@ -5,7 +5,7 @@ use rustc_lint::EarlyContext;
use super::UNSEPARATED_LITERAL_SUFFIX;
pub(super) fn check(cx: &EarlyContext<'_>, lit: &Lit, lit_snip: &String, suffix: &str, sugg_type: &str) {
pub(super) fn check(cx: &EarlyContext<'_>, lit: &Lit, lit_snip: &str, suffix: &str, sugg_type: &str) {
let maybe_last_sep_idx = if let Some(val) = lit_snip.len().checked_sub(suffix.len() + 1) {
val
} else {

View File

@ -5,7 +5,7 @@ use rustc_lint::EarlyContext;
use super::ZERO_PREFIXED_LITERAL;
pub(super) fn check(cx: &EarlyContext<'_>, lit: &Lit, lit_snip: String) {
pub(super) fn check(cx: &EarlyContext<'_>, lit: &Lit, lit_snip: &str) {
span_lint_and_then(
cx,
ZERO_PREFIXED_LITERAL,