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

Đang mở
#165,647 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
compilers

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Rust
Star
121k
Fork
17.3k
Merge trung bình
2 ngày 16 giờ
Pull request đã merge (30 ngày)
529

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của rust-lang/rust

Tất cả issue của rust-lang/rust

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.