Skip to content

Commit e783aea

Browse files
committed
if range has a field with uncertain type, only reduce applicability
1 parent b013db9 commit e783aea

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

clippy_lints/src/no_effect.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,12 @@ fn reduce_expression<'a>(
368368
&& let Some(start) = range.start
369369
&& let Some(end) = range.end =>
370370
{
371-
if [start, end].into_iter().any(|e| expr_type_is_certain(cx, e)) {
372-
Some(vec![start, end])
373-
} else {
374-
None
371+
if ![start, end].into_iter().any(|e| expr_type_is_certain(cx, e)) {
372+
// there's a risk that if we take the field exprs out of the context of the range constructor,
373+
// their types might become ambiguous
374+
*applicability = Applicability::MaybeIncorrect;
375375
}
376+
Some(vec![start, end])
376377
},
377378
ExprKind::Struct(_, fields, ref base) => {
378379
if fields.iter().any(|f| !expr_type_is_certain(cx, f.expr)) {

0 commit comments

Comments
 (0)