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

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

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 ...
    |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
4 participants