rust-lang / rust-lang/rust

requiring item bounds for coinduction may be breaking

Open
#162,194 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-coinduction T-types
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

our current plan to soundly support coinductive traits is to require proving the item bounds of a trait when using an implementation. Afaict this should break the following example:

trait WithSuper<T>: Copy {}

trait WithAliasBound {
    type Assoc: Copy;
}

// With our approach to coinduction, using this impl should require
// proving `<T as WithAliasBound>::Assoc: Copy`
impl<T: WithAliasBound> WithSuper<T> for <T as WithAliasBound>::Assoc {}

fn impls_with_super<T: WithSuper<U>, U>() {}

fn item_bounds_not_checked<T: WithAliasBound<Assoc = U>, U>() {
    impls_with_super::<U, T>();
    // This uses the impl and would fail to prove `U: Copy`.
}
related issues

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reducing the Rust example in the issue and comparing its behavior with related issue #103899. Investigate how the compiler checks item bounds when using the coinductive trait implementation. Done means the example follows the intended soundness rules and has regression coverage for the observed behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.