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

(RFC 1210) specialization: restrictions around lifetime dispatch #45982

Closed
3 tasks
giannicic opened this issue Nov 14, 2017 · 1 comment
Closed
3 tasks

(RFC 1210) specialization: restrictions around lifetime dispatch #45982

giannicic opened this issue Nov 14, 2017 · 1 comment
Labels
A-lifetimes Area: lifetime related A-specialization Area: Trait impl specialization C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. F-specialization `#![feature(specialization)]` I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness requires-nightly This issue requires a nightly compiler in some way. S-tracking-design-concerns Status: There are blocking ❌ design concerns. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@giannicic
Copy link
Contributor

giannicic commented Nov 14, 2017

Note: #31844 is the tracking issue for specialization in general

this issue tracks the tasks to do to implement "restrictions around lifetime dispatch" as described here:

Specialization based on lifetimes shouldn't be allowed partly because "trans" erases any lifetime information and partly because lifetime inference could lead to counterintuitive result.
Unfotunately it's not easy to avoid any lifetime dependent specialization.
Additionally, using lifetime specialized associated types results in different deductions between type_check and trans

Things to do:

  • Stabilize just the core specialization, it will work without specializing associated type. Introduce a new feature gate called assoc_specialization necessary when using specialization on default types.
  • Issue a warning that a specialization might have applied in case a specialized impl imposes any lifetime constraints not present in the more general impl.
    The warning should be issued at trans time when the more general impl is selected over the specialized impl, it could be relaxed or forbidden as described in this reply
  • If the specialized impl use the same lifetime constraints as the more general impl, specialization should work as expected.

@nikomatsakis

@TimNN TimNN added the C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. label Nov 14, 2017
@jonas-schievink jonas-schievink added A-specialization Area: Trait impl specialization F-specialization `#![feature(specialization)]` A-lifetimes Area: lifetime related I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Nov 26, 2019
@Centril Centril added the requires-nightly This issue requires a nightly compiler in some way. label Mar 26, 2020
bors added a commit to rust-lang/hashbrown that referenced this issue Apr 25, 2020
Remove unsound use of specialization

Basically the issue is that specialization does not currently take lifetimes into account.

See rust-lang/rust#45982 for details.
@Elinvynia Elinvynia added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jun 9, 2020
@LeSeulArtichaut LeSeulArtichaut removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jun 9, 2020
@joshtriplett joshtriplett added the S-tracking-design-concerns Status: There are blocking ❌ design concerns. label Aug 10, 2022
@Mark-Simulacrum
Copy link
Member

Mark-Simulacrum commented Aug 10, 2022

It seems like this isn't tracking extra state -- #31844 is the primary tracking issue for specialization, and already has discussion of it being unsound. There's definitely work here to resolve these concerns and move us forward, but it's not particularly useful to have a separate issue for it that's not being actively updated or paid attention to.

With that in mind, closing in favor of #31844.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: lifetime related A-specialization Area: Trait impl specialization C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. F-specialization `#![feature(specialization)]` I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness requires-nightly This issue requires a nightly compiler in some way. S-tracking-design-concerns Status: There are blocking ❌ design concerns. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

8 participants