Skip to content

Commit 62fd159

Browse files
authored
Fix non_copy_const ICE (#15083)
fixes #15069 ---- changelog: none
2 parents 59291a7 + ac8f504 commit 62fd159

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

clippy_lints/src/non_copy_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ impl<'tcx> NonCopyConst<'tcx> {
617617

618618
// Then a type check. Note we only check the type here as the result
619619
// gets cached.
620-
let ty = EarlyBinder::bind(typeck.expr_ty(src_expr)).instantiate(tcx, init_args);
620+
let ty = typeck.expr_ty(src_expr);
621621
// Normalized as we need to check if this is an array later.
622622
let ty = tcx.try_normalize_erasing_regions(typing_env, ty).unwrap_or(ty);
623623
if self.is_ty_freeze(tcx, typing_env, ty).is_freeze() {

tests/ui/borrow_interior_mutable_const.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,20 @@ fn main() {
218218
let _ = &S::VALUE.1; //~ borrow_interior_mutable_const
219219
let _ = &S::VALUE.2;
220220
}
221+
{
222+
pub struct Foo<T, const N: usize>(pub Entry<N>, pub T);
223+
224+
pub struct Entry<const N: usize>(pub Cell<[u32; N]>);
225+
226+
impl<const N: usize> Entry<N> {
227+
const INIT: Self = Self(Cell::new([42; N]));
228+
}
229+
230+
impl<T, const N: usize> Foo<T, N> {
231+
pub fn make_foo(v: T) -> Self {
232+
// Used to ICE due to incorrect instantiation.
233+
Foo(Entry::INIT, v)
234+
}
235+
}
236+
}
221237
}

0 commit comments

Comments
 (0)