-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Update codegen for 2018-06-22 nightly. #666
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
use syntax::codemap; | ||
use syntax::parse::parser::{PathStyle, Parser}; | ||
use syntax::parse::PResult; | ||
use syntax::parse::{SeqSep, PResult}; | ||
use syntax::ast::{self, Path, StrStyle, Ident}; | ||
use syntax::parse::token; | ||
use syntax::parse::token::Token::{Eof, Comma}; | ||
use syntax::parse::common::SeqSep; | ||
use syntax::symbol::Symbol; | ||
|
||
pub trait ParserExt<'a> { | ||
|
@@ -14,6 +15,10 @@ pub trait ParserExt<'a> { | |
|
||
// Like `parse_ident` but also looks for an `ident` in a `Pat`. | ||
fn parse_ident_inc_pat(&mut self) -> PResult<'a, Ident>; | ||
|
||
// Duplicates previously removed method in libsyntax | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this link back to the rust repository more concretely? I wasn't sure if I should refer to a PR, commit, URL, or just leave a generic note like this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's link to the PR that removed the method. Something like, "See https://github.com/rust-lang/rust/foo/bar/baz for more details.". |
||
fn parse_seq<T, F>(&mut self, bra: &token::Token, ket: &token::Token, sep: SeqSep, f: F) | ||
-> PResult<'a, codemap::Spanned<Vec<T>>> where F: FnMut(&mut Parser<'a>) -> PResult<'a, T>; | ||
} | ||
|
||
impl<'a> ParserExt<'a> for Parser<'a> { | ||
|
@@ -53,4 +58,22 @@ impl<'a> ParserExt<'a> for Parser<'a> { | |
Ok(ident) | ||
}) | ||
} | ||
|
||
// NB: Do not use this function unless you actually plan to place the | ||
// spanned list in the AST. | ||
fn parse_seq<T, F>(&mut self, | ||
bra: &token::Token, | ||
ket: &token::Token, | ||
sep: SeqSep, | ||
f: F) | ||
-> PResult<'a, codemap::Spanned<Vec<T>>> where | ||
F: FnMut(&mut Parser<'a>) -> PResult<'a, T>, | ||
{ | ||
let lo = self.span; | ||
self.expect(bra)?; | ||
let result = self.parse_seq_to_before_end(ket, sep, f)?; | ||
let hi = self.span; | ||
self.bump(); | ||
Ok(codemap::respan(lo.to(hi), result)) | ||
} | ||
} |
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.
This is the only part I'm not quite certain of. Seems to work, but there might be a better way of doing this.
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.
Does
ident
include the initial tick'
? You should take a look at the generated code and ensure that it looks correct, even if it's accepted by the compiler otherwise. Aside from this, this looks good, though it would seem thatkind
doesn't need to be aref kind
.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.
I'm pushing a slightly different fix for this in 0.3. Let's use the same one for master.