Skip to content

Commit

Permalink
clear DefId when an expression's type changes to non-adt
Browse files Browse the repository at this point in the history
  • Loading branch information
y21 committed Mar 29, 2024
1 parent 124e68b commit 9f5d31e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clippy_utils/src/ty/type_certainty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fn expr_type_certainty(cx: &LateContext<'_>, expr: &Expr<'_>) -> Certainty {
if let Some(def_id) = adt_def_id(expr_ty) {
certainty.with_def_id(def_id)
} else {
certainty
certainty.clear_def_id()
}
}

Expand Down
26 changes: 26 additions & 0 deletions tests/ui/crashes/ice-12585.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#![allow(clippy::unit_arg)]

struct One {
x: i32,
}
struct Two {
x: i32,
}

struct Product {}

impl Product {
pub fn a_method(self, _: ()) {}
}

fn from_array(_: [i32; 2]) -> Product {
todo!()
}

pub fn main() {
let one = One { x: 1 };
let two = Two { x: 2 };

let product = from_array([one.x, two.x]);
product.a_method(<()>::default());
}

0 comments on commit 9f5d31e

Please sign in to comment.