rust-lang / rust-lang/rust

member constraints involving external regions are scuffed

Open
#146,062 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-borrow-checker A-impl-trait A-lifetimes A-type-system C-bug T-compiler T-types
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

struct Inv<'a>(Option<*mut &'a ()>);
fn foo() -> impl Sized {
    let _: fn() -> Inv<'static> = || {
        foo()
    };
    loop {}
}

When borrow checking the closure with signature fn() -> Inv<'external> we've got a defining use of the opaque with the hidden type Inv<'external>.

The member constraint 'external member ['static] does not choose 'static here as it fails the upper bound check. This should work, properly supporting it is hard :>

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 compiling the provided Rust reproducer and tracing the borrow-checking handling of the closure signature fn() -> Inv<'external> and its member constraint 'external member ['static]. Done means the reproducer compiles with the opaque hidden type Inv<'external> and the member constraint can select 'static without failing its upper-bound check.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.