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 try_from_lit from from_anon_const #128715

Closed
wants to merge 2 commits into from
Closed

Conversation

Jaic1
Copy link
Contributor

@Jaic1 Jaic1 commented Aug 6, 2024

This PR tries to fix #116308.

TODO:

  • write up the reason why try_from_lit should be removed from from_anon_const
  • write up the reason why it is safe to do this
  • do a perf run and see if doing this affect performance

ui tests changes:

  • failed run-pass/check-pass (const-arg-in-const-arg.rs#full, abstract-const-as-cast-4.rs, no_dependence.rs, issue-94293.rs)
  • symbol mangling affected (symbol-names/*)
  • different error report (const-projection-err.rs#gce, abstract-const-as-cast-3.rs, type_mismatch.rs)
  • misc
    • error report reordering
    • same error, but different const type reprs

This PR is related to two unstable features (adt_const_params: #95174, generic_const_exprs: #76560). r? @BoxyUwU

@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 Aug 6, 2024
@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
assertion failed: progress.is_finished()
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

FAILED TEST: tests/ui/large_const_arrays.rs
command: CLIPPY_CONF_DIR="tests" RUSTC_ICE="0" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/clippy-driver" "--error-format=json" "--emit=metadata" "-Aunused" "-Ainternal_features" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Dwarnings" "-Ldependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps" "--extern=clippy_config=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_config-170d62a13831014d.rlib" "--extern=clippy_lints=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_lints-e40bab591daa40d9.rlib" "--extern=clippy_utils=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_utils-8698619764e82140.rlib" "--extern=futures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libfutures-51007212676bc4d7.rlib" "--extern=if_chain=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libif_chain-49fd91c51cbf146b.rlib" "--extern=itertools=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libitertools-5b58552e029722f2.rlib" "--extern=parking_lot=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libparking_lot-d305caadebee1c78.rlib" "--extern=quote=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libquote-c7a7b5bff16134e2.rlib" "--extern=regex=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libregex-6c9cd5e89eb65a39.rlib" "--extern=serde=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libserde-1e0d66824ae1083d.rlib" "--extern=serde_derive=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps/libserde_derive-2233436f0b800125.so" "--extern=syn=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libsyn-91b42af8abdc8b28.rlib" "--extern=tokio=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libtokio-38bf9cf4165a3cda.rlib" "-Ldependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/ui_test/tests/ui" "tests/ui/large_const_arrays.rs" "--edition" "2021"
error: actual output differed from expected
Execute `cargo uibless` to update `tests/ui/large_const_arrays.stderr` to the actual output
--- tests/ui/large_const_arrays.stderr
+++ <stderr output>
+++ <stderr output>
-error: large array defined as const
-  --> tests/ui/large_const_arrays.rs:10:1
-   |
-LL | pub(crate) const FOO_PUB_CRATE: [u32; 1_000_000] = [0u32; 1_000_000];
-   |            |
-   |            help: make this a static item: `static`
-   |
-   = note: `-D clippy::large-const-arrays` implied by `-D warnings`
-   = note: `-D clippy::large-const-arrays` implied by `-D warnings`
-   = help: to override `-D warnings` add `#[allow(clippy::large_const_arrays)]`
-
-error: large array defined as const
-  --> tests/ui/large_const_arrays.rs:11:1
-   |
-LL | pub const FOO_PUB: [u32; 1_000_000] = [0u32; 1_000_000];
-   |     |
-   |     help: make this a static item: `static`
-
-error: large array defined as const
-error: large array defined as const
-  --> tests/ui/large_const_arrays.rs:12:1
-   |
-LL | const FOO: [u32; 1_000_000] = [0u32; 1_000_000];
-   | |
-   | help: make this a static item: `static`
-
-error: large array defined as const
-error: large array defined as const
-  --> tests/ui/large_const_arrays.rs:21:5
-   |
-LL |     pub const BAR_PUB: [u32; 1_000_000] = [0u32; 1_000_000];
-   |         |
-   |         help: make this a static item: `static`
-
-error: large array defined as const
-error: large array defined as const
-  --> tests/ui/large_const_arrays.rs:22:5
-   |
-LL |     const BAR: [u32; 1_000_000] = [0u32; 1_000_000];
-   |     |
-   |     help: make this a static item: `static`
-
-error: large array defined as const
-error: large array defined as const
-  --> tests/ui/large_const_arrays.rs:23:5
-   |
-LL |     pub const BAR_STRUCT_PUB: [S; 5_000] = [S { data: [0; 32] }; 5_000];
-   |         |
-   |         help: make this a static item: `static`
-
-error: large array defined as const
-error: large array defined as const
-  --> tests/ui/large_const_arrays.rs:24:5
-   |
-LL |     const BAR_STRUCT: [S; 5_000] = [S { data: [0; 32] }; 5_000];
-   |     |
-   |     help: make this a static item: `static`
-
-error: large array defined as const
-error: large array defined as const
-  --> tests/ui/large_const_arrays.rs:25:5
-   |
-LL |     pub const BAR_S_PUB: [Option<&str>; 200_000] = [Some("str"); 200_000];
-   |         |
-   |         help: make this a static item: `static`
-
-error: large array defined as const
-error: large array defined as const
-  --> tests/ui/large_const_arrays.rs:26:5
-   |
-LL |     const BAR_S: [Option<&str>; 200_000] = [Some("str"); 200_000];
-   |     |
-   |     help: make this a static item: `static`
-
-error: aborting due to 9 previous errors
-error: aborting due to 9 previous errors
-



FAILED TEST: tests/ui/no_effect_return.rs
command: CLIPPY_CONF_DIR="tests" RUSTC_ICE="0" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/clippy-driver" "--error-format=json" "--emit=metadata" "-Aunused" "-Ainternal_features" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Dwarnings" "-Ldependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps" "--extern=clippy_config=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_config-170d62a13831014d.rlib" "--extern=clippy_lints=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_lints-e40bab591daa40d9.rlib" "--extern=clippy_utils=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_utils-8698619764e82140.rlib" "--extern=futures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libfutures-51007212676bc4d7.rlib" "--extern=if_chain=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libif_chain-49fd91c51cbf146b.rlib" "--extern=itertools=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libitertools-5b58552e029722f2.rlib" "--extern=parking_lot=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libparking_lot-d305caadebee1c78.rlib" "--extern=quote=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libquote-c7a7b5bff16134e2.rlib" "--extern=regex=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libregex-6c9cd5e89eb65a39.rlib" "--extern=serde=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libserde-1e0d66824ae1083d.rlib" "--extern=serde_derive=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps/libserde_derive-2233436f0b800125.so" "--extern=syn=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libsyn-91b42af8abdc8b28.rlib" "--extern=tokio=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libtokio-38bf9cf4165a3cda.rlib" "-Ldependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps" "--crate-type=lib" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/ui_test/tests/ui" "tests/ui/no_effect_return.rs" "--edition" "2021"
error: actual output differed from expected
error: actual output differed from expected
Execute `cargo uibless` to update `tests/ui/no_effect_return.stderr` to the actual output
--- tests/ui/no_effect_return.stderr
 error: statement with no effect
   --> tests/ui/no_effect_return.rs:9:9
... 39 lines skipped ...
    |

@BoxyUwU
Copy link
Member

BoxyUwU commented Aug 9, 2024

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 9, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 9, 2024
Remove `try_from_lit` from `from_anon_const`

This PR tries to fix rust-lang#116308.

TODO:
- [ ] write up the reason why `try_from_lit` should be removed from `from_anon_const`
- [ ] write up the reason why it is safe to do this
- [ ] do a perf run and see if doing this affect performance

ui tests changes:
- [ ] failed run-pass/check-pass (`const-arg-in-const-arg.rs#full`, `abstract-const-as-cast-4.rs`, `no_dependence.rs`, `issue-94293.rs`)
- [ ] symbol mangling affected (`symbol-names/*`)
- [ ] different error report (`const-projection-err.rs#gce`, `abstract-const-as-cast-3.rs`, `type_mismatch.rs`)
- [x] misc
    - error report reordering
    - same error, but different const type reprs

This PR is related to two unstable features (`adt_const_params`: rust-lang#95174, `generic_const_exprs`: rust-lang#76560). r? `@BoxyUwU`
@bors
Copy link
Contributor

bors commented Aug 9, 2024

⌛ Trying commit 4692924 with merge e852e36...

@bors
Copy link
Contributor

bors commented Aug 9, 2024

☀️ Try build successful - checks-actions
Build commit: e852e36 (e852e367af4e93ff05d389c0da51bbbf44c89f2c)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e852e36): comparison URL.

Overall result: ❌ regressions - ACTION NEEDED

Benchmarking 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 @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
138.8% [0.2%, 1041.2%] 101
Regressions ❌
(secondary)
2.1% [0.2%, 17.0%] 53
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 138.8% [0.2%, 1041.2%] 101

Max RSS (memory usage)

Results (primary 264.6%, secondary 0.9%)

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.

mean range count
Regressions ❌
(primary)
335.7% [1.4%, 609.9%] 30
Regressions ❌
(secondary)
1.9% [1.3%, 2.6%] 8
Improvements ✅
(primary)
-2.1% [-2.8%, -0.4%] 8
Improvements ✅
(secondary)
-3.0% [-3.8%, -2.1%] 2
All ❌✅ (primary) 264.6% [-2.8%, 609.9%] 38

Cycles

Results (primary 470.4%, secondary 13.8%)

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.

mean range count
Regressions ❌
(primary)
470.4% [1.5%, 1502.6%] 37
Regressions ❌
(secondary)
13.8% [2.9%, 17.5%] 7
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 470.4% [1.5%, 1502.6%] 37

Binary size

Results (primary -0.1%, secondary -0.6%)

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.

mean range count
Regressions ❌
(primary)
0.0% [0.0%, 0.0%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.2% [-0.3%, -0.0%] 24
Improvements ✅
(secondary)
-0.6% [-0.6%, -0.6%] 6
All ❌✅ (primary) -0.1% [-0.3%, 0.0%] 27

Bootstrap: 759.636s -> 762.742s (0.41%)
Artifact size: 337.10 MiB -> 336.44 MiB (-0.19%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Aug 9, 2024
@Jaic1
Copy link
Contributor Author

Jaic1 commented Aug 12, 2024

Closed due to dramatic performance lost.

We could next try remove the delayed bug inside try_from_lit here and return None instead.

@Jaic1 Jaic1 closed this Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ice: Const::from_anon_const: couldn't lit_to_const TypeError
6 participants