-
Notifications
You must be signed in to change notification settings - Fork 909
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
upgrade rustc-ap-* version to v642 #4022
Conversation
syntax_pos was renamed to rustc_span rust-lang/rust#67707 and modules like `symbol` and `source_map` are no longer re-exported in libsyanx so we also need to consume them directly from the rustc_span crate rust-lang/rust#67786
several mods from libsyntax have been split out into separate crates, including the `parse` mod rust-lang/rust#65324
TraitItem/ImplItem were combined to `AssocItem`, along with their respecitve `*Kind`'s, the `Method` variant was also renamed to `Fn` in the new `AssocItemKind` rust-lang/rust#67131
`Mutability` variants were renamed to `Not` and `Mut` rust-lang/rust#67355
implicit pprust dependencies were removed and now require explicit usage rust-lang/rust#65363
AFAICT these changes are required based on the changes `LocalInternedString` and `SymbolStr` in rust-lang/rust#65776
Implements changes required post rust-lang/rust#65750
Updates to account for changes in rust-lang/rust#66271
@topecongiro - most of the tests that are failing are due to an extra semicolon being inserted on macros that have a paren or bracket delim, and I'm not sure why that's happening 🤔 impl Foo {
- add_fun!();
+ add_fun!();;
} Any suggestions on the best way to address that? I could fix most of them by removing the explicit semicolon insertion but I don't think that's the right solution. rustfmt/rustfmt-core/rustfmt-lib/src/macros.rs Lines 272 to 279 in cbebfb2
|
@calebcartwright I had a similar issue in the past, and IIRC it was due to the change to the span. In this case, it could be that in 610, the span of macro didn't contain the trailing semicolon, whereas, in 638, the span contains it. |
You are right @topecongiro, that is exactly what's happening |
86d7fb4
to
657c336
Compare
@@ -0,0 +1,2 @@ | |||
a_macro!(name<Param1, Param2>, |
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.
apparently the trailing whitespace is now actually being trimmed, so creating a test file under source
directory with the trailing whitepsace to keep the test case valid since the end formatting result in the file under target
has the whitepsace removed
|
||
// 1 = ; | ||
let shape = self.shape().saturating_sub_width(1); | ||
let rewrite = self.with_context(|ctx| rewrite_macro(mac, ident, ctx, shape, pos)); | ||
self.push_rewrite(mac.span, rewrite); | ||
let (span, rewrite) = match macro_style(mac, &self.get_context()) { |
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 to address the change in this version of the rustc-ap creates where the span no longer includes the associated ;
(#4022 (comment)). Wasn't sure what the best solution to this would be, so figured I'd try to just get the "correct" span to include the ;
when warranted, so that Mac items that have whitespace between the closing delim and the semicolon are still formatted correctly (i.e. ) ;
is still formatted to );
)
} else { | ||
rw | ||
} | ||
}); |
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 was done to fix two snippets that were failing in the tests due to the ;
being stripped. I think that was related to the same span change around missing semis so correcting it here.
The two failing snippets without this were:
rustfmt/rustfmt-core/rustfmt-lib/tests/target/macros.rs
Lines 239 to 242 in facba6a
gfx_pipeline!(pipe { | |
vbuf: gfx::VertexBuffer<Vertex> = (), | |
out: gfx::RenderTarget<ColorFormat> = "Target0", | |
}); |
and
rustfmt/rustfmt-core/rustfmt-lib/tests/target/issue-2916.rs
Lines 1 to 2 in facba6a
a_macro!(name<Param1, Param2>, | |
); |
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.
Note that on both master and rustfmt 1.x that any whitespace between the closing delim and semi is not currently removed for these two snippets, so I think this actually fixes a very minor existing issue.
For example with the below/linked snippet, the whitespace between the delim and semi remains after formatting with 1.x and master:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=649ebcbc83ba416d42392084d91ba266
gfx_pipeline!(pipe {
vbuf: gfx::VertexBuffer<Vertex> = (),
out: gfx::RenderTarget<ColorFormat> = "Target0",
}) ;
I enhanced those two test snippets to ensure that rustfmt removes that extra whitespace
657c336
to
30baa4c
Compare
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.
Thank you for the PR! Looks good to me with some minor nits addressed.
30baa4c
to
00f2a46
Compare
Rustfmt in the rustc repo just broke rust-lang/rust#68917 |
I'll work on bumping this up to a 64*.0.0 version, and hopefully @topecongiro will be available to merge. I believe I'd likely then need to backport this on top of the 1.4.11 branch though to fix the issue in the rustc repo, since this is targetting the new 2.x version of rustfmt on master which I don't believe is ready for release |
Believe we'll need an early bump of the rustc-ap-* crates to pull in the |
@calebcartwright My apologies for the late reply, I have been busy with my private life. Thank you so much for all the work! |
No worries, and my pleasure! |
Backport not needed |
I structured the changes into several smaller commits that were focused on a specific change/related set of changes in the upstream rustc crates, and included details about the upstream change in the commit messages (hope this makes it somewhat easier to review!).
I decided to focus on getting rustfmt to just "work" with the latest rustc crate versions, and defer making certain other changes (like refactoring, supporting the new half open range syntax - #4009, etc.) to future PRs. My thinking is defering those other changes will hopefully make this easier to merge since there's already a decent sized diff just from upgrading the rustc-ap versions, and I suspect this PR has a higher potential than normal for merge conflicts