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: Compiler error with dyn + for<'a> #132000

Open
ABorgna opened this issue Oct 21, 2024 · 3 comments
Open

regression: Compiler error with dyn + for<'a> #132000

ABorgna opened this issue Oct 21, 2024 · 3 comments
Labels
C-bug Category: This is a bug. I-prioritize Issue: Indicates that prioritization has been requested for this issue. regression-from-stable-to-beta Performance or correctness regression from stable to beta.
Milestone

Comments

@ABorgna
Copy link

ABorgna commented Oct 21, 2024

Code

pub trait Tr {
    type Assoc<'c>;
}

pub trait Mapping<'c, T: Tr>: Fn(T::Assoc<'c>) -> T::Assoc<'c> {}

pub trait ForallMap<T: Tr>: for<'c> Mapping<'c, T> {}

pub struct S<T: Tr>(pub dyn ForallMap<T>);

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/lib.rs:9:29
  |
5 | pub trait Mapping<'c, T: Tr>: Fn(T::Assoc<'c>) -> T::Assoc<'c> {}
  |                                                   ------------ due to this supertrait
...
9 | pub struct S<T: Tr>(pub dyn ForallMap<T>);
  |                             ^^^^^^^^^^^^

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

playground

EDIT: Cleaned the example a bit

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.

@ABorgna ABorgna changed the title regression: lifetime under _for all_ does not appear in the trait input types regression: Compiler error with dyn + for<'a> Oct 28, 2024
@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 9, 2024
@apiraino
Copy link
Contributor

Bisection leads to #130367, which was FCP'd, so am I right in assuming this is intended breakage or are still wrinkles to fix there? Anything in that PR that should get into the release notes? Thanks for a bit of context :)

cc @compiler-errors @spastorino

@Mark-Simulacrum Mark-Simulacrum added this to the 1.83.0 milestone Nov 22, 2024
@cuviper
Copy link
Member

cuviper commented Nov 22, 2024

This will be documented as a compat note via #131271.

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. regression-from-stable-to-beta Performance or correctness regression from stable to beta.
Projects
None yet
Development

No branches or pull requests

7 participants