Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regression: lifetime under _for all_ does not appear in the trait input types #132000

Open
ABorgna opened this issue Oct 21, 2024 · 1 comment
Open
Labels
C-bug Category: This is a bug. I-prioritize Issue: Indicates that prioritization has been requested for this issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. regression-from-stable-to-beta Performance or correctness regression from stable to beta.

Comments

@ABorgna
Copy link

ABorgna commented Oct 21, 2024

Code

pub trait TraitWithGAT {
    type T<'c>;
}

pub trait FnLike<'c, TM: TraitWithGAT>: Fn(TM::T<'c>) -> TM::T<'c> {}

pub trait StaticFnLike<TM: TraitWithGAT>: for<'c> FnLike<'c, TM> {}

pub struct DynTraitObject<TM: TraitWithGAT>(pub dyn StaticFnLike<TM>);

On stable, cargo build compiles without errors.

On beta (and nightly 2024-10-20), it fails with the following error:

error[E0582]: binding for associated type `Output` references lifetime `'c`, which does not appear in the trait input types
 --> src/trait_beta_bug.rs:9:53
  |
5 | pub trait FnLike<'c, TM: TraitWithGAT>: Fn(TM::T<'c>) -> TM::T<'c> {}
  |                                                          --------- due to this supertrait
...
9 | pub struct DynTraitObject<TM: TraitWithGAT>(pub dyn StaticFnLike<TM>);
  |                                                     ^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0582`.

playground

Version it worked on

rustc --version --verbose:

rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: aarch64-apple-darwin
release: 1.82.0
LLVM version: 19.1.1

Version with regression

rustc +beta --version --verbose:

rustc 1.83.0-beta.2 (88c1c3c11 2024-10-18)
binary: rustc
commit-hash: 88c1c3c1102bbf3860891bfa52b7ddd9f26aec2f
commit-date: 2024-10-18
host: aarch64-apple-darwin
release: 1.83.0-beta.2
LLVM version: 19.1.1

@rustbot modify labels: +regression-from-stable-to-beta -regression-untriaged

@ABorgna ABorgna added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Oct 21, 2024
@rustbot rustbot added I-prioritize Issue: Indicates that prioritization has been requested for this issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. regression-from-stable-to-beta Performance or correctness regression from stable to beta. and removed regression-untriaged Untriaged performance or correctness regression. labels Oct 21, 2024
@compiler-errors
Copy link
Member

This is very likely unsound in the same way that for<'a> Fn(T::Assoc<'a>) -> T::Assoc<'a> is unsound as a supertrait bound.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-prioritize Issue: Indicates that prioritization has been requested for this issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. regression-from-stable-to-beta Performance or correctness regression from stable to beta.
Projects
None yet
Development

No branches or pull requests

3 participants