Skip to content

core: minor refactoring of run_utf8_validation #108217

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
wants to merge 1 commit into from
Closed

Conversation

mina86
Copy link
Contributor

@mina86 mina86 commented Feb 18, 2023

  • Use utf8_is_cont_byte instead of (byte as i8) > -64. The former
    is much more descriptive. This was the main motivation for this
    commit.
  • Use [T]::get in favour of explicit length check which is more
    concise.
  • Put ‘is continuation byte’ checking inside of a macro to reduce
    repetition.
  • Replace next! macro by macros getting by offset so that the offset
    doesn’t have to be repeated in invocation of err!.

* Use `utf8_is_cont_byte` instead of `(byte as i8) > -64`.  The former
  is **much more** descriptive.  This was the main motivation for this
  commit.
* Use `[T]::get` in favour of explicit length check which is more
  concise.
* Put ‘is continuation byte’ checking inside of a macro to reduce
  repetition.
* Replace `next!` macro by macros getting by offset so that the offset
  doesn’t have to be repeated in invocation of `err!`.
@rustbot
Copy link
Collaborator

rustbot commented Feb 18, 2023

r? @m-ou-se

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 18, 2023
@rustbot
Copy link
Collaborator

rustbot commented Feb 18, 2023

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@the8472
Copy link
Member

the8472 commented Feb 18, 2023

note that there's a bigger rewrite happening in #107760

@mina86 mina86 closed this Feb 18, 2023
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check-tidy failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Prepare all required actions
Getting action download info
Download action repository 'actions/checkout@v3' (SHA:ac593985615ec2ede58e132d2e21d2b1cbd6127c)
Download action repository 'rust-lang/simpleinfra@master' (SHA:75573f9759179a720f4c3af6c9fb518ac0061dca)
Complete job name: PR (mingw-check-tidy, true, ubuntu-20.04-xl)
git config --global core.autocrlf false
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  CI_JOB_NAME: mingw-check-tidy
---
Building wheels for collected packages: reuse
  Building wheel for reuse (pyproject.toml): started
  Building wheel for reuse (pyproject.toml): finished with status 'done'
  Created wheel for reuse: filename=reuse-1.1.0-cp310-cp310-manylinux_2_35_x86_64.whl size=180117 sha256=a2b5d39c8ff2686626c851b00c3d3ae10157feb2cc6d0d07e414234b479dbb17
  Stored in directory: /tmp/pip-ephem-wheel-cache-k4fo_dtv/wheels/c2/3c/b9/1120c2ab4bd82694f7e6f0537dc5b9a085c13e2c69a8d0c76d
Installing collected packages: boolean-py, binaryornot, setuptools, reuse, python-debian, markupsafe, license-expression, jinja2, chardet
  Attempting uninstall: setuptools
    Found existing installation: setuptools 59.6.0
    Not uninstalling setuptools at /usr/lib/python3/dist-packages, outside environment /usr
---
Successfully built b5e72b566c4f
Successfully tagged rust-ci:latest
Built container sha256:b5e72b566c4f423e6d13f90c9357ece14e73b668cd07e5155901f3616a02aac1
Uploading finished image to https://ci-caches.rust-lang.org/docker/f36b5782f7228aca51ac4b42fc8d834a0357048eedd2f8ec11ebf729b3642b4f40d12a04648dc10cace4cb151f5ecc2ac820f64f301d3380602cceb15ce3c48d
upload failed: - to s3://rust-lang-ci-sccache2/docker/f36b5782f7228aca51ac4b42fc8d834a0357048eedd2f8ec11ebf729b3642b4f40d12a04648dc10cace4cb151f5ecc2ac820f64f301d3380602cceb15ce3c48d Unable to locate credentials
[CI_JOB_NAME=mingw-check-tidy]
[CI_JOB_NAME=mingw-check-tidy]
---
   Compiling tidy v0.1.0 (/checkout/src/tools/tidy)
    Finished release [optimized] target(s) in 18.63s
fmt check
skip untracked path cpu-usage.csv during rustfmt invocations
Diff in /checkout/library/core/src/str/validations.rs at line 146:
                     Some(&byte) => byte,
                     None => err!(None),
-            }
+            };
         }
         macro_rules! check_cont_byte {
         macro_rules! check_cont_byte {
             ($off:expr) => {
Diff in /checkout/library/core/src/str/validations.rs at line 153:
                 if !utf8_is_cont_byte(get_byte!($off)) {
                     err!(Some($off as u8))
-            }
+            };
         }
 
 
         if first >= 128 {
Running `"/checkout/obj/build/x86_64-unknown-linux-gnu/rustfmt/bin/rustfmt" "--config-path" "/checkout" "--edition" "2021" "--unstable-features" "--skip-children" "--check" "/checkout/library/core/src/str/pattern.rs" "/checkout/library/core/src/str/traits.rs" "/checkout/library/core/src/str/validations.rs" "/checkout/library/core/src/str/count.rs" "/checkout/library/core/src/mem/mod.rs" "/checkout/library/core/src/ops/try_trait.rs" "/checkout/library/core/src/async_iter/async_iter.rs" "/checkout/library/core/src/ops/range.rs"` failed.
If you're running `tidy`, try again with `--bless`. Or, if you just want to format code, run `./x.py fmt` instead.

@mina86 mina86 deleted the d branch January 27, 2024 06:46
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-libs Relevant to the library 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