-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Remove NtExpr
.
#96724
Remove NtExpr
.
#96724
Conversation
I was playing around with this just to see what happened. #96627 showed that avoiding
For these four, after the change there is one less error than before. And I think the new behaviour is better. I can't see why the relevant lines were errors. Perhaps the parser has one or more places where an
For these ones a lot of the stringified outputs have changed. A lot are worse, with worse spacing. But a few are arguably better. There's even a
These are ones where the error messages have changed a little for the worse. After the // Current rustc and new version both reject this like so:
//
// error: `<` is interpreted as a start of generic arguments for `u32`, not a shift
// --> f.rs:15:14
// |
// 15 | 1 as u32 << 24
// | ^^ -- interpreted as generic arguments
// | |
// | not interpreted as shift
// |
// help: try shifting the cast value
// |
// 15 | (1 as u32) << 24
// | + +
fn sample2() -> u32 {
1 as u32 << 24
}
// Current rustc accepts this, new version doesn't.
macro_rules! f {
($u_scalar:ty) => {
fn sample1() -> u32 {
1 as $u_scalar << 24
}
}
}
f! { u32 }
fn main() {
let _ = sample1() + sample2();
} Again, I think the new behaviour is reasonable. This doesn't seem possible to land, but it does suggest that the current use of |
773bc03
to
a778dde
Compare
This comment has been minimized.
This comment has been minimized.
The If we assume that (*) The grammar is |
Conclusion: most of the changes in tests will disappear if |
For quick testing you can replace the invisibles with regular parentheses |
This comment was marked as resolved.
This comment was marked as resolved.
4096efb
to
0fa765f
Compare
I have updated. As well as not producing On one hand, it's encouraging that I've managed to get it down to only four |
This comment has been minimized.
This comment has been minimized.
@nnethercote fn bump(&self, preserve_invisible: bool) { ... } ? I'm not ready to take a responsibility for reviewing a change that does all of this in one go. Every such step may potentially require a language team involvement. |
I understand the motivation here. But we always get one token in advance. When we're at a place where we want to allow an invisible delimiter, e.g. in |
I need to think how to better stage the implementation here. |
So, to split the implementation into multiple part we need To do that we should be able to simply keep an extra flag in Once all nonterminal tokens are migrated we'll be able to switch this flag to "never skip" and process invisible delimiters from proc macros correctly too. |
Good suggestion. I have added the flag to
|
0fa765f
to
6b6f97f
Compare
The current test failures:
|
This comment has been minimized.
This comment has been minimized.
Interesting: the change of pretty-printing from "foo::bar" to "foo :: bar" broke some links in doctests. Fortunately it's pretty easy to address, just by adding |
f3c1674
to
5f31dad
Compare
TokenKind::Interpolate
for NtTy
.NtExpr
.
I have updated the code, which has a bunch of fixes, including a couple from @petrochenkov's branches. I have disabled two tests and commented out some failing-to-parse assertions in one unit test. Except for those, all tests now pass, so that's some kind of progress. Still plenty of wrinkles to iron out, though, and who knows what a crater run might uncover. |
5f31dad
to
6a9399b
Compare
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #97239) made this pull request unmergeable. Please resolve the merge conflicts. |
doctest failures: ``` proc_macro/struct.Diagnostic.html:14: broken intra-doc link - [<code>Level :: Error</code>] proc_macro/struct.Diagnostic.html:15: broken intra-doc link - [<code>Level :: Error</code>] proc_macro/struct.Diagnostic.html:16: broken intra-doc link - [<code>Level :: Warning</code>] proc_macro/struct.Diagnostic.html:17: broken intra-doc link - [<code>Level :: Warning</code>] proc_macro/struct.Diagnostic.html:18: broken intra-doc link - [<code>Level :: Note</code>] proc_macro/struct.Diagnostic.html:19: broken intra-doc link - [<code>Level :: Note</code>] proc_macro/struct.Diagnostic.html:20: broken intra-doc link - [<code>Level :: Help</code>] proc_macro/struct.Diagnostic.html:21: broken intra-doc link - [<code>Level :: Help</code>] checked links in: 3.9s number of HTML files scanned: 32308 number of HTML redirects found: 10094 number of links checked: 2259114 number of links ignored due to external: 112863 number of links ignored due to exceptions: 19 number of intra doc links ignored: 25 errors found: 8 found some broken links ``` XXX: caused by changes in pretty-printing: `Level::Error` -> `Level :: Error`.
[*] two ui tests temporarily removed, and one unit test has a couple of failing-to-parse assertions removed. XXX: - Some tests have sub-optimal error messages, I want to improve them - Added a `src` field to `Delimiter::Invisible` which indicates where it came from, partly replicates the Nonterminal kind within `Interpolated`. - parse_meta_item_inner required significant changes, it was assuming that parse_unsuffixed_lit didn't consume any tokens on failure
6a9399b
to
17a1e04
Compare
☔ The latest upstream changes (presumably #97293) made this pull request unmergeable. Please resolve the merge conflicts. |
@nnethercote what's the update on this? |
I'm not planning to work on it further, because it seems too hard and likely to have major backwards incompatibility problems. I am ok with closing it, if you want. |
Thanks for the update. Closing it then :) |
…Kind-Interpolated, r=<try> Remove `Nonterminal` and `TokenKind::Interpolated` A third attempt at this; the first attempt was rust-lang#96724 and the second was rust-lang#114647. r? `@ghost`
…Kind-Interpolated, r=<try> Remove `Nonterminal` and `TokenKind::Interpolated` A third attempt at this; the first attempt was rust-lang#96724 and the second was rust-lang#114647. r? `@ghost`
…Kind-Interpolated, r=<try> Remove `Nonterminal` and `TokenKind::Interpolated` A third attempt at this; the first attempt was rust-lang#96724 and the second was rust-lang#114647. r? `@ghost`
…Kind-Interpolated, r=<try> Remove `Nonterminal` and `TokenKind::Interpolated` A third attempt at this; the first attempt was rust-lang#96724 and the second was rust-lang#114647. r? `@ghost`
…Kind-Interpolated, r=<try> Remove `Nonterminal` and `TokenKind::Interpolated` A third attempt at this; the first attempt was rust-lang#96724 and the second was rust-lang#114647. r? `@ghost`
By using invisible delimiters.
r? @ghost