Skip to content

Commit 0f4e861

Browse files
committed
fix: single_range_in_vec_init FP for explicit Range
1 parent 8ed05ab commit 0f4e861

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

clippy_lints/src/single_range_in_vec_init.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ impl LateLintPass<'_> for SingleRangeInVecInit {
9191
};
9292

9393
if cx.tcx.qpath_is_lang_item(qpath, LangItem::Range)
94+
&& !start.expr.span.eq_ctxt(inner_expr.span)
9495
&& let ty = cx.typeck_results().expr_ty(start.expr)
9596
&& let Some(snippet) = span.get_source_text(cx)
9697
// `is_from_proc_macro` will skip any `vec![]`. Let's not!

tests/ui/single_range_in_vec_init.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,9 @@ fn main() {
6666
vec![0..200];
6767
}
6868
}
69+
70+
fn issue16042() {
71+
use std::ops::Range;
72+
73+
let input = vec![Range { start: 0, end: 5 }];
74+
}

0 commit comments

Comments
 (0)