Fix non_copy_const ICE (#15083)
fixes rust-lang/rust-clippy#15069 ---- changelog: none
This commit is contained in:
commit
62fd159a5d
2 changed files with 17 additions and 1 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue