use crate::rustc::ty;
use crate::utils::{differing_macro_contexts, match_type, paths, snippet, span_lint_and_then, walk_ptrs_ty, SpanlessEq};
use crate::utils::sugg::Sugg;
+use crate::rustc_errors::Applicability;
/// **What it does:** Checks for manual swapping.
///
(true, format!(" `{}` and `{}`", first, second),
format!("std::mem::swap({}, {})", first.mut_addr(), second.mut_addr()))
} else {
- (true, "".to_owned(), "".to_owned())
+ (true, String::new(), String::new())
};
let span = w[0].span.to(second.span);
&format!("this looks like you are swapping{} manually", what),
|db| {
if !sugg.is_empty() {
- db.span_suggestion(span, "try", sugg);
+ db.span_suggestion_with_applicability(
+ span,
+ "try",
+ sugg,
+ Applicability::Unspecified,
+ );
if replace {
db.note("or maybe you should use `std::mem::replace`?");
&format!("this looks like you are trying to swap{}", what),
|db| {
if !what.is_empty() {
- db.span_suggestion(span, "try",
- format!("std::mem::swap({}, {})", lhs, rhs));
+ db.span_suggestion_with_applicability(
+ span,
+ "try",
+ format!("std::mem::swap({}, {})",
+ lhs,
+ rhs),
+ Applicability::Unspecified,
+ );
db.note("or maybe you should use `std::mem::replace`?");
}
});