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

Allow implementing traits with statically uncallable methods #35369

Closed
Stebalien opened this issue Aug 5, 2016 · 2 comments
Closed

Allow implementing traits with statically uncallable methods #35369

Stebalien opened this issue Aug 5, 2016 · 2 comments

Comments

@Stebalien
Copy link
Contributor

Stebalien commented Aug 5, 2016

Basically, given:

trait Foo {
    fn foo(self) where Self: Sized;
    fn bar(&self);
}

The following is valid:

impl<T: ?Sized> Foo for T {
    fn foo(self) where Self: Sized {}
    fn bar(&self) {}
}

But the following isn't:

impl<T> Foo for [T] {
    fn foo(self) where Self: Sized { unreachable!() } // Should disappear at compile-time.
    fn bar(&self) {}
}

This means that, for example, Iterator can't be implemented types that are known to be DSTs, only types that may be DSTs. This is an inconsistent and an unnecessary limitation.

@nikomatsakis
Copy link
Contributor

Dup of #20021

@nikomatsakis
Copy link
Contributor

(I closed in favor of #20021 as it has more discussion)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants