use matches::matches;
-use rustc::hir::*;
-use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
-use rustc::{declare_lint, lint_array};
+use crate::rustc::hir::*;
+use crate::rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
+use crate::rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
-use rustc::ty;
+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.
///
snippet(cx, idx1.span, ".."),
snippet(cx, idx2.span, "..")))
} else {
- (false, "".to_owned(), "".to_owned())
+ (false, String::new(), String::new())
}
} else if let (Some(first), Some(second)) = (Sugg::hir_opt(cx, lhs1), Sugg::hir_opt(cx, rhs1)) {
(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`?");
second.mut_addr().to_string(),
)
} else {
- ("".to_owned(), "".to_owned(), "".to_owned())
+ (String::new(), String::new(), String::new())
};
let span = first.span.to(second.span);
&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`?");
}
});