Skip to content
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 P<> from visit_s in ast MutVisitor #132112

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

maxcabrajac
Copy link
Contributor

@maxcabrajac maxcabrajac commented Oct 24, 2024

On #128974, one divergence I found between versions of the trait were P<> wrappers on some types on the mutable one.
Some are really easy to remove, while others are not.
This PR tries to remove them.

r? @petrochenkov

related to #128974

@rustbot
Copy link
Collaborator

rustbot commented Oct 24, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @petrochenkov (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 24, 2024
@maxcabrajac maxcabrajac marked this pull request as draft October 24, 2024 16:47
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 24, 2024
@petrochenkov
Copy link
Contributor

(The PR was marked as a draft, so I assumed you want to try removing the rest of P<>s.)

@maxcabrajac
Copy link
Contributor Author

Yup, that was the idea... But I'm starting to think this might not be a good one. From the Vistor's perspective it surely is, but when I looked at how rustc_expand heavily uses substitution on this P<>s it seems not to be great to remove them.

I'll look deeper into it on the weekend and keep you up to date!

If I end up finding a way to remove them from the visits then its best that we do another perf test.

@rust-log-analyzer

This comment has been minimized.

@maxcabrajac
Copy link
Contributor Author

For now, I removed P<>s from all visits, but this just pushed the problem into rustc_expand. What I see as the problem now is calling .into_inner() on the P<>s we get from .make_*() methods. A better approach is to change them to return T instead of P<T>. This would possibly remove some memory allocations, which I see as a good thing!

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Oct 27, 2024

☔ The latest upstream changes (presumably #131284) made this pull request unmergeable. Please resolve the merge conflicts.

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-18 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
------
 > importing cache manifest from ghcr.io/rust-lang/rust-ci-cache:c32c805632780b5c1de330e3f44561b336c2efe163bc0990acb392390157a8e1d9f855d75914a239aa40c49d77f4a837247d05d2f8d46f554b98e1f46712a3e3:
------
##[endgroup]
Setting extra environment values for docker:  --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-18]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure: 
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-18', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-18/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
---- [ui] tests/ui-fulldeps/pprust-expr-roundtrip.rs stdout ----

error: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui-fulldeps/pprust-expr-roundtrip.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(FALSE)" "-O" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui-fulldeps/pprust-expr-roundtrip/a" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
--- stderr -------------------------------
error[E0053]: method `visit_expr` has an incompatible type for trait
##[error]  --> /checkout/tests/ui-fulldeps/pprust-expr-roundtrip.rs:201:33
   |
   |
LL |     fn visit_expr(&mut self, e: &mut P<Expr>) {
   |                                 ^^^^^^^^^^^^ expected `rustc_ast::Expr`, found `P<rustc_ast::Expr>`
   |
   = note: expected signature `fn(&mut RemoveParens, &mut rustc_ast::Expr)`
              found signature `fn(&mut RemoveParens, &mut P<rustc_ast::Expr>)`
   |
   |
LL |     fn visit_expr(&mut self, e: &mut rustc_ast::Expr) {

error[E0053]: method `visit_expr` has an incompatible type for trait
##[error]  --> /checkout/tests/ui-fulldeps/pprust-expr-roundtrip.rs:214:33
   |
   |
LL |     fn visit_expr(&mut self, e: &mut P<Expr>) {
   |                                 ^^^^^^^^^^^^ expected `rustc_ast::Expr`, found `P<rustc_ast::Expr>`
   |
   = note: expected signature `fn(&mut AddParens, &mut rustc_ast::Expr)`
              found signature `fn(&mut AddParens, &mut P<rustc_ast::Expr>)`
   |
   |
LL |     fn visit_expr(&mut self, e: &mut rustc_ast::Expr) {

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0053`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants