Change:
<!-- Thank you for finding an Internal Compiler Error! If possible, try to provide a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for how to create smaller examples. --<!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</details
's parameter doesn't have to have an error type; it appears it can be any type (that doesn't trip the full feature gate error.) This version ICEs without any prior diagnostics: Neither version ICEs on beta or stable. (const generics aren't stable on 1.50, but after reporting an error for use of unstable features the compiler reports the same errors as beta and doesn't ICE.) label A-const-generics regression-from-stable-to-nightly
Bisected, this is a weird one:
I've attempted a second bisection using the snippet from the , I got a different result (not sure why, unsure if it helps) searched nightlies: from nightly-2021-02-15 to nightly-2021-03-18 regressed nightly: nightly-2021-03-18 searched commits: from to regressed commit: <details<summarybisected with <a href=''cargo-bisect-rustc</av0.6.0</summaryHost triple: x86_64-unknown-linux-gnu Reproduce with: </details
I guess that was a lie I'm looking into this
Assigning and removing as in the prioritization working group. label: +P-high -I-prioritize

Discussion:
use crate::ty::{self, Ty, TyCtxt, TypeFoldable}; use rustc_hir as ast; use rustc_hir::def_id::DefId; <ins> use rustc_span::DUMMY_SP; </ins> use rustc_target::spec::abi; use std::iter;

// FIXME(oli-obk): once const generics can have generic types, this assertion // will likely get triggered. Move to `normalize_erasing_regions` at that point. <del> assert_eq!( tcx.erase_regions(a.ty), tcx.erase_regions(b.ty), "cannot relate constants of different types" ); </del> <ins> let a_ty = tcx.erase_regions(a.ty); let b_ty = tcx.erase_regions(b.ty); if a_ty != b_ty { relation.tcx().sess.delay_span_bug( DUMMY_SP, &format!("cannot relate constants of different types: {} != {}", a_ty, b_ty), ); } </ins> let eagerly_eval = |x: &'tcx ty::Const<'tcx>| x.eval(tcx, relation.param_env()); let a = eagerly_eval(a);

<ins> fn foo<const N: usize>() -> [u8; N] { bar::<N>() //~ ERROR mismatched types } fn bar<const N: u8>() -> [u8; N] {} //~^ ERROR mismatched types //~| ERROR mismatched types fn main() {} </ins>

<ins> error[E0308]: mismatched types --> $DIR/type_mismatch.rs:2:11 | LL |     bar::<N>() |           ^ expected `u8`, found `usize` error[E0308]: mismatched types --> $DIR/type_mismatch.rs:5:31 | LL | fn bar<const N: u8>() -> [u8; N] {} |                               ^ expected `usize`, found `u8` error[E0308]: mismatched types --> $DIR/type_mismatch.rs:5:26 | LL | fn bar<const N: u8>() -> [u8; N] {} |    ---                   ^^^^^^^ expected array `[u8; N]`, found `()` |    | |    implicitly returns `()` as its body has no tail or `return` expression error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0308`. </ins>

<ins> impl X { //~^ ERROR cannot find type fn getn<const N: usize>() -> [u8; N] { getn::<N>() } } fn getn<const N: cfg_attr>() -> [u8; N] {} //~^ ERROR expected type, found built-in attribute `cfg_attr` //~| ERROR mismatched types fn main() {} </ins>

<ins> error[E0412]: cannot find type `X` in this scope --> $DIR/type_not_in_scope.rs:1:6 | LL | impl X { |      ^ not found in this scope error[E0573]: expected type, found built-in attribute `cfg_attr` --> $DIR/type_not_in_scope.rs:7:18 | LL | fn getn<const N: cfg_attr>() -> [u8; N] {} |                  ^^^^^^^^ not a type error[E0308]: mismatched types --> $DIR/type_not_in_scope.rs:7:33 | LL | fn getn<const N: cfg_attr>() -> [u8; N] {} |    ----                         ^^^^^^^ expected array `[u8; N]`, found `()` |    | |    implicitly returns `()` as its body has no tail or `return` expression error: aborting due to 3 previous errors Some errors have detailed explanations: E0308, E0412, E0573. For more information about an error, try `rustc --explain E0308`. </ins>