Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
syntax: Tweak parsing lifetime bounds on closures
In summary these are some example transitions this change makes: 'a || => ||: 'a proc:Send() => proc():Send The intended syntax for closures is to put the lifetime bound not at the front but rather in the list of bounds. Currently there is no official support in the AST for bounds that are not 'static, so this case is currently specially handled in the parser to desugar to what the AST is expecting. Additionally, this moves the bounds on procedures to the correct position, which is after the argument list. The current grammar for closures and procedures is: procedure := 'proc' [ '<' lifetime-list '>' ] '(' arg-list ')' [ ':' bound-list ] [ '->' type ] closure := [ 'unsafe' ] ['<' lifetime-list '>' ] '|' arg-list '|' [ ':' bound-list ] [ '->' type ] lifetime-list := lifetime | lifetime ',' lifetime-list arg-list := ident ':' type | ident ':' type ',' arg-list bound-list := bound | bound '+' bound-list bound := path | lifetime This does not currently handle the << ambiguity in `Option<<'a>||>`, I am deferring that to a later patch. Additionally, this removes the support for the obsolete syntaxes of ~fn and &fn. Closes #10553 Closes #10767 Closes #11209 Closes #11210 Closes #11211
- Loading branch information
304d82a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from cmr
at alexcrichton@304d82a
304d82a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging alexcrichton/rust/parse-closure = 304d82a into auto
304d82a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alexcrichton/rust/parse-closure = 304d82a merged ok, testing candidate = 899c635
304d82a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some tests failed:
failure: http://buildbot.rust-lang.org/builders/auto-bsd-64-opt/builds/4922
exception: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/5059
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/5059
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/4151
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/4165
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/5159
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/4246
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/4254
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/5161
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/4246
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/4251
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android/builds/4317
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/2046
exception: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/5158
exception: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/4255
exception: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/4266