-
-
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
Conversation
@jebrosen The implementations for these functions: are they copied straight from the rustc source code, or did you reimplement them yourself? |
These are all from Rereading at my original comment, it was not very clear that my intent here is to demonstrate that it is possible for this code to be duplicated and in the case of of From my point of view, these are the options I see in order of desirability:
|
We absolutely want to move away from I think we should proceed with a combination of 2) and 3) as follows: if the method still exists in |
Sounds good. I am preparing a PR for rust-lang/rust that makes the these methods public, and will remove them from this PR. |
…-Simulacrum make more libsyntax methods public Followup for rust-lang#51502, which was sufficient only for the latest stable release of Rocket. The `master` branch uses a few more. I plan to reimplement the deleted method `parse_seq` in Rocket (see rwf2/Rocket#666), rather than resurrecting it in libsyntax. r? @Mark-Simulacrum
e0e96b1
to
c5a24ee
Compare
Rebased, rewrote, and also updated for compatibility with changes introduced by rust-lang/rust#48149. |
c5a24ee
to
f33c8e3
Compare
@@ -27,11 +27,11 @@ fn struct_lifetime(ecx: &mut ExtCtxt, item: &Annotatable, sp: Span) -> Option<St | |||
ItemKind::Struct(_, ref generics) => { | |||
let mut lifetimes = generics.params.iter() | |||
.filter_map(|p| match *p { | |||
GenericParam::Lifetime(ref def) => Some(def), | |||
GenericParam { ref ident, ref kind, .. } if *kind == GenericParamKind::Lifetime => Some(ident), |
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 that kind
doesn't need to be a ref 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.
@@ -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 comment
The 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 comment
The 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.".
Fixes #660 in the
master
branch.Depends on rust-lang/rust#51664.parse_seq
is identical to the method removed from libsyntax.Also includes fix for next breakage, introduced around 2018-06-22.
parse_optional_str
andmk_mac_expr
(which are private) are now re-implemented by Rocket inparser_ext.rs
by a copy/paste and fixing up the paths.parse_seq
was deleted. This reimplementation is not quite identical: it usesparse_seq_to_end
, which we already asked be made public, instead ofparse_seq_to_before_end
, which is still private. I think the span associated with the result is one character longer than it was in the original implementation. I would like to fix that but I am not sure how to correct it (or even inspect or verify it).If a "quick fix" that makes no changes to libsyntax is useful or helpful, this appears to work. It does have a likelihood of bitrot, but Rocket will eventually move away from libsyntax anyway.If requesting changes to libsyntax is preferred, I think we can get by withparse_optional_str
andmk_mac_expr
public, and either reintroduceparse_seq
or re-implement it (correctly, not necessarily this implementation) in Rocket. Havingparse_seq_to_before_end
would help if we were to re-implementparse_seq
in Rocket.EDIT: I have not (yet) verified that the nightly bound (2018-06-12) is actually sufficient, but I believe it should be.