Skip to content

Prevent where < ident > from parsing. - #38268

Merged
bors merged 4 commits into
rust-lang:masterfrom
withoutboats:parse_where_higher_rank_hack
Dec 24, 2016
Merged

Prevent where < ident > from parsing.#38268
bors merged 4 commits into
rust-lang:masterfrom
withoutboats:parse_where_higher_rank_hack

Conversation

@withoutboats

Copy link
Copy Markdown
Contributor

In order to be forward compatible with where<'a> syntax for higher
rank parameters, prevent potential conflicts with UFCS from parsing
correctly for the near term.

In order to be forward compatible with `where<'a>` syntax for higher
rank parameters, prevent potential conflicts with UFCS from parsing
correctly for the near term.
@rust-highfive

Copy link
Copy Markdown
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@withoutboats

Copy link
Copy Markdown
ContributorAuthor

This is my first PR to rustc! 🎉

I think this is correct, though I don't have any idea at all what error message to issue in this case.

See also rust-lang/rfcs#1598 for background on this change. cc @rust-lang/lang

r? @eddyb

Comment threadsrc/libsyntax/parse/parser.rs Outdated
*t == token::Gt || *t == token::Comma || *t == token::Colon
});
if gt_comma_or_colon {
return Err(self.fatal("TODO How to even explain this error?"));

@petrochenkovpetrochenkovDec 9, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a recoverable error, no need to return Err.
self.err("syntax `where<T>` is reserved for future use"); would be more appropriate.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consume tokens until the the next Gt in that case?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, if it's indeed <A>::B: Tr (more likely), then it'll parse successfully without consuming extra tokens, otherwise (less likely) it doesn't matter.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But don't we want it to parse as ::B: Tr1? I suppose it doesn't matter much since it errors anyway.

@eddyb

eddyb commented Dec 10, 2016

Copy link
Copy Markdown
Contributor

LGTM, I'll start a crater run.

@eddybeddyb added the T-lang Relevant to the language team label Dec 10, 2016
@eddyb

Copy link
Copy Markdown
Contributor

@brson Looks like crater is busted again, build completes successfully but then:

mv: cannot stat 'rust/dist/rustc-*-x86_64-unknown-linux-gnu.tar.gz': No such file or directory

@withoutboats

Copy link
Copy Markdown
ContributorAuthor

Any update on crater?

This wants to land before the next beta is cut.

@eddyb

Copy link
Copy Markdown
Contributor

@withoutboats If you rebase I could try again, but I didn't hear back from @brson on this.

@withoutboats

Copy link
Copy Markdown
ContributorAuthor

Cool, I'll rebase when I get home tonight

@brson

Copy link
Copy Markdown
Contributor

@eddyb This is because of the change to rustbuild. Also changes to cargo's release process broke crater. So crater can neither build custom rustc nor install the latest cargo nightlies atm. I can't get to it this week I'm afraid, but next.

@brson

Copy link
Copy Markdown
Contributor

I'll crater.

@withoutboats

Copy link
Copy Markdown
ContributorAuthor

oops i forgot to rebase this, let me know if thats a problem

@brson

Copy link
Copy Markdown
Contributor

Crater says: https://gist.github.com/anonymous/4ad4a0abf91b713fa58d7771ad281de0

Looks like no regressions, 1 false positive.

@brsonbrson added the relnotes Marks issues that should be documented in the release notes of the next release. label Dec 23, 2016
@withoutboats

Copy link
Copy Markdown
ContributorAuthor

Awesome, what are the steps to landing & backporting this to 1.15 beta?

@aturon

Copy link
Copy Markdown
Contributor

Since @eddyb already reviewed, it's ready for bors! I'll also nominate for backport.

@bors r=eddyb

@bors

bors commented Dec 23, 2016

Copy link
Copy Markdown
Collaborator

📌 Commit 14e4b00 has been approved by eddyb

@aturonaturon added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Dec 23, 2016
@bors

bors commented Dec 24, 2016

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 14e4b00 with merge 8d65c8d...

bors added a commit that referenced this pull request Dec 24, 2016
…ddyb
Prevent where < ident > from parsing.
In order to be forward compatible with `where<'a>` syntax for higher
rank parameters, prevent potential conflicts with UFCS from parsing
correctly for the near term.
@bors
bors merged commit 14e4b00 into rust-lang:masterDec 24, 2016
@nikomatsakis

Copy link
Copy Markdown
Contributor

Why do we want this on 1.15 beta?

@eddyb

Copy link
Copy Markdown
Contributor

Because in 1.15, one of my PRs made it so where <T>::Assoc: ... worked just as well as the form without <>, as HIR no longer distinguishes between the two - this information should've been in the description.

@nikomatsakisnikomatsakis added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Dec 30, 2016
@nikomatsakis

Copy link
Copy Markdown
Contributor

OK, marking as beta-accepted. cc @rust-lang/compiler

@nikomatsakisnikomatsakis mentioned this pull request Jan 6, 2017
17 tasks
@alexcrichtonalexcrichton removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jan 6, 2017
bors added a commit that referenced this pull request Jan 14, 2018
syntax: Rewrite parsing of impls
Properly parse impls for the never type `!`
Recover from missing `for` in `impl Trait for Type`
Prohibit inherent default impls and default impls of auto traits (#37653 (comment), #37653 (comment))
Change wording in more diagnostics to use "auto traits"
Fix some spans in diagnostics
Some other minor code cleanups in the parser
Disambiguate generics and qualified paths in impls (parse `impl <Type as Trait>::AssocTy { ... }`)
Replace the future-compatibility hack from #38268 with actually parsing generic parameters
Add a test for #46438
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beta-acceptedAccepted for backporting to the compiler in the beta channel.relnotesMarks issues that should be documented in the release notes of the next release.T-langRelevant to the language team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@withoutboats@rust-highfive@eddyb@brson@aturon@bors@nikomatsakis@petrochenkov@alexcrichton