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

Negative blanket OIBIT impl treated as positive #28475

Closed
bluss opened this issue Sep 17, 2015 · 5 comments
Closed

Negative blanket OIBIT impl treated as positive #28475

bluss opened this issue Sep 17, 2015 · 5 comments
Labels
A-type-system Area: Type system C-bug Category: This is a bug. P-medium Medium priority T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@bluss
Copy link
Member

bluss commented Sep 17, 2015

impl !Pod for .. {} looks like it produces a positive impl.

(playpen)

#![feature(optin_builtin_traits)]

unsafe trait Pod {}

unsafe impl !Pod for .. {}

struct Foo<X, Y>(X, Y);

fn is_pod<T: Pod>(_: &T) { }

fn main() {
    is_pod(&Foo(0, 0));
}

cc @nikomatsakis

OIBIT tracker issue: #13231

@arielb1
Copy link
Contributor

arielb1 commented Sep 17, 2015

Negative impls are only supposed to work if they are nominal (impl<U,V,W> !Foo for Bar<U,V,W>). We should however decide what this means.

@nikomatsakis
Copy link
Contributor

impl !Pod for .. is certainly not legal, in any case.

@brson brson added T-lang Relevant to the language team, which will review and decide on the PR/issue. A-type-system Area: Type system I-wrong P-medium Medium priority and removed A-lang labels Mar 23, 2017
@Mark-Simulacrum Mark-Simulacrum added C-bug Category: This is a bug. and removed I-wrong labels Jul 24, 2017
@lcnr
Copy link
Contributor

lcnr commented Jul 21, 2020

What exactly has to be done to close this issue?

The example given here doesn't seem to compile.

@jonas-schievink
Copy link
Contributor

impl Trait for .. syntax doesn't exist anymore, so it's impossible to write this sort of impl now.

@nikomatsakis
Copy link
Contributor

Yeah, that syntax never made sense, and has been replaced with "auto trait" (or is it #[auto] trait). Probably this issue is just "outmoded".

One thing is that I think we should not permit a negative impl like impl<T> !Foo for T -- i.e., negative impls should always be implemented for specific types. The truth is that we have to write out the specific rules at some point.

@fmease fmease added A-type-system Area: Type system and removed A-type-system Area: Type system labels Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system C-bug Category: This is a bug. P-medium Medium priority 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

9 participants