mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-30 04:56:25 +03:00
Fix useless_conversion wrongly unmangled macros (#16171)
Closes rust-lang/rust-clippy#16165 changelog: [`useless_conversion`] fix wrongly unmangled macros
This commit is contained in:
@@ -354,7 +354,10 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
|
||||
return;
|
||||
}
|
||||
|
||||
let sugg = snippet(cx, recv.span, "<expr>").into_owned();
|
||||
let mut applicability = Applicability::MachineApplicable;
|
||||
let sugg = snippet_with_context(cx, recv.span, e.span.ctxt(), "<expr>", &mut applicability)
|
||||
.0
|
||||
.into_owned();
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
USELESS_CONVERSION,
|
||||
|
||||
@@ -442,3 +442,14 @@ fn issue14739() {
|
||||
let _ = R.map(|_x| 0);
|
||||
//~^ useless_conversion
|
||||
}
|
||||
|
||||
fn issue16165() {
|
||||
macro_rules! mac {
|
||||
(iter $e:expr) => {
|
||||
$e.iter()
|
||||
};
|
||||
}
|
||||
|
||||
for _ in mac!(iter [1, 2]) {}
|
||||
//~^ useless_conversion
|
||||
}
|
||||
|
||||
@@ -442,3 +442,14 @@ fn issue14739() {
|
||||
let _ = R.into_iter().map(|_x| 0);
|
||||
//~^ useless_conversion
|
||||
}
|
||||
|
||||
fn issue16165() {
|
||||
macro_rules! mac {
|
||||
(iter $e:expr) => {
|
||||
$e.iter()
|
||||
};
|
||||
}
|
||||
|
||||
for _ in mac!(iter [1, 2]).into_iter() {}
|
||||
//~^ useless_conversion
|
||||
}
|
||||
|
||||
@@ -389,5 +389,11 @@ error: useless conversion to the same type: `std::ops::Range<u32>`
|
||||
LL | let _ = R.into_iter().map(|_x| 0);
|
||||
| ^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `R`
|
||||
|
||||
error: aborting due to 43 previous errors
|
||||
error: useless conversion to the same type: `std::slice::Iter<'_, i32>`
|
||||
--> tests/ui/useless_conversion.rs:453:14
|
||||
|
|
||||
LL | for _ in mac!(iter [1, 2]).into_iter() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `mac!(iter [1, 2])`
|
||||
|
||||
error: aborting due to 44 previous errors
|
||||
|
||||
|
||||
Reference in New Issue
Block a user