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

Empty bounds lists in where clauses cause the type to not be WF-checked. #53696

Closed
eddyb opened this issue Aug 25, 2018 · 5 comments
Closed

Empty bounds lists in where clauses cause the type to not be WF-checked. #53696

eddyb opened this issue Aug 25, 2018 · 5 comments
Labels
A-typesystem Area: The type system T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@eddyb
Copy link
Member

eddyb commented Aug 25, 2018

This produces no error:

fn foo() where Vec<dyn Copy>: {}

Just like the other known "missing WF checks" bug (#21903):

type Foo = Vec<dyn Copy>;

Unlike type aliases, I don't believe you can even reach the type written in the where clause without any bounds, since it doesn't even "remain in the type/trait-system" (e.g. inference can't pick it up).

So it's not as bad, but I did come up with use for it as a WF requirement, in #44580 (comment).

cc @rust-lang/lang @RalfJung @petrochenkov

@eddyb eddyb added A-typesystem Area: The type system I-nominated T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Aug 25, 2018
bors added a commit that referenced this issue Aug 25, 2018
rustc_typeck: turn `where Type:,` into a WF(Type) predicate, instead of ignoring it.

Fixes #53696, assuming crater doesn't catch anyone using this syntax already.

r? @nikomatsakis cc @petrochenkov
@Centril
Copy link
Contributor

Centril commented Aug 27, 2018

Why is fn foo() where Vec<dyn Copy>: {} even passing the parser?
There is no bound on the RHS of :...

@cramertj
Copy link
Member

@Centril We're pretty permissive with parsing "zero or more" of many syntax elements, e.g. fn foo() where {} also compiles.

@Centril
Copy link
Contributor

Centril commented Aug 27, 2018

@cramertj Oh I see; that's where this is coming from. It didn't click initially; Thanks! ❤️

@Centril
Copy link
Contributor

Centril commented Aug 30, 2018

We discussed this briefly on the meeting and the consensus was that if crater passes, then this is fine.

@eddyb
Copy link
Member Author

eddyb commented Sep 5, 2018

This is waiting on @nikomatsakis or someone else r+'ing #53707 (crater was clean).

bors added a commit that referenced this issue Sep 6, 2018
rustc_typeck: turn `where Type:,` into a WF(Type) predicate, instead of ignoring it.

Fixes #53696, assuming crater doesn't catch anyone using this syntax already.

Allowing an empty list of bounds in the grammar was done for the benefit of macro authors, most of which would *probably* be using it for bounds on type parameters, which are always WF.

r? @nikomatsakis cc @petrochenkov
scalexm added a commit to scalexm/rust that referenced this issue Nov 13, 2018
)

A `WF(Type)` predicate was used previously, which did not play
well with implied bounds in chalk.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-typesystem Area: The type system 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

3 participants