Rollup merge of #89895 - camsteffen:for-loop-head-span, r=davidtwco

Don't mark for loop iter expression as desugared

We typically don't mark spans of lowered things as desugared. This helps Clippy rightly discern when code is (not) from expansion. This was discovered by ``@flip1995`` at https://github.com/rust-lang/rust-clippy/pull/7789#issuecomment-939289501.
This commit is contained in:
Yuki Okushi 2021-10-22 19:42:45 +09:00 committed by GitHub
commit efef16f6ed

View file

@ -63,13 +63,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessVec {
if is_copy(cx, vec_type(cx.typeck_results().expr_ty_adjusted(arg))); if is_copy(cx, vec_type(cx.typeck_results().expr_ty_adjusted(arg)));
then { then {
// report the error around the `vec!` not inside `<std macros>:` // report the error around the `vec!` not inside `<std macros>:`
let span = arg.span let span = arg.span.ctxt().outer_expn_data().call_site;
.ctxt()
.outer_expn_data()
.call_site
.ctxt()
.outer_expn_data()
.call_site;
self.check_vec_macro(cx, &vec_args, Mutability::Not, span); self.check_vec_macro(cx, &vec_args, Mutability::Not, span);
} }
} }