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

Specialization and lifetime dispatch #40582

Open
dtolnay opened this issue Mar 16, 2017 · 3 comments
Open

Specialization and lifetime dispatch #40582

dtolnay opened this issue Mar 16, 2017 · 3 comments
Labels
A-specialization Area: Trait impl specialization B-unstable Blocker: Implemented in the nightly compiler and unstable. C-bug Category: This is a bug. F-specialization `#![feature(specialization)]` I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness P-medium Medium priority requires-nightly This issue requires a nightly compiler in some way. S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@dtolnay
Copy link
Member

dtolnay commented Mar 16, 2017

I see this briefly mentioned in #31844 but no existing issue tracking the incorrect behavior.

Something in the following code is unsound. It should not be possible to implement make_static.

#![feature(specialization)]

trait FromRef<'a, T: ?Sized> {
    fn from_ref(r: &'a T) -> Self;
}

impl<'a, T: ?Sized> FromRef<'a, T> for &'a T {
    fn from_ref(r: &'a T) -> Self {
        r
    }
}

impl<'a, T: ?Sized, R> FromRef<'a, T> for R {
    default fn from_ref(_: &'a T) -> Self {
        unimplemented!()
    }
}

fn main() {
    let s = "specialization".to_owned();
    println!("{:?}", make_static(s.as_str()));
}

fn make_static<T: ?Sized>(data: &T) -> &'static T {
    fn helper<T: ?Sized, R>(data: &T) -> R {
        R::from_ref(data)
    }
    helper(data)
}
@Mark-Simulacrum Mark-Simulacrum added the A-specialization Area: Trait impl specialization label Jun 13, 2017
@Mark-Simulacrum Mark-Simulacrum added C-bug Category: This is a bug. I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 27, 2017
@Mark-Simulacrum
Copy link
Member

Nominating for a priority assignment, though I'm guessing this is a "fixed by chalk, we hope" issue.

@glaebhoerl
Copy link
Contributor

@nikomatsakis
Copy link
Contributor

triage: P-medium

Known problem, doin' what we can here!

@rust-highfive rust-highfive added P-medium Medium priority and removed I-nominated labels Aug 24, 2017
@bstrie bstrie added the B-unstable Blocker: Implemented in the nightly compiler and unstable. label Sep 20, 2017
@Centril Centril added F-specialization `#![feature(specialization)]` requires-nightly This issue requires a nightly compiler in some way. labels Jul 28, 2019
@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
@oli-obk oli-obk added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Oct 21, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 27, 2023
…unsound-issues, r=jackh726

Add `known-bug` tests for 4 unsound issues

This PR adds `known-bug` tests for 4 unsound issues as part of rust-lang#105107
- rust-lang#40582
- rust-lang#49682
- rust-lang#74629
- rust-lang#105782
@jackh726 jackh726 added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 27, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 27, 2023
…unsound-issues, r=jackh726

Add `known-bug` tests for 4 unsound issues

This PR adds `known-bug` tests for 4 unsound issues as part of rust-lang#105107
- rust-lang#40582
- rust-lang#49682
- rust-lang#74629
- rust-lang#105782
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-specialization Area: Trait impl specialization B-unstable Blocker: Implemented in the nightly compiler and unstable. C-bug Category: This is a bug. F-specialization `#![feature(specialization)]` I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness P-medium Medium priority requires-nightly This issue requires a nightly compiler in some way. S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests