Support ?Sized in where clauses#37791
Conversation
src/librustc/hir/lowering.rs
Outdated
There was a problem hiding this comment.
s/break/continue/
src/librustc/hir/lowering.rs
Outdated
There was a problem hiding this comment.
Can't macros make a mess of this in their evil macro-ey ways? Better look up the definition to avoid the question.
There was a problem hiding this comment.
Type parameters are not hygienic now, but it may make sense to lookup definitions for future proofing. Even if this is a loop it's probably not very performance critical.
There was a problem hiding this comment.
Sure. Randomly implementing unhygienic lookup is a sure way to cause bugs in the future.
|
@petrochenkov do you have an alternate, more hygiene-friendly impl in mind? |
|
@nikomatsakis |
|
@petrochenkov ok seems better |
|
Updated. |
|
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. |
|
@thepowersgang I like to place all constraints after |
nikomatsakis
left a comment
There was a problem hiding this comment.
Code looks good, I just think we can tweak the error message.
src/librustc/hir/lowering.rs
Outdated
There was a problem hiding this comment.
Nit: maybe "only permitted at the point where a type parameter is declared"?
There was a problem hiding this comment.
Updated the message.
There was a problem hiding this comment.
what on earth is ?Trait<'static>? we permit that??
There was a problem hiding this comment.
huh, apparently. I would have thought it'd be an error. Oh well, obviously pre-existing.
|
@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 |
|
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 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 |
|
@bors r+ |
|
📌 Commit 7d15250 has been approved by |
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
Implemented as described in #20503 (comment) -
?Traitbounds 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