Skip to content

Commit 9f5d31e

Browse files
committed
clear DefId when an expression's type changes to non-adt
1 parent 124e68b commit 9f5d31e

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

clippy_utils/src/ty/type_certainty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fn expr_type_certainty(cx: &LateContext<'_>, expr: &Expr<'_>) -> Certainty {
9090
if let Some(def_id) = adt_def_id(expr_ty) {
9191
certainty.with_def_id(def_id)
9292
} else {
93-
certainty
93+
certainty.clear_def_id()
9494
}
9595
}
9696

tests/ui/crashes/ice-12585.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#![allow(clippy::unit_arg)]
2+
3+
struct One {
4+
x: i32,
5+
}
6+
struct Two {
7+
x: i32,
8+
}
9+
10+
struct Product {}
11+
12+
impl Product {
13+
pub fn a_method(self, _: ()) {}
14+
}
15+
16+
fn from_array(_: [i32; 2]) -> Product {
17+
todo!()
18+
}
19+
20+
pub fn main() {
21+
let one = One { x: 1 };
22+
let two = Two { x: 2 };
23+
24+
let product = from_array([one.x, two.x]);
25+
product.a_method(<()>::default());
26+
}

0 commit comments

Comments
 (0)