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

impl SuperTrait for T: SubTrait does not work #71

Closed
mikeyhew opened this issue Nov 22, 2017 · 11 comments
Closed

impl SuperTrait for T: SubTrait does not work #71

mikeyhew opened this issue Nov 22, 2017 · 11 comments

Comments

@mikeyhew
Copy link
Contributor

The following works in Rust, but not in Chalk:

trait DynSized {}
trait Sized where Self: DynSized {}
impl<T> DynSized for T where T: Sized {}
struct i32 {}
impl Sized for i32 {}

For the goal i32: DynSized, Chalk currently returns "No possible solution", and it should return "Unique".

@mikeyhew
Copy link
Contributor Author

It looks like this is an instance of #12

@scalexm
Copy link
Member

scalexm commented Nov 22, 2017

@mikeyhew Yes, this is somehow a known bug, because of implied bounds not being completely implemented at the moment.

@mikeyhew
Copy link
Contributor Author

@scalexm what do you mean by "implied bounds"?

@scalexm
Copy link
Member

scalexm commented Nov 22, 2017

I mean things like "if T implements Sized, then T necessarily implements DynSized". For these kinds of affirmation to be correct, we must add some requirements on impls (called well-formedness requirements). Currently, these requirements are too restrictive, hence your code is not being accepted. That shall be fixed in the future.

@mikeyhew
Copy link
Contributor Author

@scalexm the above code is accepted by chalk. I guess it just ignores it though?

@mikeyhew
Copy link
Contributor Author

@scalexm I tried out your implied-bounds branch, but didn't notice any changes with the above code :/

@scalexm
Copy link
Member

scalexm commented Nov 22, 2017

@mikeyhew Yes by "not accepted" I meant "gives a wrong answer", sorry :)
That's indeed because the remaining work is to be done in my implied-bounds branch (and that's also why the PR's still open).

@mikeyhew
Copy link
Contributor Author

mikeyhew commented Nov 22, 2017

@scalexm Oh, I see... I saw that @nikomatsakis was reviewing it, and assumed it was otherwise good to go 😄

@mikeyhew
Copy link
Contributor Author

I'm gonna close this, since it is a duplicate of #12

@scalexm
Copy link
Member

scalexm commented Feb 8, 2018

@mikeyhew PS: it works now

@mikeyhew
Copy link
Contributor Author

mikeyhew commented Feb 8, 2018

@scalexm Sweet!

trait DynSized {}
trait Sized where Self: DynSized {}
impl<T> DynSized for T where T: Sized {}
struct i32 {}
impl Sized for i32 {}

// ?- i32: DynSized
// Unique; substitution [], lifetime constraints []

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