rust-lang / rust-lang/rust

Different codegen between comparison of `&str` and `&[u8]` on `And` and `Or` condition

Open
#144,279 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-optimization T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

On And condition, &[u8] can be optimized directly as false while &str can't
https://godbolt.org/z/GvWxGxj5b

On Or condition, &[u8] generates more branches/comparisons than &str
https://godbolt.org/z/EcYa99658

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two Rust examples using the linked Godbolt cases for And and Or conditions, then compare the generated code for &str and &[u8]. The issue names no repository files or tests; done means determining the intended codegen behavior and aligning the differing cases with regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.