Fix adjacent code
This commit is contained in:
parent
ed519ad746
commit
26df55112f
@ -54,7 +54,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>, msrv: &Msrv
|
|||||||
|
|
||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
expr.span,
|
expr.span,
|
||||||
&format!("replace with `ptr::slice_from_raw_parts{mutbl_fn_str}`"),
|
format!("replace with `ptr::slice_from_raw_parts{mutbl_fn_str}`"),
|
||||||
sugg,
|
sugg,
|
||||||
rustc_errors::Applicability::HasPlaceholders,
|
rustc_errors::Applicability::HasPlaceholders,
|
||||||
);
|
);
|
||||||
|
@ -377,7 +377,7 @@ fn check_format_in_format_args(cx: &LateContext<'_>, call_site: Span, name: Symb
|
|||||||
call_site,
|
call_site,
|
||||||
&format!("`format!` in `{name}!` args"),
|
&format!("`format!` in `{name}!` args"),
|
||||||
|diag| {
|
|diag| {
|
||||||
diag.help(&format!(
|
diag.help(format!(
|
||||||
"combine the `format!(..)` arguments with the outer `{name}!(..)` call"
|
"combine the `format!(..)` arguments with the outer `{name}!(..)` call"
|
||||||
));
|
));
|
||||||
diag.help("or consider changing `format!` to `format_args!`");
|
diag.help("or consider changing `format!` to `format_args!`");
|
||||||
|
@ -111,7 +111,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &Item<'tcx>) {
|
|||||||
);
|
);
|
||||||
diag.span_label(
|
diag.span_label(
|
||||||
def.variants[variants_size[1].ind].span,
|
def.variants[variants_size[1].ind].span,
|
||||||
&if variants_size[1].fields_size.is_empty() {
|
if variants_size[1].fields_size.is_empty() {
|
||||||
"the second-largest variant carries no data at all".to_owned()
|
"the second-largest variant carries no data at all".to_owned()
|
||||||
} else {
|
} else {
|
||||||
format!(
|
format!(
|
||||||
|
@ -361,7 +361,7 @@ fn check_for_is_empty<'tcx>(
|
|||||||
db.span_note(span, "`is_empty` defined here");
|
db.span_note(span, "`is_empty` defined here");
|
||||||
}
|
}
|
||||||
if let Some(self_kind) = self_kind {
|
if let Some(self_kind) = self_kind {
|
||||||
db.note(&output.expected_sig(self_kind));
|
db.note(output.expected_sig(self_kind));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -335,7 +335,7 @@ pub fn read_conf(sess: &Session, path: &io::Result<Option<PathBuf>>) -> Conf {
|
|||||||
Ok(Some(path)) => path,
|
Ok(Some(path)) => path,
|
||||||
Ok(None) => return Conf::default(),
|
Ok(None) => return Conf::default(),
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
sess.struct_err(&format!("error finding Clippy's configuration file: {error}"))
|
sess.struct_err(format!("error finding Clippy's configuration file: {error}"))
|
||||||
.emit();
|
.emit();
|
||||||
return Conf::default();
|
return Conf::default();
|
||||||
},
|
},
|
||||||
|
@ -77,7 +77,7 @@ pub(super) fn check<'tcx>(
|
|||||||
applicability,
|
applicability,
|
||||||
);
|
);
|
||||||
|
|
||||||
diag.note(&format!(
|
diag.note(format!(
|
||||||
"`{name}` is of type `{int_name}`, making it ineligible for `Iterator::enumerate`"
|
"`{name}` is of type `{int_name}`, making it ineligible for `Iterator::enumerate`"
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
|
@ -76,7 +76,7 @@ fn check_fn(
|
|||||||
let help = format!("make the function `async` and {ret_sugg}");
|
let help = format!("make the function `async` and {ret_sugg}");
|
||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
header_span,
|
header_span,
|
||||||
&help,
|
help,
|
||||||
format!("async {}{ret_snip}", &header_snip[..ret_pos]),
|
format!("async {}{ret_snip}", &header_snip[..ret_pos]),
|
||||||
Applicability::MachineApplicable
|
Applicability::MachineApplicable
|
||||||
);
|
);
|
||||||
|
@ -109,7 +109,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
|||||||
|
|
||||||
let test_span = expr.span.until(then.span);
|
let test_span = expr.span.until(then.span);
|
||||||
span_lint_and_then(cx, MANUAL_STRIP, strippings[0], &format!("stripping a {kind_word} manually"), |diag| {
|
span_lint_and_then(cx, MANUAL_STRIP, strippings[0], &format!("stripping a {kind_word} manually"), |diag| {
|
||||||
diag.span_note(test_span, &format!("the {kind_word} was tested here"));
|
diag.span_note(test_span, format!("the {kind_word} was tested here"));
|
||||||
multispan_sugg(
|
multispan_sugg(
|
||||||
diag,
|
diag,
|
||||||
&format!("try using the `strip_{kind_word}` method"),
|
&format!("try using the `strip_{kind_word}` method"),
|
||||||
|
@ -36,7 +36,7 @@ pub fn check(
|
|||||||
expr.span,
|
expr.span,
|
||||||
&format!("calling `to_string` on `{arg_ty}`"),
|
&format!("calling `to_string` on `{arg_ty}`"),
|
||||||
|diag| {
|
|diag| {
|
||||||
diag.help(&format!(
|
diag.help(format!(
|
||||||
"`{self_ty}` implements `ToString` through a slower blanket impl, but `{deref_self_ty}` has a fast specialization of `ToString`"
|
"`{self_ty}` implements `ToString` through a slower blanket impl, but `{deref_self_ty}` has a fast specialization of `ToString`"
|
||||||
));
|
));
|
||||||
let mut applicability = Applicability::MachineApplicable;
|
let mut applicability = Applicability::MachineApplicable;
|
||||||
|
@ -29,7 +29,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr
|
|||||||
application = Applicability::Unspecified;
|
application = Applicability::Unspecified;
|
||||||
diag.span_help(
|
diag.span_help(
|
||||||
pat.span,
|
pat.span,
|
||||||
&format!("for this change `{}` has to be mutable", snippet(cx, pat.span, "..")),
|
format!("for this change `{}` has to be mutable", snippet(cx, pat.span, "..")),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ pub(super) fn check<'tcx>(
|
|||||||
suggestion.push((map_arg_span.with_hi(map_arg_span.lo()), format!("{unwrap_snippet}, ")));
|
suggestion.push((map_arg_span.with_hi(map_arg_span.lo()), format!("{unwrap_snippet}, ")));
|
||||||
}
|
}
|
||||||
|
|
||||||
diag.multipart_suggestion(&format!("use `{suggest}` instead"), suggestion, applicability);
|
diag.multipart_suggestion(format!("use `{suggest}` instead"), suggestion, applicability);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ fn check_manual_split_once_indirect(
|
|||||||
};
|
};
|
||||||
diag.span_suggestion_verbose(
|
diag.span_suggestion_verbose(
|
||||||
local.span,
|
local.span,
|
||||||
&format!("try `{r}split_once`"),
|
format!("try `{r}split_once`"),
|
||||||
format!("let ({lhs}, {rhs}) = {self_snip}.{r}split_once({pat_snip}){unwrap};"),
|
format!("let ({lhs}, {rhs}) = {self_snip}.{r}split_once({pat_snip}){unwrap};"),
|
||||||
app,
|
app,
|
||||||
);
|
);
|
||||||
|
@ -62,7 +62,7 @@ pub(super) fn check<'tcx>(
|
|||||||
span_lint_and_then(cx, UNNECESSARY_LAZY_EVALUATIONS, expr.span, msg, |diag| {
|
span_lint_and_then(cx, UNNECESSARY_LAZY_EVALUATIONS, expr.span, msg, |diag| {
|
||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
span,
|
span,
|
||||||
&format!("use `{simplify_using}(..)` instead"),
|
format!("use `{simplify_using}(..)` instead"),
|
||||||
format!("{simplify_using}({})", snippet(cx, body_expr.span, "..")),
|
format!("{simplify_using}({})", snippet(cx, body_expr.span, "..")),
|
||||||
applicability,
|
applicability,
|
||||||
);
|
);
|
||||||
|
@ -284,7 +284,7 @@ fn check<'tcx>(
|
|||||||
|
|
||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
assign.lhs_span,
|
assign.lhs_span,
|
||||||
&format!("declare `{binding_name}` here"),
|
format!("declare `{binding_name}` here"),
|
||||||
let_snippet,
|
let_snippet,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
@ -304,7 +304,7 @@ fn check<'tcx>(
|
|||||||
|
|
||||||
diag.span_suggestion_verbose(
|
diag.span_suggestion_verbose(
|
||||||
usage.stmt.span.shrink_to_lo(),
|
usage.stmt.span.shrink_to_lo(),
|
||||||
&format!("declare `{binding_name}` here"),
|
format!("declare `{binding_name}` here"),
|
||||||
format!("{let_snippet} = "),
|
format!("{let_snippet} = "),
|
||||||
applicability,
|
applicability,
|
||||||
);
|
);
|
||||||
@ -335,7 +335,7 @@ fn check<'tcx>(
|
|||||||
|
|
||||||
diag.span_suggestion_verbose(
|
diag.span_suggestion_verbose(
|
||||||
usage.stmt.span.shrink_to_lo(),
|
usage.stmt.span.shrink_to_lo(),
|
||||||
&format!("declare `{binding_name}` here"),
|
format!("declare `{binding_name}` here"),
|
||||||
format!("{let_snippet} = "),
|
format!("{let_snippet} = "),
|
||||||
applicability,
|
applicability,
|
||||||
);
|
);
|
||||||
|
@ -125,7 +125,7 @@ fn check_lit(cx: &EarlyContext<'_>, lit: &Lit, span: Span, is_string: bool) {
|
|||||||
if is_string { "string" } else { "byte string" }
|
if is_string { "string" } else { "byte string" }
|
||||||
),
|
),
|
||||||
|diag| {
|
|diag| {
|
||||||
diag.help(&format!(
|
diag.help(format!(
|
||||||
"octal escapes are not supported, `\\0` is always a null {}",
|
"octal escapes are not supported, `\\0` is always a null {}",
|
||||||
if is_string { "character" } else { "byte" }
|
if is_string { "character" } else { "byte" }
|
||||||
));
|
));
|
||||||
@ -139,7 +139,7 @@ fn check_lit(cx: &EarlyContext<'_>, lit: &Lit, span: Span, is_string: bool) {
|
|||||||
// suggestion 2: unambiguous null byte
|
// suggestion 2: unambiguous null byte
|
||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
span,
|
span,
|
||||||
&format!(
|
format!(
|
||||||
"if the null {} is intended, disambiguate using",
|
"if the null {} is intended, disambiguate using",
|
||||||
if is_string { "character" } else { "byte" }
|
if is_string { "character" } else { "byte" }
|
||||||
),
|
),
|
||||||
|
@ -50,7 +50,7 @@ fn lint_misrefactored_assign_op(
|
|||||||
let long = format!("{snip_a} = {}", sugg::make_binop(op.into(), a, r));
|
let long = format!("{snip_a} = {}", sugg::make_binop(op.into(), a, r));
|
||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
expr.span,
|
expr.span,
|
||||||
&format!(
|
format!(
|
||||||
"did you mean `{snip_a} = {snip_a} {} {snip_r}` or `{long}`? Consider replacing it with",
|
"did you mean `{snip_a} = {snip_a} {} {snip_r}` or `{long}`? Consider replacing it with",
|
||||||
op.as_str()
|
op.as_str()
|
||||||
),
|
),
|
||||||
|
@ -108,7 +108,7 @@ fn check_crate_post(&mut self, cx: &LateContext<'tcx>) {
|
|||||||
|diag| {
|
|diag| {
|
||||||
diag.span_note(
|
diag.span_note(
|
||||||
trait_method_span,
|
trait_method_span,
|
||||||
&format!("existing `{method_name}` defined here"),
|
format!("existing `{method_name}` defined here"),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -151,7 +151,7 @@ fn check_crate_post(&mut self, cx: &LateContext<'tcx>) {
|
|||||||
// iterate on trait_spans?
|
// iterate on trait_spans?
|
||||||
diag.span_note(
|
diag.span_note(
|
||||||
trait_spans[0],
|
trait_spans[0],
|
||||||
&format!("existing `{method_name}` defined here"),
|
format!("existing `{method_name}` defined here"),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -132,7 +132,7 @@ fn generate_swap_warning(cx: &LateContext<'_>, e1: &Expr<'_>, e2: &Expr<'_>, spa
|
|||||||
applicability,
|
applicability,
|
||||||
);
|
);
|
||||||
if !is_xor_based {
|
if !is_xor_based {
|
||||||
diag.note(&format!("or maybe you should use `{sugg}::mem::replace`?"));
|
diag.note(format!("or maybe you should use `{sugg}::mem::replace`?"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -214,7 +214,7 @@ fn check_suspicious_swap(cx: &LateContext<'_>, block: &Block<'_>) {
|
|||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
diag.note(
|
diag.note(
|
||||||
&format!("or maybe you should use `{sugg}::mem::replace`?")
|
format!("or maybe you should use `{sugg}::mem::replace`?")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -77,7 +77,7 @@ pub(super) fn check<'tcx>(
|
|||||||
&format!("transmute from `{from_ty_orig}` which has an undefined layout"),
|
&format!("transmute from `{from_ty_orig}` which has an undefined layout"),
|
||||||
|diag| {
|
|diag| {
|
||||||
if from_ty_orig.peel_refs() != from_ty.peel_refs() {
|
if from_ty_orig.peel_refs() != from_ty.peel_refs() {
|
||||||
diag.note(&format!("the contained type `{from_ty}` has an undefined layout"));
|
diag.note(format!("the contained type `{from_ty}` has an undefined layout"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -91,7 +91,7 @@ pub(super) fn check<'tcx>(
|
|||||||
&format!("transmute to `{to_ty_orig}` which has an undefined layout"),
|
&format!("transmute to `{to_ty_orig}` which has an undefined layout"),
|
||||||
|diag| {
|
|diag| {
|
||||||
if to_ty_orig.peel_refs() != to_ty.peel_refs() {
|
if to_ty_orig.peel_refs() != to_ty.peel_refs() {
|
||||||
diag.note(&format!("the contained type `{to_ty}` has an undefined layout"));
|
diag.note(format!("the contained type `{to_ty}` has an undefined layout"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -119,16 +119,16 @@ pub(super) fn check<'tcx>(
|
|||||||
),
|
),
|
||||||
|diag| {
|
|diag| {
|
||||||
if let Some(same_adt_did) = same_adt_did {
|
if let Some(same_adt_did) = same_adt_did {
|
||||||
diag.note(&format!(
|
diag.note(format!(
|
||||||
"two instances of the same generic type (`{}`) may have different layouts",
|
"two instances of the same generic type (`{}`) may have different layouts",
|
||||||
cx.tcx.item_name(same_adt_did)
|
cx.tcx.item_name(same_adt_did)
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
if from_ty_orig.peel_refs() != from_ty {
|
if from_ty_orig.peel_refs() != from_ty {
|
||||||
diag.note(&format!("the contained type `{from_ty}` has an undefined layout"));
|
diag.note(format!("the contained type `{from_ty}` has an undefined layout"));
|
||||||
}
|
}
|
||||||
if to_ty_orig.peel_refs() != to_ty {
|
if to_ty_orig.peel_refs() != to_ty {
|
||||||
diag.note(&format!("the contained type `{to_ty}` has an undefined layout"));
|
diag.note(format!("the contained type `{to_ty}` has an undefined layout"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -146,7 +146,7 @@ pub(super) fn check<'tcx>(
|
|||||||
&format!("transmute from `{from_ty_orig}` which has an undefined layout"),
|
&format!("transmute from `{from_ty_orig}` which has an undefined layout"),
|
||||||
|diag| {
|
|diag| {
|
||||||
if from_ty_orig.peel_refs() != from_ty {
|
if from_ty_orig.peel_refs() != from_ty {
|
||||||
diag.note(&format!("the contained type `{from_ty}` has an undefined layout"));
|
diag.note(format!("the contained type `{from_ty}` has an undefined layout"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -163,7 +163,7 @@ pub(super) fn check<'tcx>(
|
|||||||
&format!("transmute into `{to_ty_orig}` which has an undefined layout"),
|
&format!("transmute into `{to_ty_orig}` which has an undefined layout"),
|
||||||
|diag| {
|
|diag| {
|
||||||
if to_ty_orig.peel_refs() != to_ty {
|
if to_ty_orig.peel_refs() != to_ty {
|
||||||
diag.note(&format!("the contained type `{to_ty}` has an undefined layout"));
|
diag.note(format!("the contained type `{to_ty}` has an undefined layout"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -24,7 +24,7 @@ pub(super) fn check<'tcx>(
|
|||||||
&format!("transmute from `{from_ty}` to `{to_ty}` which could be expressed as a pointer cast instead"),
|
&format!("transmute from `{from_ty}` to `{to_ty}` which could be expressed as a pointer cast instead"),
|
||||||
|diag| {
|
|diag| {
|
||||||
if let Some(arg) = sugg::Sugg::hir_opt(cx, arg) {
|
if let Some(arg) = sugg::Sugg::hir_opt(cx, arg) {
|
||||||
let sugg = arg.as_ty(&to_ty.to_string()).to_string();
|
let sugg = arg.as_ty(to_ty.to_string()).to_string();
|
||||||
diag.span_suggestion(e.span, "try", sugg, Applicability::MachineApplicable);
|
diag.span_suggestion(e.span, "try", sugg, Applicability::MachineApplicable);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -61,7 +61,7 @@ pub(super) fn check<'tcx>(
|
|||||||
"transmute from an integer to a pointer",
|
"transmute from an integer to a pointer",
|
||||||
|diag| {
|
|diag| {
|
||||||
if let Some(arg) = sugg::Sugg::hir_opt(cx, arg) {
|
if let Some(arg) = sugg::Sugg::hir_opt(cx, arg) {
|
||||||
diag.span_suggestion(e.span, "try", arg.as_ty(&to_ty.to_string()), Applicability::Unspecified);
|
diag.span_suggestion(e.span, "try", arg.as_ty(to_ty.to_string()), Applicability::Unspecified);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -31,7 +31,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
|
|||||||
&format!("usage of `{outer_sym}<{generic_snippet}>`"),
|
&format!("usage of `{outer_sym}<{generic_snippet}>`"),
|
||||||
|diag| {
|
|diag| {
|
||||||
diag.span_suggestion(hir_ty.span, "try", format!("{generic_snippet}"), applicability);
|
diag.span_suggestion(hir_ty.span, "try", format!("{generic_snippet}"), applicability);
|
||||||
diag.note(&format!(
|
diag.note(format!(
|
||||||
"`{generic_snippet}` is already a pointer, `{outer_sym}<{generic_snippet}>` allocates a pointer on the heap"
|
"`{generic_snippet}` is already a pointer, `{outer_sym}<{generic_snippet}>` allocates a pointer on the heap"
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
@ -78,7 +78,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
|
|||||||
format!("{outer_sym}<{generic_snippet}>"),
|
format!("{outer_sym}<{generic_snippet}>"),
|
||||||
applicability,
|
applicability,
|
||||||
);
|
);
|
||||||
diag.note(&format!(
|
diag.note(format!(
|
||||||
"`{inner_sym}<{generic_snippet}>` is already on the heap, `{outer_sym}<{inner_sym}<{generic_snippet}>>` makes an extra allocation"
|
"`{inner_sym}<{generic_snippet}>` is already on the heap, `{outer_sym}<{inner_sym}<{generic_snippet}>>` makes an extra allocation"
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
@ -91,10 +91,10 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
|
|||||||
hir_ty.span,
|
hir_ty.span,
|
||||||
&format!("usage of `{outer_sym}<{inner_sym}<{generic_snippet}>>`"),
|
&format!("usage of `{outer_sym}<{inner_sym}<{generic_snippet}>>`"),
|
||||||
|diag| {
|
|diag| {
|
||||||
diag.note(&format!(
|
diag.note(format!(
|
||||||
"`{inner_sym}<{generic_snippet}>` is already on the heap, `{outer_sym}<{inner_sym}<{generic_snippet}>>` makes an extra allocation"
|
"`{inner_sym}<{generic_snippet}>` is already on the heap, `{outer_sym}<{inner_sym}<{generic_snippet}>>` makes an extra allocation"
|
||||||
));
|
));
|
||||||
diag.help(&format!(
|
diag.help(format!(
|
||||||
"consider using just `{outer_sym}<{generic_snippet}>` or `{inner_sym}<{generic_snippet}>`"
|
"consider using just `{outer_sym}<{generic_snippet}>` or `{inner_sym}<{generic_snippet}>`"
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
|
@ -129,7 +129,7 @@ fn lint_unit_args(cx: &LateContext<'_>, expr: &Expr<'_>, args_to_recover: &[&Exp
|
|||||||
|
|
||||||
if arg_snippets_without_empty_blocks.is_empty() {
|
if arg_snippets_without_empty_blocks.is_empty() {
|
||||||
db.multipart_suggestion(
|
db.multipart_suggestion(
|
||||||
&format!("use {singular}unit literal{plural} instead"),
|
format!("use {singular}unit literal{plural} instead"),
|
||||||
args_to_recover
|
args_to_recover
|
||||||
.iter()
|
.iter()
|
||||||
.map(|arg| (arg.span, "()".to_string()))
|
.map(|arg| (arg.span, "()".to_string()))
|
||||||
@ -142,7 +142,7 @@ fn lint_unit_args(cx: &LateContext<'_>, expr: &Expr<'_>, args_to_recover: &[&Exp
|
|||||||
let it_or_them = if plural { "them" } else { "it" };
|
let it_or_them = if plural { "them" } else { "it" };
|
||||||
db.span_suggestion(
|
db.span_suggestion(
|
||||||
expr.span,
|
expr.span,
|
||||||
&format!(
|
format!(
|
||||||
"{or}move the expression{empty_or_s} in front of the call and replace {it_or_them} with the unit literal `()`"
|
"{or}move the expression{empty_or_s} in front of the call and replace {it_or_them} with the unit literal `()`"
|
||||||
),
|
),
|
||||||
sugg,
|
sugg,
|
||||||
|
@ -377,7 +377,7 @@ fn check_newline(cx: &LateContext<'_>, format_args: &FormatArgsExpn<'_>, macro_c
|
|||||||
// print!("\n"), write!(f, "\n")
|
// print!("\n"), write!(f, "\n")
|
||||||
|
|
||||||
diag.multipart_suggestion(
|
diag.multipart_suggestion(
|
||||||
&format!("use `{name}ln!` instead"),
|
format!("use `{name}ln!` instead"),
|
||||||
vec![(name_span, format!("{name}ln")), (format_string_span, String::new())],
|
vec![(name_span, format!("{name}ln")), (format_string_span, String::new())],
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
@ -388,7 +388,7 @@ fn check_newline(cx: &LateContext<'_>, format_args: &FormatArgsExpn<'_>, macro_c
|
|||||||
let newline_span = format_string_span.with_lo(hi - BytePos(3)).with_hi(hi - BytePos(1));
|
let newline_span = format_string_span.with_lo(hi - BytePos(3)).with_hi(hi - BytePos(1));
|
||||||
|
|
||||||
diag.multipart_suggestion(
|
diag.multipart_suggestion(
|
||||||
&format!("use `{name}ln!` instead"),
|
format!("use `{name}ln!` instead"),
|
||||||
vec![(name_span, format!("{name}ln")), (newline_span, String::new())],
|
vec![(name_span, format!("{name}ln")), (newline_span, String::new())],
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
fn docs_link(diag: &mut Diagnostic, lint: &'static Lint) {
|
fn docs_link(diag: &mut Diagnostic, lint: &'static Lint) {
|
||||||
if env::var("CLIPPY_DISABLE_DOCS_LINKS").is_err() {
|
if env::var("CLIPPY_DISABLE_DOCS_LINKS").is_err() {
|
||||||
if let Some(lint) = lint.name_lower().strip_prefix("clippy::") {
|
if let Some(lint) = lint.name_lower().strip_prefix("clippy::") {
|
||||||
diag.help(&format!(
|
diag.help(format!(
|
||||||
"for further information visit https://rust-lang.github.io/rust-clippy/{}/index.html#{lint}",
|
"for further information visit https://rust-lang.github.io/rust-clippy/{}/index.html#{lint}",
|
||||||
&option_env!("RUST_RELEASE_NUM").map_or("master".to_string(), |n| {
|
&option_env!("RUST_RELEASE_NUM").map_or("master".to_string(), |n| {
|
||||||
// extract just major + minor version and ignore patch versions
|
// extract just major + minor version and ignore patch versions
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// run-rustfix
|
// run-rustfix
|
||||||
#![warn(clippy::manual_retain)]
|
#![warn(clippy::manual_retain)]
|
||||||
#![allow(unused)]
|
#![allow(unused, clippy::redundant_clone)]
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
use std::collections::BinaryHeap;
|
use std::collections::BinaryHeap;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// run-rustfix
|
// run-rustfix
|
||||||
#![warn(clippy::manual_retain)]
|
#![warn(clippy::manual_retain)]
|
||||||
#![allow(unused)]
|
#![allow(unused, clippy::redundant_clone)]
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
use std::collections::BinaryHeap;
|
use std::collections::BinaryHeap;
|
||||||
|
Loading…
Reference in New Issue
Block a user