mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
cfc5f25b3d
Reorder trait bound modifiers *after* `for<...>` binder in trait bounds This PR suggests changing the grammar of trait bounds from: ``` [CONSTNESS] [ASYNCNESS] [?] [BINDER] [TRAIT_PATH] const async ? for<'a> Sized ``` to ``` ([BINDER] [CONSTNESS] [ASYNCNESS] | [?]) [TRAIT_PATH] ``` i.e., either ``` ? Sized ``` or ``` for<'a> const async Sized ``` (but not both) ### Why? I think it's strange that the binder applies "more tightly" than the `?` trait polarity. This becomes even weirder when considering that we (or at least, I) want to have `async` trait bounds expressed like: ``` where T: for<'a> async Fn(&'a ()) -> i32, ``` and not: ``` where T: async for<'a> Fn(&'a ()) -> i32, ``` ### Fallout No crates on crater use this syntax, presumably because it's literally useless. This will require modifying the reference grammar, though. ### Alternatives If this is not desirable, then we can alternatively keep parsing `for<'a>` after the `?` but deprecate it with either an FCW (or an immediate hard error), and begin parsing `for<'a>` *before* the `?`. |
||
---|---|---|
.. | ||
auxiliary | ||
dyn-pos.rs | ||
dyn-pos.stderr | ||
edition-2015-not-async-bound.rs | ||
edition-2015.rs | ||
edition-2015.stderr | ||
higher-ranked-async-fn.rs | ||
impl-header.rs | ||
impl-header.stderr | ||
impl-trait.rs | ||
mbe-async-trait-bound-theoretical-regression.rs | ||
mbe-async-trait-bound-theoretical-regression.stderr | ||
method-call-pos.rs | ||
method-call-pos.stderr | ||
not-a-trait.rs | ||
not-a-trait.stderr | ||
project.rs | ||
simple.rs | ||
sugar.rs | ||
trait-bounds-in-macro.rs | ||
trait-bounds-in-macro.stderr | ||
wrong-trait.rs | ||
wrong-trait.stderr |