-
Notifications
You must be signed in to change notification settings - Fork 12.1k
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
Print token::Interpolated
with token stream pretty printing.
#125174
base: master
Are you sure you want to change the base?
Conversation
a397a90
to
f7ce1ac
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
…, r=<try> Print `token::Interpolated` with token stream pretty printing. r? `@ghost`
ca35330
to
9c693ad
Compare
Full details are in the individual commits. @dtolnay has agreed to update the A crater run should be done before this merges, to make sure the Performance is unlikely to be affected, but let's confirm that: |
This comment has been minimized.
This comment has been minimized.
…, r=<try> Print `token::Interpolated` with token stream pretty printing. This is a step towards removing `token::Interpolated` (rust-lang#124141). It unavoidably changes the output of the `stringify!` macro, generally for the better. r? `@petrochenkov`
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
While I can see how this PR is a necessary step toward removing
This is the opposite of what I expect, and I consider
#[macro_export]
macro_rules! ensure {
($cond:expr) => {
if let false = $cond {
return Err($crate::err_msg(format!("{}", stringify!($cond))));
}
};
} Some changes picked up by https://github.com/dtolnay/anyhow's test suite from this PR: - Error::msg::<<str as ToOwned>::Owned>.t(1) == 2
+ Error ::msg ::<< str as ToOwned >::Owned >.t (1) == 2
- f::<1>() != ()
+ f ::<1 >() != ()
- f::<-1>() != ()
+ f ::<- 1 >() != ()
- E::U::<> > E::U::<u8>
+ E ::U ::<> > E ::U ::<u8 >
- E::U::<u8> > E::U
+ E ::U ::<u8 > > E ::U
- b\"hmm\"[1] == b'c'
+ b\"hmm\" [1] == b'c'
- result? == 2
+ result ? == 2
- f as for<'a> fn() as usize * 0 != 0
+ f as for<'a > fn() as usize * 0 != 0
- &0 as &dyn EqDebug<i32, Assoc = bool> != &0
+ &0 as &dyn EqDebug <i32, Assoc = bool > != &0
- PhantomData as PhantomData<<i32 as ToOwned>::Owned> != PhantomData
+ PhantomData as PhantomData << i32 as ToOwned >::Owned > != PhantomData
- 0 as int!(...) != 0
+ 0 as int !(...) != 0
- 0 as int![...] != 0
+ 0 as int ![...] != 0
- 0 as int! { ... } != 0
+ 0 as int ! { ... } != 0
- if let -1..=1 = 0 { 0 } else { 1 } == 1
+ if let -1 ..=1 = 0 { 0 } else { 1 } == 1 |
Finished benchmarking commit (e07dc21): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)Results (primary 0.2%, secondary -5.0%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary -0.3%, secondary 0.2%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 669.726s -> 668.949s (-0.12%) |
We can discuss what "more capable" means, but there are cases visible in the
How do I run that suite? I tried |
|
AFAICT this is the |
Minimal repro: macro_rules! repro {
($foo:ident $colons:tt $bar:ident) => {
stringify_expr!($foo $colons $bar)
};
}
macro_rules! stringify_expr {
($expr:expr) => {
stringify!($expr)
};
}
fn main() {
println!("{}", repro!(foo::bar));
} - foo::bar
+ foo ::bar |
@craterbot check |
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
…chenkov Tweak `Spacing` use Some clean-up precursors to rust-lang#125174. r? `@petrochenkov`
…chenkov Tweak `Spacing` use Some clean-up precursors to rust-lang#125174. r? ``@petrochenkov``
🎉 Experiment
|
Rollup merge of rust-lang#125316 - nnethercote:tweak-Spacing, r=petrochenkov Tweak `Spacing` use Some clean-up precursors to rust-lang#125174. r? ``@petrochenkov``
☔ The latest upstream changes (presumably #125436) made this pull request unmergeable. Please resolve the merge conflicts. |
michaelzoech/vkinfo: this one needs to be fixed. error: proc-macro derive panicked
--> src/vk.rs:62:14
|
62 | #[derive(Serialize)]
| ^^^^^^^^^
|
= help: message: called `Result::unwrap()` on an `Err` value: "failed to parse derive input: \"pubstruct InstanceCreateFlags { bits: u32, }\"" I skimmed a few of the rest and they all seemed like they might be the same issue. |
Here is the issue: https://github.com/bitflags/bitflags/blob/1.0.1/src/lib.rs#L312 This is something I observed in IMO a punct immediately preceding a close delimiter with no space should be treated as |
I don't think removing nonterminals is strictly required for addressing #67062. I do feel that characterizing nonterminals as "legacy" or "slated for removal" in comments is premature.
I'd expect large pieces of code like items (impls with nested functions, with large bodies with blocks) to be botched by token pretty-printing to a larger degree than expressions.
From what I remember in decl macro output we just give up and print spaces (possibly prettified by |
I've looked at the crater results. There are two things going on. SpacingWhen I first created this PR on May 16 I had a commit "Add Spacing to mbe::TokenTree::Token". This was buggy, and could cause some pairs of tokens to be concatenated, like consecutive identifiers, leading to invalid output such as But somehow that buggy commit ended up in the crater run: 3b977bb. The buggy commit doesn't show up in the PR's commits list. But that explains a lot of the failures such as So I think this cause of failures is solved, though I don't understand why the crater run included the buggy commit. rentalrustc has a "pretty_printing_compatibility_hack" that causes slightly different token-handling behaviour when compiling versions of the rust/compiler/rustc_expand/src/proc_macro.rs Lines 123 to 133 in 78dd504
The hack forces a matching item or statement to be put into an So this PR perfectly undoes the hack, because So I think the best way to fix these failures is to finally remove the hack. It has been four years since it was added. I think that's better than trying to adapt the hack to work with the tokenstream pretty printer. @petrochenkov, what do you think? |
+1 from me for removing that hack targeting 4-year-old
Crater doesn't compile rustc. It uses an already-compiled rustc that got built by bors in the most recent "bors try". In this PR there was a "bors try" in #125174 (comment). According to the bors response in #125174 (comment), the head of the PR at the time was commit 9c693ad. There was a force push from that commit to 33d6e6f right below #125174 (comment), followed by "craterbot check" in #125174 (comment). Craterbot uses the most recent try build, and says so in #125174 (comment): "🤖 Automatically detected try build e07dc21 |
Aha. Old try build, makes sense. About rental: I have commented in #106060. The discussion there indicated people are being extremely cautious about even scaling back the hack, let alone removing it. Hmm. I've made a short argument, other more eloquent arguments in favour of removal would be appreciated if people have them... |
Instead of using AST pretty printing. This is a step towards removing `token::Interpolated`, which will eventually (in rust-lang#124141) be replaced with a token stream within invisible delimiters. This changes (improves) the output of the `stringify!` macro in some cases. This is allowed. As the `stringify!` docs say: "Note that the expanded results of the input tokens may change in the future. You should be careful if you rely on the output." Test changes: - tests/ui/macros/stringify.rs: this used to test both token stream pretty printing and AST pretty printing via different ways of invoking of `stringify!` (i.e. `$expr` vs `$tt`). But those two different invocations now give the same result, which is a nice consistency improvement. This removes the need for all the `c2*` macros. The AST pretty printer now has more thorough testing thanks to rust-lang#125236. - tests/ui/proc-macro/*: minor improvements where small differences between `INPUT (DISPLAY)` output and `DEEP-RE-COLLECTED (DISPLAY)` output disappear.
33d6e6f
to
a322750
Compare
I'm also fine with removing the hack. |
We still check for the `rental`/`allsorts-rental` crates. But now if they are detected we just emit a fatal error, instead of emitting a warning and providing alternative behaviour. The original "hack" implementing alternative behaviour was added in rust-lang#73345. The lint was added in rust-lang#83127. The tracking issue is rust-lang#83125. The direct motivation for the change is that providing the alternative behaviour is interfering with rust-lang#125174 and follow-on work.
#125596 converts the hack to a hard error, which is enough to unblock this PR. |
We still check for the `rental`/`allsorts-rental` crates. But now if they are detected we just emit a fatal error, instead of emitting a warning and providing alternative behaviour. The original "hack" implementing alternative behaviour was added in rust-lang#73345. The lint was added in rust-lang#83127. The tracking issue is rust-lang#83125. The direct motivation for the change is that providing the alternative behaviour is interfering with rust-lang#125174 and follow-on work.
Convert `proc_macro_back_compat` lint to an unconditional error. We still check for the `rental`/`allsorts-rental` crates. But now if they are detected we just emit a fatal error, instead of emitting a warning and providing alternative behaviour. The original "hack" implementing alternative behaviour was added in rust-lang#73345. The lint was added in rust-lang#83127. The tracking issue is rust-lang#83125. The direct motivation for the change is that providing the alternative behaviour is interfering with rust-lang#125174 and follow-on work. r? `@estebank`
This is a step towards removing
token::Interpolated
(#124141). It unavoidably changes the output of thestringify!
macro, generally for the better.r? @petrochenkov