gce: don't ICE on non-local const

This commit is contained in:
Yotam Ofek
2025-06-27 16:59:25 +00:00
parent 13c46fd0b0
commit 0e32036deb
4 changed files with 23 additions and 16 deletions

View File

@@ -421,7 +421,9 @@ fn const_evaluatable_predicates_of<'tcx>(
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ConstCollector<'tcx> {
fn visit_const(&mut self, c: ty::Const<'tcx>) {
if let ty::ConstKind::Unevaluated(uv) = c.kind() {
if is_const_param_default(self.tcx, uv.def.expect_local()) {
if let Some(local) = uv.def.as_local()
&& is_const_param_default(self.tcx, local)
{
// Do not look into const param defaults,
// these get checked when they are actually instantiated.
//

View File

@@ -1,15 +0,0 @@
//@ known-bug: #133808
#![feature(generic_const_exprs, transmutability)]
mod assert {
use std::mem::TransmuteFrom;
pub fn is_transmutable<Src, Dst>()
where
Dst: TransmuteFrom<Src>,
{
}
}
pub fn main() {}

View File

@@ -0,0 +1,10 @@
// regression test for #133808.
#![feature(generic_const_exprs)]
#![feature(min_generic_const_args)]
#![allow(incomplete_features)]
#![crate_type = "lib"]
pub trait Foo {}
impl Foo for [u8; std::path::MAIN_SEPARATOR] {}
//~^ ERROR the constant `MAIN_SEPARATOR` is not of type `usize`

View File

@@ -0,0 +1,10 @@
error: the constant `MAIN_SEPARATOR` is not of type `usize`
--> $DIR/non-local-const.rs:9:14
|
LL | impl Foo for [u8; std::path::MAIN_SEPARATOR] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `char`
|
= note: the length of array `[u8; MAIN_SEPARATOR]` must be type `usize`
error: aborting due to 1 previous error