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

Support `?Sized` in where clauses #37791

Merged
merged 1 commit into from Nov 29, 2016

Conversation

Projects
None yet
9 participants
@petrochenkov
Contributor

petrochenkov commented Nov 16, 2016

Implemented as described in #20503 (comment) - ?Trait bounds are moved on type parameter definitions when possible, reported as errors otherwise.
(It'd be nice to unify bounds and where clauses in HIR, but this is mostly blocked by rustdoc now - it needs to render bounds in pleasant way and the best way to do it so far is to mirror what was written in source code.)

Fixes #20503
r? @nikomatsakis

@nikomatsakis

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis

nikomatsakis Nov 16, 2016

Contributor

@petrochenkov do you have an alternate, more hygiene-friendly impl in mind?

Contributor

nikomatsakis commented Nov 16, 2016

@petrochenkov do you have an alternate, more hygiene-friendly impl in mind?

@petrochenkov

This comment has been minimized.

Show comment
Hide comment
@petrochenkov

petrochenkov Nov 16, 2016

Contributor

@nikomatsakis
Yes, sure, all definitions are recorded in def map when AST->HIR lowering happens and can be compared instead of names.

Contributor

petrochenkov commented Nov 16, 2016

@nikomatsakis
Yes, sure, all definitions are recorded in def map when AST->HIR lowering happens and can be compared instead of names.

@nikomatsakis

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis

nikomatsakis Nov 17, 2016

Contributor

@petrochenkov ok seems better

Contributor

nikomatsakis commented Nov 17, 2016

@petrochenkov ok seems better

@petrochenkov

This comment has been minimized.

Show comment
Hide comment
@petrochenkov

petrochenkov Nov 17, 2016

Contributor

Updated.

Contributor

petrochenkov commented Nov 17, 2016

Updated.

@thepowersgang

This comment has been minimized.

Show comment
Hide comment
@thepowersgang

thepowersgang Nov 22, 2016

Contributor

I am against this because I believe that being sized is such an important part of the type that the annotation removing it should be in a prominent location, not hidden among the where clauses.

Contributor

thepowersgang commented Nov 22, 2016

I am against this because I believe that being sized is such an important part of the type that the annotation removing it should be in a prominent location, not hidden among the where clauses.

@KalitaAlexey

This comment has been minimized.

Show comment
Hide comment
@KalitaAlexey

KalitaAlexey Nov 22, 2016

Contributor

@thepowersgang I like to place all constraints after where.

Contributor

KalitaAlexey commented Nov 22, 2016

@thepowersgang I like to place all constraints after where.

@nikomatsakis

Code looks good, I just think we can tweak the error message.

Show outdated Hide outdated src/librustc/hir/lowering.rs
Show outdated Hide outdated src/test/compile-fail/maybe-bounds-where.rs

@nikomatsakis nikomatsakis added the T-lang label Nov 22, 2016

@nikomatsakis

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis

nikomatsakis Nov 22, 2016

Contributor

@rfcbot fcp merge

Strictly speaking, this is an "insta-stable" lang change. We could use a stability period, not sure if it is necessary in this case. I propose we merge, as this feels more like a bugfix to me, but am amenable to a stability period as well. But let's FCP it.

OK @rust-lang/lang, what do you think? The change is to permit fn foo<T>() where T: ?Sized and not require that it be declared like fn foo<T: ?Sized>() (i.e., allow T: ?Sized to be moved into a where-clause on the item where T is declared.

Contributor

nikomatsakis commented Nov 22, 2016

@rfcbot fcp merge

Strictly speaking, this is an "insta-stable" lang change. We could use a stability period, not sure if it is necessary in this case. I propose we merge, as this feels more like a bugfix to me, but am amenable to a stability period as well. But let's FCP it.

OK @rust-lang/lang, what do you think? The change is to permit fn foo<T>() where T: ?Sized and not require that it be declared like fn foo<T: ?Sized>() (i.e., allow T: ?Sized to be moved into a where-clause on the item where T is declared.

@rfcbot

This comment has been minimized.

Show comment
Hide comment
@rfcbot

rfcbot Nov 22, 2016

Team member @nikomatsakis has proposed to merge this. The next step is review by the rest of the tagged teams:

No concerns currently listed.

Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

rfcbot commented Nov 22, 2016

Team member @nikomatsakis has proposed to merge this. The next step is review by the rest of the tagged teams:

No concerns currently listed.

Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@withoutboats

This comment has been minimized.

Show comment
Hide comment
@withoutboats

withoutboats Nov 22, 2016

Contributor

@rfcbot reviewed

Seems like a bug fix to me. It should always be possible to transpose bounds from the parameter introduction clause to the where clause. "Special cases aren't special enough to break the rules." etc

Contributor

withoutboats commented Nov 22, 2016

@rfcbot reviewed

Seems like a bug fix to me. It should always be possible to transpose bounds from the parameter introduction clause to the where clause. "Special cases aren't special enough to break the rules." etc

@nikomatsakis

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis
Contributor

nikomatsakis commented Nov 28, 2016

@bors r+

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Nov 28, 2016

Contributor

📌 Commit 7d15250 has been approved by nikomatsakis

Contributor

bors commented Nov 28, 2016

📌 Commit 7d15250 has been approved by nikomatsakis

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Nov 28, 2016

Contributor

⌛️ Testing commit 7d15250 with merge 1c44857...

Contributor

bors commented Nov 28, 2016

⌛️ Testing commit 7d15250 with merge 1c44857...

bors added a commit that referenced this pull request Nov 28, 2016

Auto merge of #37791 - petrochenkov:where, r=nikomatsakis
Support `?Sized` in where clauses

Implemented as described in #20503 (comment) - `?Trait` bounds are moved on type parameter definitions when possible, reported as errors otherwise.
(It'd be nice to unify bounds and where clauses in HIR, but this is mostly blocked by rustdoc now - it needs to render bounds in pleasant way and the best way to do it so far is to mirror what was written in source code.)

Fixes #20503
r? @nikomatsakis

@bors bors merged commit 7d15250 into rust-lang:master Nov 29, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details

@petrochenkov petrochenkov deleted the petrochenkov:where branch Mar 16, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment