diff options
| author | llogiq <bogusandre@gmail.com> | 2025-06-19 20:46:45 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-19 20:46:45 +0000 |
| commit | 62fd159a5d565aa571b70b31d5dfefc2b6fdbcfd (patch) | |
| tree | fb1f9d740f29822515558f0a2dedefd44f176c48 | |
| parent | 59291a75dff663f4a0a6762eb5ebeeb764d8b3ec (diff) | |
| parent | ac8f50473caf0b43c05e07028cae7f13d074efb5 (diff) | |
| download | rust-62fd159a5d565aa571b70b31d5dfefc2b6fdbcfd.tar.gz rust-62fd159a5d565aa571b70b31d5dfefc2b6fdbcfd.zip | |
Fix `non_copy_const` ICE (#15083)
fixes rust-lang/rust-clippy#15069 ---- changelog: none
| -rw-r--r-- | clippy_lints/src/non_copy_const.rs | 2 | ||||
| -rw-r--r-- | tests/ui/borrow_interior_mutable_const.rs | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/clippy_lints/src/non_copy_const.rs b/clippy_lints/src/non_copy_const.rs index a27c6aa75e3..5f10e1968f1 100644 --- a/clippy_lints/src/non_copy_const.rs +++ b/clippy_lints/src/non_copy_const.rs @@ -617,7 +617,7 @@ impl<'tcx> NonCopyConst<'tcx> { // Then a type check. Note we only check the type here as the result // gets cached. - let ty = EarlyBinder::bind(typeck.expr_ty(src_expr)).instantiate(tcx, init_args); + let ty = typeck.expr_ty(src_expr); // Normalized as we need to check if this is an array later. let ty = tcx.try_normalize_erasing_regions(typing_env, ty).unwrap_or(ty); if self.is_ty_freeze(tcx, typing_env, ty).is_freeze() { diff --git a/tests/ui/borrow_interior_mutable_const.rs b/tests/ui/borrow_interior_mutable_const.rs index 0f439f78915..674450a73ad 100644 --- a/tests/ui/borrow_interior_mutable_const.rs +++ b/tests/ui/borrow_interior_mutable_const.rs @@ -218,4 +218,20 @@ fn main() { let _ = &S::VALUE.1; //~ borrow_interior_mutable_const let _ = &S::VALUE.2; } + { + pub struct Foo<T, const N: usize>(pub Entry<N>, pub T); + + pub struct Entry<const N: usize>(pub Cell<[u32; N]>); + + impl<const N: usize> Entry<N> { + const INIT: Self = Self(Cell::new([42; N])); + } + + impl<T, const N: usize> Foo<T, N> { + pub fn make_foo(v: T) -> Self { + // Used to ICE due to incorrect instantiation. + Foo(Entry::INIT, v) + } + } + } } |
