Const blocks in fns with trivially unsatisifiable clauses can render addition of trait impls a post-monomorphization breaking change

Abierto
#165,647 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
rust
Área
compilers

Línea de trabajo

Start with the const evaluation and trait obligation handling discussed in the linked issue #165153 and PR #142293; the payload does not name Rust compiler files or tests. Reproduce the downstream const { panic!() } case with and without the upstream trait impl, then trace why evaluation changes after monomorphization. Done means the compiler behavior and the compatibility implications are understood and addressed.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

A-const-eval A-crate-compat A-monomorphization C-bug T-compiler T-types

Back in closed PR #142293 after [@]BoxyUwU pointed out the issues with suppressing const eval if there are trivially unsatisfiable clauses in scope in the context of GCI (now tracked in issue https://github.com/rust-lang/rust/issues/165153), it made me realize (CC https://github.com/rust-lang/rust/pull/142293#issuecomment-3229975360 (from 2025)) that const blocks are affected by this problem.

Reproducer

Upstream crate upstream:

pub trait Trait {}

// NOTE: Adding this impl breaks downstream.
//impl Trait for () {}

Downstream crate downstream:

fn scope()
where
    for<'_delay> (): upstream::Trait,
{
    const { panic!() } // NOTE: panics at comptime post-mono if upstream adds the impl
}

Of course, due to the existence of 1IR ("one-impl rule"), the addition of trait impls is already breaking (pre-mono even).

Moreover, at the time of writing two unstable features are affected by this issue (also pre-mono), namely GCI (https://github.com/rust-lang/rust/issues/165153) and DFV (https://github.com/rust-lang/rust/issues/165152) meaning this mistake is easy to make by rustc devs.

However, by posting https://github.com/rust-lang/rust/issues/165152#issuecomment-6722673316 @theemathas made me realize that we should probably track this in a GH issue.

Lenguaje dominante
Rust
Estrellas
121k
Forks
17.3k
Merge medio
2 d 17 h
PR fusionados (30 d)
525

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de rust-lang/rust

Todos los issues de rust-lang/rust

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.