Skip to content

[EXPERIMENTAL] Lower constant pattern subslices into valtrees #121540

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

Closed

Conversation

jieyouxu
Copy link
Member

@jieyouxu jieyouxu commented Feb 24, 2024

🚧 This PR is experimental because this is the first time I touch MIR stuff :3

This PR attempts to revive #112370 and work towards fixing #110870.

Checklist

  • Resolve unable to compare [T; N] == [T; N] via ~const PartialEq.
  • Add before/after MIR tests to confirm this PR does indeed affect MIR build simplification in a desirable way.

@rustbot
Copy link
Collaborator

rustbot commented Feb 24, 2024

r? @michaelwoerister

rustbot has assigned @michaelwoerister.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

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

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

Click to see the possible cause of the failure (guessed by this bot)
GITHUB_ACTION=__run_7
GITHUB_ACTIONS=true
GITHUB_ACTION_REF=
GITHUB_ACTION_REPOSITORY=
GITHUB_ACTOR=jieyouxu
GITHUB_API_URL=https://api.github.com
GITHUB_BASE_REF=master
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_66aaabd0-437a-4507-9d6b-b15d0bd86dc3
GITHUB_EVENT_NAME=pull_request
---
GITHUB_SERVER_URL=https://github.com
GITHUB_SHA=7f1ded0f299fa0c9839bbb6b00c37a143699ea2b
GITHUB_STATE=/home/runner/work/_temp/_runner_file_commands/save_state_66aaabd0-437a-4507-9d6b-b15d0bd86dc3
GITHUB_STEP_SUMMARY=/home/runner/work/_temp/_runner_file_commands/step_summary_66aaabd0-437a-4507-9d6b-b15d0bd86dc3
GITHUB_TRIGGERING_ACTOR=jieyouxu
GITHUB_WORKFLOW_REF=rust-lang/rust/.github/workflows/ci.yml@refs/pull/121540/merge
GITHUB_WORKFLOW_SHA=7f1ded0f299fa0c9839bbb6b00c37a143699ea2b
GITHUB_WORKSPACE=/home/runner/work/rust/rust
GOROOT_1_19_X64=/opt/hostedtoolcache/go/1.19.13/x64
---
#12 writing image sha256:f7d6f821a0698b4d03e3ad8230fe337a05af67cbca2c7e693c7e0ca1189dd3cc done
#12 naming to docker.io/library/rust-ci done
#12 DONE 10.0s
##[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-16]
##[group]Clock drift check
  local time: Sat Feb 24 10:10:06 UTC 2024
  network time: Sat, 24 Feb 2024 10:10:07 GMT
  network time: Sat, 24 Feb 2024 10:10:07 GMT
##[endgroup]
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-16', '--enable-llvm-link-shared', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'change-id=99999999', '--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', 'build.optimized-compiler-builtins', '--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-16/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.thin-lto-import-instr-limit := 10
configure: change-id            := 99999999
---
   Compiling libc v0.2.153
   Compiling memchr v2.5.0
   Compiling std v0.0.0 (/checkout/library/std)
   Compiling compiler_builtins v0.1.108
error[E0277]: can't compare `[u8; 1]` with `[u8; 1]`
    |
    |
661 |             [10, ..] => true,
    |             ^^^^^^^^ no implementation for `[u8; 1] == [u8; 1]`
    |
    = help: the trait `~const PartialEq` is not implemented for `[u8; 1]`
    = help: the following other types implement trait `PartialEq<Rhs>`:
              <[T; N] as PartialEq<[U; N]>>
              <[T; N] as PartialEq<[U]>>
              <[T; N] as PartialEq<&[U]>>
              <[T; N] as PartialEq<&mut [U]>>
              <[T] as PartialEq<[U; N]>>
              <[T] as PartialEq<[U]>>
              <&[T] as PartialEq<[U; N]>>
              <&mut [T] as PartialEq<[U; N]>>

error[E0277]: can't compare `[u8; 2]` with `[u8; 2]`
    |
    |
663 |             [192, 168, ..] => true,
    |             ^^^^^^^^^^^^^^ no implementation for `[u8; 2] == [u8; 2]`
    |
    = help: the trait `~const PartialEq` is not implemented for `[u8; 2]`
    = help: the following other types implement trait `PartialEq<Rhs>`:
              <[T; N] as PartialEq<[U; N]>>
              <[T; N] as PartialEq<[U]>>
              <[T; N] as PartialEq<&[U]>>
              <[T; N] as PartialEq<&mut [U]>>
              <[T] as PartialEq<[U; N]>>
              <[T] as PartialEq<[U]>>
              <&[T] as PartialEq<[U; N]>>
              <&mut [T] as PartialEq<[U; N]>>

error[E0277]: can't compare `[u8; 2]` with `[u8; 2]`
    |
    |
688 |         matches!(self.octets(), [169, 254, ..])
    |                                 ^^^^^^^^^^^^^^ no implementation for `[u8; 2] == [u8; 2]`
    |
    = help: the trait `~const PartialEq` is not implemented for `[u8; 2]`
    = help: the following other types implement trait `PartialEq<Rhs>`:
              <[T; N] as PartialEq<[U; N]>>
              <[T; N] as PartialEq<[U]>>
              <[T; N] as PartialEq<&[U]>>
              <[T; N] as PartialEq<&mut [U]>>
              <[T] as PartialEq<[U; N]>>
              <[T] as PartialEq<[U]>>
              <&[T] as PartialEq<[U; N]>>
              <&mut [T] as PartialEq<[U; N]>>
For more information about this error, try `rustc --explain E0277`.
error: could not compile `core` (lib) due to 3 previous errors
Build completed unsuccessfully in 0:03:50
  local time: Sat Feb 24 10:14:33 UTC 2024

@michaelwoerister
Copy link
Member

r? mir

@jieyouxu
Copy link
Member Author

jieyouxu commented Feb 27, 2024

Going to abort this PR because:

  • It's too specialized and only handles trivial const slices, does not handle nested subslice patterns
  • It's so much easier/cleaner implementation-wise to delegate to ~const PartialEq once that is usable in libcore.

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.

5 participants