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

[Invalid accepted] E0568 can be bypassed by where Self #84075

Closed
codehz opened this issue Apr 10, 2021 · 3 comments · Fixed by #89494
Closed

[Invalid accepted] E0568 can be bypassed by where Self #84075

codehz opened this issue Apr 10, 2021 · 3 comments · Fixed by #89494
Labels
A-traits Area: Trait system C-bug Category: This is a bug. F-auto_traits `#![feature(auto_traits)]` I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness P-high High priority requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@codehz
Copy link

codehz commented Apr 10, 2021

I tried this code:

#![feature(auto_traits)]

auto trait CanCopy where Self: Copy {}

I expected to see this happen: got E0568 because the unstable book say supertraits for auto trait are unsound

Instead, this happened: Compiler accepted those code

Playground link:
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=57126ad5d71bd5bbaa913416b70fae67

Meta

rustc --version --verbose:

1.53.0-nightly

(2021-04-09 dae9d6ac3e9a8fb389cf)
(rust playground)

nightly feature tracking issue: #13231

@codehz codehz added the C-bug Category: This is a bug. label Apr 10, 2021
@nbdd0121
Copy link
Contributor

nbdd0121 commented Apr 10, 2021

A slight tweak with the example in #29859, this is indeed unsound.

#![feature(auto_traits)]

auto trait Magic where Self: Copy {}
impl<T: Magic> Magic for T {}

fn copy<T: Magic>(x: T) -> (T, T) { (x, x) }

#[derive(Debug)]
struct NoClone;

fn main() {
    let (a, b) = copy(NoClone);
    println!("{:?} {:?}", a, b);
}

This compiles while it shouldn't.

@rustbot label: +requires-nightly

@rustbot
Copy link
Collaborator

rustbot commented Apr 10, 2021

Error: Label 💥 can only be set by Rust team members

Please let @rust-lang/release know if you're having trouble with this bot.

@rustbot rustbot added the requires-nightly This issue requires a nightly compiler in some way. label Apr 10, 2021
@jonas-schievink jonas-schievink added F-auto_traits `#![feature(auto_traits)]` I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness labels Apr 10, 2021
@camelid camelid added A-traits Area: Trait system I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Apr 11, 2021
@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 14, 2021
@apiraino
Copy link
Contributor

apiraino commented Apr 15, 2021

Assigning priority as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

edit: upgrading to p-high because by looking at the code samples, the unsoundness looks easy to trigger

@rustbot label -I-prioritize +P-high

@rustbot rustbot added P-medium Medium priority P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Apr 15, 2021
@apiraino apiraino removed the P-medium Medium priority label Apr 16, 2021
Manishearth added a commit to Manishearth/rust that referenced this issue Oct 5, 2021
Manishearth added a commit to Manishearth/rust that referenced this issue Oct 5, 2021
Manishearth added a commit to Manishearth/rust that referenced this issue Oct 5, 2021
Manishearth added a commit to Manishearth/rust that referenced this issue Oct 5, 2021
@bors bors closed this as completed in c9158db Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system C-bug Category: This is a bug. F-auto_traits `#![feature(auto_traits)]` I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness P-high High priority requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants