diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs index b8ae0430502b5..9ac3fc2da55e7 100644 --- a/src/librustc/ty/subst.rs +++ b/src/librustc/ty/subst.rs @@ -541,6 +541,8 @@ impl<'a, 'gcx, 'tcx> SubstFolder<'a, 'gcx, 'tcx> { let opt_ty = self.substs.get(p.idx as usize).map(|k| k.unpack()); let ty = match opt_ty { Some(UnpackedKind::Type(ty)) => ty, + Some(UnpackedKind::Const(ty::Const { ty, ..})) => ty, + None => source_ty, _ => { let span = self.span.unwrap_or(DUMMY_SP); span_bug!( @@ -551,7 +553,8 @@ impl<'a, 'gcx, 'tcx> SubstFolder<'a, 'gcx, 'tcx> { source_ty, p.idx, self.root_ty, - self.substs); + self.substs, + ); } }; diff --git a/src/test/ui/const-generics/issue-60264.rs b/src/test/ui/const-generics/issue-60264.rs new file mode 100644 index 0000000000000..28c9cad6ca7ed --- /dev/null +++ b/src/test/ui/const-generics/issue-60264.rs @@ -0,0 +1,8 @@ +use std::marker::PhantomData; + +struct B(PhantomData<[T; N]>); +//~^ ERROR expected type, found const parameter `N` +//~| ERROR const generics are unstable +//~| ERROR mismatched types + +fn main() {} diff --git a/src/test/ui/const-generics/issue-60264.stderr b/src/test/ui/const-generics/issue-60264.stderr new file mode 100644 index 0000000000000..3219a0ce94dd0 --- /dev/null +++ b/src/test/ui/const-generics/issue-60264.stderr @@ -0,0 +1,28 @@ +error[E0573]: expected type, found const parameter `N` + --> $DIR/issue-60264.rs:3:14 + | +LL | struct B(PhantomData<[T; N]>); + | ^ help: a struct with a similar name exists: `B` + +error[E0658]: const generics are unstable + --> $DIR/issue-60264.rs:3:23 + | +LL | struct B(PhantomData<[T; N]>); + | ^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/44580 + = help: add #![feature(const_generics)] to the crate attributes to enable + +error[E0308]: mismatched types + --> $DIR/issue-60264.rs:3:45 + | +LL | struct B(PhantomData<[T; N]>); + | ^ expected usize, found type parameter + | + = note: expected type `usize` + found type `T` + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0308, E0658. +For more information about an error, try `rustc --explain E0308`.