-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Compiletest: add proc-macro header #133540
Conversation
This adds a proc-macro header to make it easier to depend on a proc-macro, and remove some of the boilerplate necessary.
Some changes occurred in src/tools/compiletest cc @jieyouxu |
6785c76
to
ea41925
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.
Thanks. I'm very much in favor of reducing proc-macro boilerplate but changing the default edition for proc-macro tests as far as I can tell regresses our test coverage -- this is the one thing I'm not sure about. i.e.
This allows the
force-host
,no-prefer-dynamic
headers, andcrate_type
attribute to be removed. Additionally it uses--extern
likeaux_crate
(allows implicitextern crate
in 2018) and--extern proc_macro
(to place in the prelude in 2018).
This is great, thank you for the effort!
This also includes a secondary change which defaults the edition of proc-macros to 2024. This further reduces boilerplate (removing
extern crate proc_macro;
), and allows using modern Rust syntax. I was a little on the fence including this. I personally prefer it, but I can imagine it might be confusing to others.
This, however, I hesistant about. This means that test writers by default won't remember to cover older editions.
Very cool regardless.
This comment was marked as outdated.
This comment was marked as outdated.
ea41925
to
f94142b
Compare
The compiletest change LGTM, I'll review the test diff tmrw. |
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 manually looked through the tests, and AFAICT the transformations are correct.
@bors p=1 (conflict-prone) |
Actually I'll update the dev-guide docs. |
Something else came to my mind, actually: if we support transitive builds, i.e. auxiliary can itself declare auxiliaries, technically we can have a cycle... right? What happens then? Does compiletest explode? i.e. if aux A -> aux B but aux B -> aux A... Do we just, infinitely try to compile each other until we run out of disk space? Whereas the previous scheme disallows auxiliaries from declaring auxiliaries themselves AFAIK, which is also what |
@bors r- (one question) |
I agree that properly supporting transitive builds is something that would be desirable, but that might require proper cycle detection. |
That's nothing new, is it? This PR isn't changing that. Transitive builds have always been supported with aux-build and aux-crate, and compiletest has always had a stack overflow if it has a cycle. |
Hm, I think you're right, I might be misremembering as in @bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (a2545fd): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (secondary -3.3%)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 -2.5%, secondary 2.3%)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: 792.194s -> 791.904s (-0.04%) |
This adds a
proc-macro
header to simplify using proc-macros, and to reduce boilerplate. This header works similar to theaux-build
header where you pass a path for a proc-macro to be built.This allows the
force-host
,no-prefer-dynamic
headers, andcrate_type
attribute to be removed. Additionally it uses--extern
likeaux_crate
(allows implicitextern crate
in 2018) and--extern proc_macro
(to place in the prelude in 2018).This also includes a secondary change which defaults the edition of proc-macros to 2024. This further reduces boilerplate (removingEDIT: Removedextern crate proc_macro;
), and allows using modern Rust syntax. I was a little on the fence including this. I personally prefer it, but I can imagine it might be confusing to others.Some tests were changed so that when there is a chain of dependencies A→B→C, that the
@ proc-macro
is placed inB
instead ofA
so that the--extern
flag works correctly (previously it depended on-L
to findC
). I think this is better to make the dependencies more explicit. None of these tests looked like the were actually testing this behavior.There is one test that had an unexplained output change:
tests/ui/macros/same-sequence-span.rs
. I do not know why it changed, but it didn't look like it was particularly important. Perhaps there was a normalization issue?This is currently not compatible with the rustdoc
build-aux-docs
header. It can probably be fixed, I'm just not feeling motivated to do that right now.Implementation steps
//@ proc-macro
aux build directive docs rustc-dev-guide#2149