rust-lang / rust-lang/rust

unlike closure parent args, we check member constraints for unused early-bound `FnDef` lifetimes

Open
#155,087 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

FnDef lifetime arguments are ignored by outlives constraints. They are not ignored by member constraints. This is inconsistent.

fn cool<'a: 'a>() {}

fn closure_outlives<'a>() -> impl Sized + use<'a> + 'static {
    || ()
}
fn fn_def_outlives<'a>() -> impl Sized + use<'a> + 'static {
    cool::<'a>
}

fn closure_member_constraints<'a>() -> impl Sized + use<> {
    || ()
}
fn fn_def_member_constraints<'a>() -> impl Sized + use<> {
    cool::<'a> //~ ERROR hidden type for `impl Sized` captures lifetime that does not appear in bounds
}

We shouldn't try to make this consistent before resolving https://github.com/rust-lang/rust/issues/153140#issuecomment-4222065426

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 with the supplied Rust reproducer and compare the closure and FnDef cases for outlives and member constraints. Read issue #153140 and its referenced comment before changing behavior; the intended fix is not defined until that issue is resolved.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.