From 116ec57dddb720ba6474ca5abea6887831936380 Mon Sep 17 00:00:00 2001 From: Jakub Panek Date: Fri, 16 Aug 2024 09:33:44 +0200 Subject: [PATCH] Update taplo to use workspace dependencies (#598) --- .dockerignore | 4 + .github/workflows/ci.yaml | 96 +++-- .github/workflows/releases.yaml | 144 ++----- .github/workflows/site.yaml | 10 +- Cargo.lock | 395 +++++++++--------- Cargo.toml | 49 ++- crates/lsp-async-stub/Cargo.toml | 48 +-- crates/lsp-async-stub/src/lib.rs | 2 +- crates/taplo-cli/Cargo.toml | 102 ++--- crates/taplo-cli/bin/taplo.rs | 2 +- crates/taplo-cli/src/args.rs | 10 +- crates/taplo-cli/src/commands/format.rs | 2 +- crates/taplo-cli/src/commands/lsp.rs | 5 +- crates/taplo-common/Cargo.toml | 94 ++--- crates/taplo-common/src/lib.rs | 1 + .../taplo-common/src/schema/associations.rs | 19 +- crates/taplo-common/src/schema/cache.rs | 4 +- crates/taplo-common/src/schema/mod.rs | 24 +- crates/taplo-common/src/util.rs | 9 +- crates/taplo-lsp/Cargo.toml | 66 +-- crates/taplo-lsp/src/diagnostics.rs | 42 +- crates/taplo-lsp/src/handlers/completion.rs | 30 +- .../src/handlers/document_symbols.rs | 2 +- crates/taplo-lsp/src/handlers/hover.rs | 21 +- crates/taplo-lsp/src/handlers/rename.rs | 18 +- crates/taplo-lsp/src/handlers/schema.rs | 5 +- crates/taplo-lsp/src/handlers/workspaces.rs | 2 +- crates/taplo-lsp/src/query.rs | 82 ++-- crates/taplo-lsp/src/world.rs | 5 +- crates/taplo-wasm/.cargo/config.toml | 2 + crates/taplo-wasm/Cargo.lock | 353 ++++++++++------ crates/taplo-wasm/Cargo.toml | 56 +-- crates/taplo-wasm/src/environment.rs | 13 +- crates/taplo-wasm/src/lib.rs | 14 +- crates/taplo-wasm/src/lsp.rs | 4 +- crates/taplo/Cargo.toml | 71 ++-- crates/taplo/src/dom/mod.rs | 2 +- crates/taplo/src/dom/node.rs | 6 +- crates/taplo/src/dom/serde.rs | 2 +- crates/taplo/src/formatter/mod.rs | 8 +- docker-bake.hcl | 78 ++++ docker/alpine/Dockerfile | 105 +++++ docker/cli-alpine.Dockerfile | 15 - docker/cli-full-alpine.Dockerfile | 15 - site/site/cli/installation/binary.md | 20 +- taplo.toml | 19 +- test-data/example.toml | 6 +- test-data/rewrite/nothing.toml | 6 +- test-data/rewrite/nothing_expected.toml | 6 +- util/test-gen/Cargo.toml | 14 +- 50 files changed, 1145 insertions(+), 963 deletions(-) create mode 100644 crates/taplo-wasm/.cargo/config.toml create mode 100644 docker-bake.hcl create mode 100644 docker/alpine/Dockerfile delete mode 100644 docker/cli-alpine.Dockerfile delete mode 100644 docker/cli-full-alpine.Dockerfile diff --git a/.dockerignore b/.dockerignore index eb5a316cb..5a815607e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,5 @@ target +docker +.github +.vscode +.lapce diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index aa401823d..833a37736 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -36,32 +36,23 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: Swatinem/rust-cache@v1 - - uses: actions-rs/cargo@v1 - name: Test Taplo - with: - command: test - args: -p taplo + - name: Install latest Rust toolchain + run: rustup update --no-self-update + - uses: Swatinem/rust-cache@v2 + - name: Test Taplo + run: | + cargo test -p taplo check_wasm32: name: Check on WASM runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - target: wasm32-unknown-unknown - toolchain: stable - override: true - - uses: Swatinem/rust-cache@v1 + - name: Install latest Rust toolchain + run: | + rustup update --no-self-update + rustup target add wasm32-unknown-unknown + - uses: Swatinem/rust-cache@v2 - working-directory: crates/taplo-wasm run: cargo check --target wasm32-unknown-unknown @@ -70,22 +61,63 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: Swatinem/rust-cache@v1 + - name: Install latest Rust toolchain + run: | + rustup update --no-self-update + - uses: Swatinem/rust-cache@v2 - name: Retrieve toml-test run: | wget https://github.com/BurntSushi/toml-test/releases/download/v1.1.0/toml-test-v1.1.0-linux-amd64.gz gunzip toml-test-v1.1.0-linux-amd64.gz chmod +x toml-test-v1.1.0-linux-amd64 - - uses: actions-rs/cargo@v1 - name: Build taplo-cli - with: - command: build - args: --bin taplo --no-default-features --features "rustls-tls,toml-test" + - name: Build taplo-cli + run: | + cargo build --bin taplo --no-default-features --features "rustls-tls,toml-test" - name: Run toml-test run: ./toml-test-v1.1.0-linux-amd64 ./target/debug/taplo -- toml-test + + test-msrv-lib: + name: Test libraries with MSRV + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install latest Rust toolchain + run: | + rustup update --no-self-update + rustup default 1.70 + - uses: Swatinem/rust-cache@v2 + - name: Test MSRV for taplo + run: | + cargo check -p lsp-async-stub -p taplo-common -p taplo-lsp -p taplo + cargo test -p lsp-async-stub -p taplo-common -p taplo-lsp -p taplo + + test-msrv-bin: + name: Test binaries with MSRV + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install latest Rust toolchain + run: | + rustup update --no-self-update + rustup default 1.70 + - uses: Swatinem/rust-cache@v2 + - name: Test taplo-cli + run: | + cargo check -p taplo-cli + cargo test -p taplo-cli + + test-msrv-wasm: + name: Test WASM with MSRV + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install latest Rust toolchain + run: | + rustup update --no-self-update + rustup default 1.74 + rustup target install wasm32-unknown-unknown + - uses: Swatinem/rust-cache@v2 + - name: Test taplo-wasm + working-directory: crates/taplo-wasm + run: | + cargo check diff --git a/.github/workflows/releases.yaml b/.github/workflows/releases.yaml index 3fefeb663..1fc2b5ac8 100644 --- a/.github/workflows/releases.yaml +++ b/.github/workflows/releases.yaml @@ -263,38 +263,6 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - cli_docker: - runs-on: ubuntu-latest - needs: ["wait_for_ci", "get_version"] - if: startsWith(github.ref, 'refs/tags/release-taplo-cli-0') || contains(fromJSON('["workflow_dispatch", "pull_request"]'), github.event_name) - strategy: - matrix: - image: - - file: docker/cli-alpine.Dockerfile - tags: tamasfe/taplo:latest,tamasfe/taplo:${{ needs.get_version.outputs.cli || 'dev' }},tamasfe/taplo:${{ needs.get_version.outputs.cli || 'dev' }}-alpine - - file: docker/cli-full-alpine.Dockerfile - tags: tamasfe/taplo:full,tamasfe/taplo:${{ needs.get_version.outputs.cli || 'dev' }}-full,tamasfe/taplo:${{ needs.get_version.outputs.cli || 'dev' }}-full-alpine - steps: - - uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Login to DockerHub - uses: docker/login-action@v2 - if: ${{ github.event_name == 'push' }} - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and push - uses: docker/build-push-action@v3 - with: - file: ${{ matrix.image.file }} - context: . - platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name == 'push' }} - tags: ${{ matrix.image.tags }} - build_cli_windows: name: ${{ matrix.triple }} runs-on: windows-latest @@ -320,16 +288,11 @@ jobs: - name: Build taplo run: | cargo build --verbose --release --bin taplo --target ${{ matrix.triple }} - Compress-Archive -Path ./target/${{ matrix.triple }}/release/taplo.exe -DestinationPath ./taplo-windows-${{ matrix.platform }}.zip - - - name: Build taplo-full - run: | - cargo build --verbose --release --bin taplo --target ${{ matrix.triple }} --features toml-test,lsp # zip - Compress-Archive -Path ./target/${{ matrix.triple }}/release/taplo.exe -DestinationPath ./taplo-full-windows-${{ matrix.platform }}.zip + Compress-Archive -Path ./target/${{ matrix.triple }}/release/taplo.exe -DestinationPath ./taplo-windows-${{ matrix.platform }}.zip # gzip $file = [System.IO.File]::Open('.\target\${{ matrix.triple }}\release\taplo.exe', [System.IO.FileMode]::Open) - $archive = [System.IO.File]::Create('.\taplo-full-windows-${{ matrix.platform }}.gz') + $archive = [System.IO.File]::Create('.\taplo-windows-${{ matrix.platform }}.gz') $compressor = [System.IO.Compression.GZipStream]::new($archive, [System.IO.Compression.CompressionMode]::Compress) $file.CopyTo($compressor) $compressor.Close() @@ -343,83 +306,44 @@ jobs: retention-days: 1 build_cli_linux_musl: - name: ${{ matrix.triple }} + name: Build linux executables runs-on: ubuntu-latest - needs: ["wait_for_ci"] + needs: ["wait_for_ci", "get_version"] if: startsWith(github.ref, 'refs/tags/release-taplo-cli-0') || contains(fromJSON('["workflow_dispatch", "pull_request"]'), github.event_name) - env: - CROSS_SYSROOT: /mnt/alpine-${{ matrix.platform }} - PACKAGES: > - zlib-static freetype-static fontconfig-static - libgit2-static libssh2-static openssl-libs-static - libssl3 gtk+3.0-dev http-parser-dev curl - build-base openssl-dev git lld clang - strategy: - fail-fast: false - matrix: - include: - - triple: i686-unknown-linux-musl - platform: x86 - - triple: x86_64-unknown-linux-musl - platform: x86_64 - - triple: aarch64-unknown-linux-musl - platform: aarch64 steps: - uses: actions/checkout@v4 - - - name: Set up Alpine Linux for ${{ matrix.platform }} (target arch) - id: alpine-target - uses: jirutka/setup-alpine@v1 - with: - arch: ${{ matrix.platform }} - branch: edge - packages: ${{ env.PACKAGES }} - shell-name: alpine-target.sh - - - name: Set up Alpine Linux for x86_64 (build arch) - uses: jirutka/setup-alpine@v1 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + run: | + docker buildx create --driver=docker-container --use + - name: Login to DockerHub + uses: docker/login-action@v2 + if: ${{ github.event_name == 'push' }} with: - arch: x86_64 - packages: ${{ env.PACKAGES }} - volumes: ${{ steps.alpine-target.outputs.root-path }}:${{ env.CROSS_SYSROOT }} - shell-name: alpine.sh - - # rustup-init is not available for x86 - - run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --target ${{ matrix.triple }} --default-toolchain stable --profile minimal -y - shell: alpine.sh {0} - - - name: Build ${{ matrix.triple }} - shell: alpine.sh {0} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Build env: - LIBZ_SYS_STATIC: 1 - LIBSSH2_STATIC: 1 - LIBGIT2_STATIC: 1 - OPENSSL_STATIC: 1 - OPENSSL_DIR: ${{ env.CROSS_SYSROOT }}/usr # static/dynamic lib workaround <3 - OPENSSL_NO_VENDOR: 1 # don't even try to build without it on musl - PKG_CONFIG_ALL_STATIC: 1 - PKG_CONFIG_LIBDIR: ${{ env.CROSS_SYSROOT }}/usr/lib/pkgconfig - RUSTFLAGS: -C target-feature=+crt-static -C linker=/usr/bin/ld.lld # link runtime static, use universal linker - CARGO_BUILD_TARGET: ${{ matrix.triple }} - SYSROOT: /dummy # workaround for https://github.com/rust-lang/pkg-config-rs/issues/102 - CC: clang + RELEASE_TAG: ${{ needs.get_version.outputs.cli || 'dev' }} + PUSH: ${{ github.event_name == 'push' }} run: | - # Workaround for https://github.com/rust-lang/pkg-config-rs/issues/102 - echo -e '#!/bin/sh\nPKG_CONFIG_SYSROOT_DIR=${{ env.CROSS_SYSROOT }} exec pkgconf "$@"' \ - | install -m755 /dev/stdin pkg-config - export PKG_CONFIG="$(pwd)/pkg-config" - - cargo build --verbose --release --bin taplo - gzip -c ./target/${{ matrix.triple }}/release/taplo > ./taplo-linux-${{ matrix.platform }}.gz - - cargo build --verbose --release --bin taplo --features toml-test,lsp - gzip -c ./target/${{ matrix.triple }}/release/taplo > ./taplo-full-linux-${{ matrix.platform }}.gz - + docker buildx bake + - name: Rename + run: | + cd ./target/alpine + mv ./linux_386/taplo ./linux_386/taplo-x86 + mv ./linux_amd64/taplo ./linux_amd64/taplo-x86_64 + mv ./linux_arm64/taplo ./linux_amd64/taplo-aarch64 + mv ./linux_arm_v7/taplo ./linux_arm_v7/taplo-armv7 + - name: Gzip files + run: | + gzip ./target/alpine/linux_*/taplo* - uses: actions/upload-artifact@v4 with: - name: taplo-linux-${{ matrix.platform }} + name: taplo-linux path: | - ./taplo-*.gz + ./target/alpine/linux_*/taplo*.gz retention-days: 1 build_cli_macos: @@ -446,11 +370,6 @@ jobs: cargo build --verbose --release --bins --target ${{ matrix.triple }} gzip -c ./target/${{ matrix.triple }}/release/taplo > ./taplo-darwin-${{ matrix.platform }}.gz - - name: Build taplo-full - run: | - cargo build --verbose --release --bins --target ${{ matrix.triple }} --features toml-test,lsp - gzip -c ./target/${{ matrix.triple }}/release/taplo > ./taplo-full-darwin-${{ matrix.platform }}.gz - - uses: actions/upload-artifact@v4 with: name: taplo-macos-${{ matrix.platform }} @@ -484,7 +403,8 @@ jobs: steps: - uses: actions/checkout@v4 - name: Install latest Rust toolchain - run: rustup update --no-self-update + run: | + rustup update --no-self-update - uses: Swatinem/rust-cache@v2 - name: Install Node.js uses: actions/setup-node@v4 diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml index 101f9aae4..011fdd3a6 100644 --- a/.github/workflows/site.yaml +++ b/.github/workflows/site.yaml @@ -15,12 +15,10 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true + - name: Install latest Rust toolchain + run: | + rustup update --no-self-update + rustup target add wasm32-unknown-unknown - name: Setup Node uses: actions/setup-node@v4 with: diff --git a/Cargo.lock b/Cargo.lock index 97c2b8d3a..410709f6b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,20 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" -dependencies = [ - "getrandom", - "once_cell", - "version_check", -] - -[[package]] -name = "ahash" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42cd52102d3df161c77a887b608d7a4897d7cc112886a9537b738a887a03aaff" +checksum = "d713b3834d76b85304d4d525563c1276e2e30dc97cc67bfb4585a4a29fc2c89f" dependencies = [ "cfg-if", "getrandom", @@ -51,6 +40,18 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" + +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + [[package]] name = "ansi_term" version = "0.12.1" @@ -60,6 +61,55 @@ dependencies = [ "winapi", ] +[[package]] +name = "anstream" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" + +[[package]] +name = "anstyle-parse" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "anyhow" version = "1.0.79" @@ -268,54 +318,71 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "clap" -version = "2.34.0" +name = "ciborium" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" dependencies = [ - "bitflags 1.3.2", - "textwrap 0.11.0", - "unicode-width", + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" + +[[package]] +name = "ciborium-ll" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" +dependencies = [ + "ciborium-io", + "half", ] [[package]] name = "clap" -version = "3.2.25" +version = "4.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" +checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" dependencies = [ - "atty", - "bitflags 1.3.2", + "clap_builder", "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" +dependencies = [ + "anstream", + "anstyle", "clap_lex", - "indexmap 1.9.3", - "once_cell", "strsim", - "termcolor", - "textwrap 0.16.0", ] [[package]] name = "clap_derive" -version = "3.2.25" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae6371b8bdc8b7d3959e9cf7b22d4435ef3e79e138688421ec654acf8c81b008" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck", - "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.48", ] [[package]] name = "clap_lex" -version = "0.2.4" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" -dependencies = [ - "os_str_bytes", -] +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "codespan-reporting" @@ -327,6 +394,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "colorchoice" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" + [[package]] name = "core-foundation" version = "0.9.4" @@ -351,9 +424,9 @@ checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636" [[package]] name = "cpp_demangle" -version = "0.3.5" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" +checksum = "7e8227005286ec39567949b33df9896bcadfa6051bccca2488129f108ca23119" dependencies = [ "cfg-if", ] @@ -369,24 +442,24 @@ dependencies = [ [[package]] name = "criterion" -version = "0.3.6" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b01d6de93b2b6c65e17c634a26653a29d107b3c98c607c765bf38d041531cd8f" +checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" dependencies = [ - "atty", + "anes", "cast", - "clap 2.34.0", + "ciborium", + "clap", "criterion-plot", - "csv", + "is-terminal", "itertools", - "lazy_static", "num-traits", + "once_cell", "oorandom", "plotters", "rayon", "regex", "serde", - "serde_cbor", "serde_derive", "serde_json", "tinytemplate", @@ -395,9 +468,9 @@ dependencies = [ [[package]] name = "criterion-plot" -version = "0.4.5" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2673cc8207403546f45f5fd319a974b1e6983ad1a3ee7e6041650013be041876" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" dependencies = [ "cast", "itertools", @@ -428,6 +501,12 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "crypto-common" version = "0.1.6" @@ -438,27 +517,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "csv" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac574ff4d437a7b5ad237ef331c17ccca63c46479e5b5453eb8e10bb99a759fe" -dependencies = [ - "csv-core", - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "csv-core" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5efa2b3d7902f4b634a20cae3c9c4e6209dc4779feb6863329607560143efa70" -dependencies = [ - "memchr", -] - [[package]] name = "ctrlc" version = "3.4.2" @@ -471,11 +529,11 @@ dependencies = [ [[package]] name = "debugid" -version = "0.7.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6ee87af31d84ef885378aebca32be3d682b0e0dc119d5b4860a2c5bb5046730" +checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d" dependencies = [ - "uuid 0.8.2", + "uuid", ] [[package]] @@ -518,9 +576,9 @@ checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] @@ -761,9 +819,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.24" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", @@ -771,7 +829,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 2.2.3", + "indexmap", "slab", "tokio", "tokio-util", @@ -780,17 +838,12 @@ dependencies = [ [[package]] name = "half" -version = "1.8.2" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" dependencies = [ - "ahash 0.7.8", + "cfg-if", + "crunchy", ] [[package]] @@ -798,6 +851,10 @@ name = "hashbrown" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +dependencies = [ + "ahash", + "allocator-api2", +] [[package]] name = "heck" @@ -828,9 +885,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "http" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ "bytes", "fnv", @@ -862,9 +919,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.28" +version = "0.14.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" dependencies = [ "bytes", "futures-channel", @@ -921,18 +978,6 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "rayon", - "serde", -] - [[package]] name = "indexmap" version = "2.2.3" @@ -940,7 +985,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown", + "rayon", + "serde", ] [[package]] @@ -949,8 +996,8 @@ version = "0.11.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "321f0f839cd44a4686e9504b0a62b4d69a50b62072144c71c68f5873c167b8d9" dependencies = [ - "ahash 0.8.8", - "indexmap 2.2.3", + "ahash", + "indexmap", "is-terminal", "itoa", "log", @@ -978,6 +1025,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + [[package]] name = "iso8601" version = "0.6.1" @@ -1026,7 +1079,7 @@ version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a071f4f7efc9a9118dfb627a0a94ef247986e1ab8606a4c806ae2b3aa3b6978" dependencies = [ - "ahash 0.8.8", + "ahash", "anyhow", "base64", "bytecount", @@ -1045,7 +1098,7 @@ dependencies = [ "serde_json", "time", "url", - "uuid 1.7.0", + "uuid", ] [[package]] @@ -1107,16 +1160,16 @@ dependencies = [ [[package]] name = "lru" -version = "0.7.8" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999beba7b6e8345721bd280141ed958096a2e4abdf74f67ff4ce49b4b54e47a" +checksum = "a4a83fb7698b3643a0e34f9ae6f2e8f0178c0fd42f8b59d493aa271ff3a5bf21" dependencies = [ - "hashbrown 0.12.3", + "hashbrown", ] [[package]] name = "lsp-async-stub" -version = "0.6.3" +version = "0.6.4" dependencies = [ "anyhow", "async-trait", @@ -1160,9 +1213,9 @@ checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "memmap2" -version = "0.5.10" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" +checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" dependencies = [ "libc", ] @@ -1228,9 +1281,9 @@ dependencies = [ [[package]] name = "nix" -version = "0.24.3" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" dependencies = [ "bitflags 1.3.2", "cfg-if", @@ -1440,12 +1493,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "os_str_bytes" -version = "6.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" - [[package]] name = "overload" version = "0.1.1" @@ -1544,9 +1591,9 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "pprof" -version = "0.9.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a97149c0eacaa6b8f8cedea99f68bb3a0517fa20f8de8d8c24c1a810f38d235d" +checksum = "ef5c97c51bd34c7e742402e216abdeb44d415fbe6ae41d56b114723e953711cb" dependencies = [ "backtrace", "cfg-if", @@ -1555,7 +1602,7 @@ dependencies = [ "inferno", "libc", "log", - "nix 0.24.3", + "nix 0.26.4", "once_cell", "parking_lot", "smallvec", @@ -1574,30 +1621,6 @@ dependencies = [ "pad", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" version = "1.0.78" @@ -1700,9 +1723,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.11.24" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ "base64", "bytes", @@ -1772,7 +1795,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a58fa8a7ccff2aec4f39cc45bf5f985cec7125ab271cf681c279fd00192b49" dependencies = [ "countme", - "hashbrown 0.14.3", + "hashbrown", "memoffset", "rustc-hash", "text-size", @@ -1805,9 +1828,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.10" +version = "0.21.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring", @@ -1940,16 +1963,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde_cbor" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" -dependencies = [ - "half", - "serde", -] - [[package]] name = "serde_derive" version = "1.0.196" @@ -1978,7 +1991,7 @@ version = "1.0.113" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" dependencies = [ - "indexmap 2.2.3", + "indexmap", "itoa", "ryu", "serde", @@ -2087,21 +2100,21 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "symbolic-common" -version = "8.8.0" +version = "12.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f551f902d5642e58039aee6a9021a61037926af96e071816361644983966f540" +checksum = "16629323a4ec5268ad23a575110a724ad4544aae623451de600c747bf87b36cf" dependencies = [ "debugid", "memmap2", "stable_deref_trait", - "uuid 0.8.2", + "uuid", ] [[package]] name = "symbolic-demangle" -version = "8.8.0" +version = "12.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4564ca7b4e6eb14105aa8bbbce26e080f6b5d9c4373e67167ab31f7b86443750" +checksum = "48c043a45f08f41187414592b3ceb53fb0687da57209cc77401767fb69d5b596" dependencies = [ "cpp_demangle", "rustc-demangle", @@ -2165,9 +2178,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "taplo" -version = "0.13.1" +version = "0.13.2" dependencies = [ - "ahash 0.8.8", + "ahash", "arc-swap", "assert-json-diff", "criterion", @@ -2190,13 +2203,13 @@ dependencies = [ [[package]] name = "taplo-cli" -version = "0.9.2" +version = "0.9.3" dependencies = [ "ansi_term", "anyhow", "async-ctrlc", "atty", - "clap 3.2.25", + "clap", "codespan-reporting", "futures", "glob", @@ -2223,9 +2236,9 @@ dependencies = [ [[package]] name = "taplo-common" -version = "0.5.1" +version = "0.5.2" dependencies = [ - "ahash 0.8.8", + "ahash", "anyhow", "arc-swap", "async-recursion", @@ -2235,7 +2248,7 @@ dependencies = [ "glob", "globset", "hex", - "indexmap 1.9.3", + "indexmap", "itertools", "json_value_merge", "jsonschema", @@ -2261,14 +2274,14 @@ dependencies = [ [[package]] name = "taplo-lsp" -version = "0.7.1" +version = "0.7.2" dependencies = [ "anyhow", "arc-swap", "either", "figment", "futures", - "indexmap 1.9.3", + "indexmap", "itertools", "lsp-async-stub", "lsp-types", @@ -2314,21 +2327,6 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f18aa187839b2bdb1ad2fa35ead8c4c2976b64e4363c386d45ac0f7ee85c9233" -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - -[[package]] -name = "textwrap" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" - [[package]] name = "thiserror" version = "1.0.57" @@ -2466,16 +2464,15 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] @@ -2505,7 +2502,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.3", + "indexmap", "serde", "serde_spanned", "toml_datetime", @@ -2646,10 +2643,10 @@ dependencies = [ ] [[package]] -name = "uuid" -version = "0.8.2" +name = "utf8parse" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" diff --git a/Cargo.toml b/Cargo.toml index 4e4dd177f..b9116a9d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,16 +1,55 @@ [workspace] -members = ["crates/*"] exclude = ["util/test-gen", "crates/taplo-wasm"] +members = ["crates/*"] resolver = "2" +[workspace.package] +authors = ["tamasfe"] +edition = "2021" +license = "MIT" +homepage = "https://taplo.tamasfe.dev" +repository = "https://github.com/tamasfe/taplo" + +[workspace.dependencies] +ahash = { version = "0.8.3" } +anyhow = { version = "1.0.53" } +arc-swap = { version = "1.5.0" } +async-trait = { version = "0.1.52" } +either = { version = "1.6.1" } +futures = { version = "0.3.5" } +glob = { version = "0.3" } +globset = { version = "0.4.8" } +getrandom = { version = "0.2", default-features = false } +hex = { version = "0.4" } +indexmap = { version = "2.2" } +itertools = { version = "0.10.3" } +lsp-types = { version = "0.93.0" } +once_cell = { version = "1.4" } +parking_lot = { version = "0.12.0" } +regex = { version = "1.5" } +reqwest = { version = "0.11.9", default-features = false } +rowan = { version = "0.15.3" } +schemars = { version = "0.8.3" } +serde = { version = "1" } +serde_json = { version = "1.0.78" } +sha1 = { version = "0.10.5" } +tap = { version = "1.0.1" } +thiserror = { version = "1.0.30" } +time = { version = "0.3.7" } +toml = { version = "0.7" } +tokio = { version = "1.24.2", default-features = false } +tracing = { version = "0.1.30" } +tracing-subscriber = { version = "0.3.7" } +url = { version = "2.2.2" } + [profile.release] codegen-units = 1 -opt-level = 3 -lto = "thin" -strip = "debuginfo" +lto = "thin" +opt-level = 3 +strip = true [profile.bench] -lto = true +lto = true opt-level = 3 diff --git a/crates/lsp-async-stub/Cargo.toml b/crates/lsp-async-stub/Cargo.toml index 44201df01..6135092e1 100644 --- a/crates/lsp-async-stub/Cargo.toml +++ b/crates/lsp-async-stub/Cargo.toml @@ -1,36 +1,32 @@ [package] -authors = ["tamasfe"] -description = "An LSP server stub for futures" -edition = "2021" -name = "lsp-async-stub" -version = "0.6.4" -license = "MIT" -repository = "https://github.com/tamasfe/taplo" +name = "lsp-async-stub" +description = "An LSP server stub for futures" +version = "0.6.4" +rust-version = "1.70" +authors = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +repository = { workspace = true } # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -anyhow = "1" -async-trait = "0.1.52" -futures = "0.3.5" -getrandom = { version = "0.2", features = ["wasm-bindgen", "js"] } -lsp-types = { version = "0.93.0" } -rowan = "0.15.3" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -tokio = { version = "1.24.2", default-features = false, optional = true } -tracing = "0.1.29" +anyhow = { workspace = true } +async-trait = { workspace = true } +futures = { workspace = true } +getrandom = { workspace = true, features = ["wasm-bindgen", "js"] } +lsp-types = { workspace = true } +rowan = { workspace = true } +serde = { workspace = true, features = ["derive"] } +serde_json = { workspace = true } +tokio = { workspace = true, optional = true } +tracing = { workspace = true } [features] -default = [] -tokio-stdio = [ - "tokio", - "tokio/rt", - "tokio/io-util", - "tokio/io-std", - "tokio/macros", -] -tokio-tcp = ["tokio", "tokio/rt", "tokio/io-util", "tokio/net", "tokio/macros"] +default = [] +tokio-stdio = ["tokio", "tokio/rt", "tokio/io-util", "tokio/io-std", "tokio/macros"] +tokio-tcp = ["tokio", "tokio/rt", "tokio/io-util", "tokio/net", "tokio/macros"] [package.metadata.auto-tag] enabled = true diff --git a/crates/lsp-async-stub/src/lib.rs b/crates/lsp-async-stub/src/lib.rs index 4f4d07811..b484904e7 100644 --- a/crates/lsp-async-stub/src/lib.rs +++ b/crates/lsp-async-stub/src/lib.rs @@ -49,7 +49,7 @@ impl Cancellation { pub fn cancel(&mut self) { self.cancelled.store(true, Ordering::SeqCst); - if let Some(w) = std::mem::replace(&mut *self.waker.lock().unwrap(), None) { + if let Some(w) = (*self.waker.lock().unwrap()).take() { w.wake(); } } diff --git a/crates/taplo-cli/Cargo.toml b/crates/taplo-cli/Cargo.toml index 4880816d2..282d6d3af 100644 --- a/crates/taplo-cli/Cargo.toml +++ b/crates/taplo-cli/Cargo.toml @@ -1,72 +1,58 @@ [package] -authors = ["tamasfe"] -description = "A CLI for Taplo TOML toolkit" -license = "MIT" -edition = "2021" -name = "taplo-cli" -version = "0.9.3" -homepage = "https://taplo.tamasfe.dev" -repository = "https://github.com/tamasfe/taplo" -categories = ["development-tools", "command-line-utilities"] -keywords = ["toml", "linter", "formatter"] +name = "taplo-cli" +description = "A CLI for Taplo TOML toolkit" +version = "0.9.3" +rust-version = "1.70" +categories = ["development-tools", "command-line-utilities"] +keywords = ["toml", "linter", "formatter"] +authors = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +repository = { workspace = true } [features] -default = ["rustls-tls"] -lsp = ["taplo-lsp", "async-ctrlc"] -native-tls = ["taplo-common/native-tls"] -rustls-tls = ["taplo-common/rustls-tls"] -toml-test = [] +default = ["rustls-tls", "lsp", "toml-test"] +lsp = ["taplo-lsp", "async-ctrlc"] +native-tls = ["taplo-common/native-tls", "taplo-lsp?/native-tls"] +rustls-tls = ["taplo-common/rustls-tls", "taplo-lsp?/rustls-tls"] +toml-test = [] [dependencies] -anyhow = { version = "1", features = ["backtrace"] } -async-ctrlc = { version = "1.2.0", features = ["stream"], optional = true } -clap = { version = "3.0.0", features = ["derive", "cargo", "env"] } -codespan-reporting = "0.11.1" -futures = "0.3" -glob = "0.3" -hex = "0.4" -itertools = "0.10.3" -once_cell = "1.4" -regex = "1.4" -reqwest = { version = "0.11.9", default-features = false, features = [ - "json", -] } -schemars = "0.8" -serde = "1" -serde_json = "1" -taplo = { version = "0.13.2", path = "../taplo", features = ["serde"] } -taplo-common = { version = "0.5.2", path = "../taplo-common" } -taplo-lsp = { version = "0.7.2", path = "../taplo-lsp", default-features = false, optional = true } -time = { version = "0.3", features = ["parsing"] } -toml = "0.7" -tracing = "0.1.29" -tracing-subscriber = { version = "0.3.7", features = ["env-filter"] } -url = "2.2.2" +taplo = { path = "../taplo", features = ["serde"] } +taplo-common = { path = "../taplo-common" } +taplo-lsp = { path = "../taplo-lsp", default-features = false, optional = true } + +anyhow = { workspace = true, features = ["backtrace"] } +clap = { version = "4", features = ["derive", "cargo", "env"] } +codespan-reporting = { version = "0.11.1" } +futures = { workspace = true } +glob = { workspace = true } +hex = { workspace = true } +itertools = { workspace = true } +once_cell = { workspace = true } +regex = { workspace = true } +reqwest = { workspace = true, features = ["json"] } +schemars = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +time = { workspace = true, features = ["parsing"] } +toml = { workspace = true } +tracing = { workspace = true } +tracing-subscriber = { workspace = true, features = ["env-filter"] } +url = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] +ansi_term = { version = "0.12" } +async-ctrlc = { version = "1.2.0", features = ["stream"], optional = true } +atty = { version = "0.2.14" } +lsp-async-stub = { path = "../lsp-async-stub", features = ["tokio-tcp", "tokio-stdio"] } # `prettydiff` is also a CLI that pulls in `clap` by default prettydiff = { version = "0.6.1", default-features = false } -ansi_term = "0.12" -atty = "0.2.14" -tokio = { version = "1.24.2", features = [ - "sync", - "fs", - "time", - "io-std", - "rt-multi-thread", - "parking_lot", -], default-features = false } -lsp-async-stub = { version = "0.6.4", path = "../lsp-async-stub", features = [ - "tokio-tcp", - "tokio-stdio", -] } +tokio = { workspace = true, features = ["sync", "fs", "time", "io-std", "rt-multi-thread", "parking_lot"] } [target.'cfg(target_arch = "wasm32")'.dependencies] -tokio = { version = "1.24.2", features = [ - "sync", - "parking_lot", - "io-util", -], default-features = false } +tokio = { workspace = true, features = ["sync", "parking_lot", "io-util"] } [package.metadata.auto-tag] enabled = true diff --git a/crates/taplo-cli/bin/taplo.rs b/crates/taplo-cli/bin/taplo.rs index 3b07fc367..aaf1aef91 100644 --- a/crates/taplo-cli/bin/taplo.rs +++ b/crates/taplo-cli/bin/taplo.rs @@ -1,4 +1,4 @@ -use clap::StructOpt; +use clap::Parser; use std::process::exit; use taplo_cli::{ args::{Colors, TaploArgs}, diff --git a/crates/taplo-cli/src/args.rs b/crates/taplo-cli/src/args.rs index d563bdbec..d4888d1f6 100644 --- a/crates/taplo-cli/src/args.rs +++ b/crates/taplo-cli/src/args.rs @@ -1,4 +1,4 @@ -use clap::{crate_version, ArgEnum, Args, Parser, Subcommand}; +use clap::{crate_version, Args, Parser, Subcommand, ValueEnum}; use std::path::PathBuf; use url::Url; @@ -7,7 +7,7 @@ use url::Url; #[clap(bin_name = "taplo")] #[clap(version = crate_version!())] pub struct TaploArgs { - #[clap(long, arg_enum, global = true, default_value = "auto")] + #[clap(long, value_enum, global = true, default_value = "auto")] pub colors: Colors, /// Enable a verbose logging format. #[clap(long, global = true)] @@ -34,7 +34,7 @@ pub struct GeneralArgs { pub no_auto_config: bool, } -#[derive(Clone, Copy, ArgEnum)] +#[derive(Clone, Copy, ValueEnum)] pub enum Colors { /// Determine whether to colorize output automatically. Auto, @@ -190,7 +190,7 @@ pub struct GetCommand { /// Comments and formatting will not be preserved. /// It is possible to select arrays and individual values that are not tables, /// in this case the output will not be a valid TOML document. - #[clap(short, long, arg_enum, default_value = "value")] + #[clap(short, long, value_enum, default_value = "value")] pub output_format: OutputFormat, /// Strip the trailing newline from the output. @@ -229,7 +229,7 @@ pub struct GetCommand { pub separator: Option, } -#[derive(Clone, Copy, ArgEnum)] +#[derive(Clone, Copy, ValueEnum)] pub enum OutputFormat { /// Extract the value outputting it in a text format. Value, diff --git a/crates/taplo-cli/src/commands/format.rs b/crates/taplo-cli/src/commands/format.rs index 08941735d..0407f1e84 100644 --- a/crates/taplo-cli/src/commands/format.rs +++ b/crates/taplo-cli/src/commands/format.rs @@ -13,7 +13,7 @@ use tokio::io::{AsyncReadExt, AsyncWriteExt}; impl Taplo { pub async fn execute_format(&mut self, cmd: FormatCommand) -> Result<(), anyhow::Error> { - if matches!(cmd.files.get(0).map(|it| it.as_str()), Some("-")) { + if matches!(cmd.files.first().map(|it| it.as_str()), Some("-")) { self.format_stdin(cmd).await } else { self.format_files(cmd).await diff --git a/crates/taplo-cli/src/commands/lsp.rs b/crates/taplo-cli/src/commands/lsp.rs index 1b7d8f38c..bb7c11458 100644 --- a/crates/taplo-cli/src/commands/lsp.rs +++ b/crates/taplo-cli/src/commands/lsp.rs @@ -1,6 +1,9 @@ use taplo_common::environment::{native::NativeEnvironment, Environment}; -use crate::{args::{LspCommand, LspCommandIo}, Taplo}; +use crate::{ + args::{LspCommand, LspCommandIo}, + Taplo, +}; impl Taplo { pub async fn execute_lsp(&mut self, cmd: LspCommand) -> Result<(), anyhow::Error> { diff --git a/crates/taplo-common/Cargo.toml b/crates/taplo-common/Cargo.toml index 10356b81a..001d02288 100644 --- a/crates/taplo-common/Cargo.toml +++ b/crates/taplo-common/Cargo.toml @@ -1,63 +1,55 @@ [package] -name = "taplo-common" -version = "0.5.2" -edition = "2021" -description = "Shared code for taplo utilities." -license = "MIT" -repository = "https://github.com/tamasfe/taplo" +name = "taplo-common" +description = "Shared code for taplo utilities." +version = "0.5.2" +rust-version = "1.70" +authors = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +repository = { workspace = true } # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ahash = { version = "0.8.3", features = ["serde"] } -anyhow = { version = "1.0.53", features = ["backtrace"] } -arc-swap = "1.5.0" -async-recursion = "1.0.0" -async-trait = "0.1.52" -atty = "0.2.14" -futures = "0.3.19" -glob = "0.3.0" -globset = "0.4.8" -hex = "0.4.3" -indexmap = { version = "1.6.0", features = ["serde", "rayon"] } -itertools = "0.10.3" -json_value_merge = "2.0.0" -jsonschema = { version = "0.17.1", default-features = false } -lru = "0.7.2" -parking_lot = "0.12.0" -percent-encoding = "2.1.0" -regex = "1.5.4" -reqwest = { version = "0.11.24", default-features = false, features = [ - "json", -] } -schemars = { version = "0.8.8", features = ["url"] } -semver = { version = "1.0.5", features = ["serde"] } -serde = { version = "1", features = ["derive"] } -serde_json = { version = "1.0.78", features = ["preserve_order"] } -sha1 = "0.10.5" -tap = "1.0.1" -taplo = { version = "0.13.2", path = "../taplo", features = ["schema"] } -thiserror = "1.0.30" -time = { version = "0.3.7", features = ["serde"] } -tracing = "0.1.29" -tracing-subscriber = { version = "0.3.11", features = ["env-filter"] } -url = { version = "2.2.2", features = ["serde"] } +taplo = { path = "../taplo", features = ["schema"] } + +ahash = { workspace = true, features = ["serde"] } +anyhow = { workspace = true, features = ["backtrace"] } +arc-swap = { workspace = true } +async-recursion = { version = "1.0.0" } +async-trait = { workspace = true } +atty = { version = "0.2.14" } +futures = { workspace = true } +glob = { workspace = true } +globset = { workspace = true } +hex = { workspace = true } +indexmap = { workspace = true, features = ["serde", "rayon"] } +itertools = { workspace = true } +json_value_merge = { version = "2.0.0" } +jsonschema = { version = "0.17.1", default-features = false } +lru = { version = "0.11.1" } +parking_lot = { workspace = true } +percent-encoding = { version = "2.1.0" } +regex = { workspace = true } +reqwest = { workspace = true, features = ["json"] } +schemars = { workspace = true, features = ["url"] } +semver = { version = "1.0.5", features = ["serde"] } +serde = { workspace = true, features = ["derive"] } +serde_json = { workspace = true, features = ["preserve_order"] } +sha1 = { workspace = true } +tap = { workspace = true } +thiserror = { workspace = true } +time = { workspace = true, features = ["serde"] } +tracing = { workspace = true } +tracing-subscriber = { workspace = true, features = ["env-filter"] } +url = { workspace = true, features = ["serde"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -tokio = { version = "1.24.2", features = [ - "sync", - "fs", - "time", - "io-std", - "parking_lot", -] } +tokio = { workspace = true, features = ["sync", "fs", "time", "io-std", "parking_lot"] } [target.'cfg(target_arch = "wasm32")'.dependencies] -tokio = { version = "1.24.2", features = [ - "sync", - "parking_lot", - "io-util", -], default-features = false } +tokio = { workspace = true, features = ["sync", "parking_lot", "io-util"] } [features] # default-tls enables native-tls but without enabling native-tls specific features. diff --git a/crates/taplo-common/src/lib.rs b/crates/taplo-common/src/lib.rs index 6ed9a2b49..d4d75acea 100644 --- a/crates/taplo-common/src/lib.rs +++ b/crates/taplo-common/src/lib.rs @@ -7,6 +7,7 @@ clippy::module_name_repetitions, clippy::missing_errors_doc, clippy::missing_panics_doc, + clippy::missing_fields_in_debug, clippy::similar_names, clippy::too_many_lines )] diff --git a/crates/taplo-common/src/schema/associations.rs b/crates/taplo-common/src/schema/associations.rs index 628d3e10a..99d6d1e4f 100644 --- a/crates/taplo-common/src/schema/associations.rs +++ b/crates/taplo-common/src/schema/associations.rs @@ -86,7 +86,7 @@ impl SchemaAssociations { self.retain(|(_, assoc)| assoc.meta["source"] != source::BUILTIN); self.associations.write().push(( - AssociationRule::Regex(Regex::new(r#".*\.?taplo\.toml$"#).unwrap()), + AssociationRule::Regex(Regex::new(r".*\.?taplo\.toml$").unwrap()), SchemaAssociation { url: builtins::TAPLO_CONFIG_URL.parse().unwrap(), meta: json!({ @@ -193,7 +193,7 @@ impl SchemaAssociations { tracing::debug!(%error, "invalid url in directive, assuming file path instead"); if self.env.is_absolute(Path::new(value)) { - match format!("file://{}", value).parse() { + match format!("file://{value}").parse() { Ok(u) => u, Err(error) => { tracing::error!(%error, "invalid schema directive"); @@ -256,9 +256,8 @@ impl SchemaAssociations { pub fn add_from_config(&self, config: &Config) { for rule in &config.rule { - let file_rule = match rule.file_rule.clone() { - Some(rule) => rule, - None => continue, + let Some(file_rule) = rule.file_rule.clone() else { + continue; }; if let Some(schema_opts) = &rule.options.schema { @@ -279,9 +278,8 @@ impl SchemaAssociations { } } - let file_rule = match config.file_rule.clone() { - Some(rule) => rule, - None => return, + let Some(file_rule) = config.file_rule.clone() else { + return; }; if let Some(schema_opts) = &config.global_options.schema { @@ -392,7 +390,7 @@ pub enum AssociationRule { impl AssociationRule { pub fn glob(pattern: &str) -> Result { - Ok(Self::Glob(GlobRule::new(&[pattern], &[] as &[&str])?)) + Ok(Self::Glob(GlobRule::new([pattern], &[] as &[&str])?)) } pub fn regex(regex: &str) -> Result { @@ -520,8 +518,7 @@ impl<'de> Deserialize<'de> for SchemaStoreCatalogSchema { if s != SCHEMA_STORE_CATALOG_SCHEMA_URL { return Err(Error::custom(format!( - "expected $schema to be {}", - SCHEMA_STORE_CATALOG_SCHEMA_URL + "expected $schema to be {SCHEMA_STORE_CATALOG_SCHEMA_URL}" ))); } diff --git a/crates/taplo-common/src/schema/cache.rs b/crates/taplo-common/src/schema/cache.rs index 5a8ff81b7..ffd4ee61b 100644 --- a/crates/taplo-common/src/schema/cache.rs +++ b/crates/taplo-common/src/schema/cache.rs @@ -4,7 +4,7 @@ use parking_lot::Mutex; use serde::{Deserialize, Serialize}; use serde_json::Value; use sha1::{Digest, Sha1}; -use std::{path::PathBuf, sync::Arc, time::Duration}; +use std::{num::NonZeroUsize, path::PathBuf, sync::Arc, time::Duration}; use time::OffsetDateTime; use url::Url; @@ -32,7 +32,7 @@ impl Cache { lru_expires_by: Arc::new(Mutex::new(env.now() + DEFAULT_LRU_CACHE_EXPIRATION_TIME)), env, schemas: Arc::new(Mutex::new(LruCache::with_hasher( - 10, + NonZeroUsize::new(10).unwrap(), ahash::RandomState::new(), ))), cache_path: Default::default(), diff --git a/crates/taplo-common/src/schema/mod.rs b/crates/taplo-common/src/schema/mod.rs index 206e7df9f..65b99a09a 100644 --- a/crates/taplo-common/src/schema/mod.rs +++ b/crates/taplo-common/src/schema/mod.rs @@ -9,7 +9,7 @@ use jsonschema::{error::ValidationErrorKind, JSONSchema, SchemaResolver, Validat use parking_lot::Mutex; use regex::Regex; use serde_json::Value; -use std::{borrow::Cow, sync::Arc}; +use std::{borrow::Cow, num::NonZeroUsize, sync::Arc}; use taplo::dom::{self, node::Key, KeyOrIndex, Keys}; use thiserror::Error; use tokio::sync::Semaphore; @@ -28,7 +28,7 @@ pub mod builtins { #[must_use] pub fn taplo_config_schema() -> Arc { - Arc::new(serde_json::to_value(&schemars::schema_for!(crate::config::Config)).unwrap()) + Arc::new(serde_json::to_value(schemars::schema_for!(crate::config::Config)).unwrap()) } #[must_use] @@ -62,7 +62,7 @@ impl Schemas { concurrent_requests: Arc::new(Semaphore::new(10)), http, validators: Arc::new(Mutex::new(LruCache::with_hasher( - 3, + NonZeroUsize::new(3).unwrap(), ahash::RandomState::new(), ))), } @@ -90,7 +90,7 @@ impl Schemas { schema_url: &Url, root: &dom::Node, ) -> Result, anyhow::Error> { - let value = serde_json::to_value(&root)?; + let value = serde_json::to_value(root)?; self.validate(schema_url, &value) .await? .into_iter() @@ -132,7 +132,7 @@ impl Schemas { // to fully validate according to a schema that has many nested references. loop { match validator.validate(value) { - Ok(_) => return Ok(Vec::new()), + Ok(()) => return Ok(Vec::new()), Err(errors) => { let errors: Vec<_> = errors .map(|err| ValidationError { @@ -248,7 +248,6 @@ impl Schemas { } None => { let val = self.load_schema(&url).await?; - let val = val; drop(self.cache.store(url, val.clone())); Ok(val) } @@ -368,14 +367,11 @@ impl Schemas { let include_self = schema["allOf"].is_null(); - let key = match path.iter().next() { - Some(k) => k, - None => { - if include_self { - schemas.push((full_path.clone(), Arc::new(schema.clone()))); - } - return Ok(()); + let Some(key) = path.iter().next() else { + if include_self { + schemas.push((full_path.clone(), Arc::new(schema.clone()))); } + return Ok(()); }; let child_path = path.skip_left(1); @@ -474,7 +470,7 @@ impl Schemas { for (path, schema) in schemas { self.collect_child_schemas( schema_url, - &*schema, + &schema, &path, &Keys::empty(), max_depth, diff --git a/crates/taplo-common/src/util.rs b/crates/taplo-common/src/util.rs index 4cb594398..e54f8c5f0 100644 --- a/crates/taplo-common/src/util.rs +++ b/crates/taplo-common/src/util.rs @@ -49,7 +49,7 @@ pub struct ArcHashValue(pub Arc); impl Hash for ArcHashValue { fn hash(&self, state: &mut H) { - HashValue(&*self.0).hash(state); + HashValue(&self.0).hash(state); } } @@ -109,9 +109,8 @@ impl Normalize for PathBuf { } pub(crate) fn normalize_str(s: &str) -> Cow { - let percent_decoded = match percent_decode_str(s).decode_utf8().ok() { - Some(s) => s, - None => return s.into(), + let Some(percent_decoded) = percent_decode_str(s).decode_utf8().ok() else { + return s.into(); }; if cfg!(windows) { @@ -165,7 +164,7 @@ pub fn get_reqwest_client(timeout: std::time::Duration) -> Result"] -description = "Language server for Taplo" -edition = "2021" -name = "taplo-lsp" -version = "0.7.2" -license = "MIT" -homepage = "https://taplo.tamasfe.dev" -repository = "https://github.com/tamasfe/taplo" +name = "taplo-lsp" +description = "Language server for Taplo" +version = "0.7.2" +rust-version = "1.70" +authors = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +repository = { workspace = true } [lib] crate-type = ["cdylib", "rlib"] [features] -default = ["rustls-tls"] +default = ["rustls-tls"] native-tls = ["taplo-common/native-tls"] rustls-tls = ["taplo-common/rustls-tls"] [dependencies] -anyhow = "1" -arc-swap = "1.5.0" -either = "1.6.1" -figment = { version = "0.10.6", features = ["json"] } -futures = "0.3.5" -indexmap = { version = "1.6", features = ["serde"] } -itertools = "0.10.3" -lsp-async-stub = { version = "0.6.4", path = "../lsp-async-stub" } -lsp-types = { version = "0.93.0", features = ["proposed"] } -once_cell = "1.5" -parking_lot = "0.12.0" -regex = "1.5.4" -reqwest = { version = "0.11.9", default-features = false, features = [ - "json", -] } -schemars = "0.8" -serde = { version = "1.0", features = ["derive"] } -serde_json = { version = "1.0", features = ["preserve_order"] } -tap = "1.0.1" -taplo = { version = "0.13.2", path = "../taplo", features = ["serde"] } -taplo-common = { version = "0.5.2", path = "../taplo-common" } -time = { version = "0.3", features = ["formatting", "parsing"] } -toml = "0.7" -tracing = "0.1.29" +lsp-async-stub = { path = "../lsp-async-stub" } +taplo = { path = "../taplo", features = ["serde"] } +taplo-common = { path = "../taplo-common" } + +anyhow = { workspace = true } +arc-swap = { workspace = true } +either = { workspace = true } +figment = { version = "0.10.6", features = ["json"] } +futures = { workspace = true } +indexmap = { workspace = true, features = ["serde"] } +itertools = { workspace = true } +lsp-types = { version = "0.93.0", features = ["proposed"] } +once_cell = { workspace = true } +parking_lot = { workspace = true } +regex = { workspace = true } +reqwest = { workspace = true, features = ["json"] } +schemars = { workspace = true } +serde = { workspace = true, features = ["derive"] } +serde_json = { workspace = true, features = ["preserve_order"] } +tap = { workspace = true } +time = { workspace = true, features = ["formatting", "parsing"] } +toml = { workspace = true } +tracing = { workspace = true } [package.metadata.auto-tag] enabled = true diff --git a/crates/taplo-lsp/src/diagnostics.rs b/crates/taplo-lsp/src/diagnostics.rs index 01c3b771e..15d7734f0 100644 --- a/crates/taplo-lsp/src/diagnostics.rs +++ b/crates/taplo-lsp/src/diagnostics.rs @@ -17,16 +17,12 @@ pub(crate) async fn publish_diagnostics( let mut diags = Vec::new(); let workspaces = context.workspaces.read().await; - let ws = match workspaces.get(&ws_url) { - Some(d) => d, - None => { - tracing::warn!(%document_url, "workspace not found"); - return; - } + let Some(ws) = workspaces.get(&ws_url) else { + tracing::warn!(%document_url, "workspace not found"); + return; }; - let doc = match ws.documents.get(&document_url) { - Some(doc) => doc, - None => return, + let Some(doc) = ws.documents.get(&document_url) else { + return; }; collect_syntax_errors(doc, &mut diags); @@ -46,16 +42,12 @@ pub(crate) async fn publish_diagnostics( } let workspaces = context.workspaces.read().await; - let ws = match workspaces.get(&ws_url) { - Some(d) => d, - None => { - tracing::warn!(%document_url, "workspace not found"); - return; - } + let Some(ws) = workspaces.get(&ws_url) else { + tracing::warn!(%document_url, "workspace not found"); + return; }; - let doc = match ws.documents.get(&document_url) { - Some(doc) => doc, - None => return, + let Some(doc) = ws.documents.get(&document_url) else { + return; }; let dom = doc.dom.clone(); @@ -77,16 +69,12 @@ pub(crate) async fn publish_diagnostics( } let workspaces = context.workspaces.read().await; - let ws = match workspaces.get(&ws_url) { - Some(d) => d, - None => { - tracing::warn!(%document_url, "workspace not found"); - return; - } + let Some(ws) = workspaces.get(&ws_url) else { + tracing::warn!(%document_url, "workspace not found"); + return; }; - let doc = match ws.documents.get(&document_url) { - Some(doc) => doc, - None => return, + let Some(doc) = ws.documents.get(&document_url) else { + return; }; collect_schema_errors(ws, doc, &dom, &document_url, &mut diags).await; diff --git a/crates/taplo-lsp/src/handlers/completion.rs b/crates/taplo-lsp/src/handlers/completion.rs index 77990c4fa..be49549dc 100644 --- a/crates/taplo-lsp/src/handlers/completion.rs +++ b/crates/taplo-lsp/src/handlers/completion.rs @@ -46,18 +46,14 @@ pub async fn completion( } }; - let schema_association = match ws.schemas.associations().association_for(&document_uri) { - Some(ass) => ass, - None => return Ok(None), + let Some(schema_association) = ws.schemas.associations().association_for(&document_uri) else { + return Ok(None); }; let position = p.text_document_position.position; - let offset = match doc.mapper.offset(Position::from_lsp(position)) { - Some(ofs) => ofs, - None => { - tracing::error!(?position, "document position not found"); - return Ok(None); - } + let Some(offset) = doc.mapper.offset(Position::from_lsp(position)) else { + tracing::error!(?position, "document position not found"); + return Ok(None); }; let query = Query::at(&doc.dom, offset); @@ -615,7 +611,7 @@ fn add_value_completions( } "boolean" => { completions.push(CompletionItem { - label: r#"true"#.into(), + label: r"true".into(), kind: Some(CompletionItemKind::VALUE), documentation: Some(Documentation::MarkupContent(MarkupContent { kind: lsp_types::MarkupKind::Markdown, @@ -625,13 +621,13 @@ fn add_value_completions( text_edit: range.map(|range| { CompletionTextEdit::Edit(TextEdit { range, - new_text: r#"true$0"#.into(), + new_text: r"true$0".into(), }) }), ..Default::default() }); completions.push(CompletionItem { - label: r#"false"#.into(), + label: r"false".into(), kind: Some(CompletionItemKind::VALUE), documentation: Some(Documentation::MarkupContent(MarkupContent { kind: lsp_types::MarkupKind::Markdown, @@ -641,7 +637,7 @@ fn add_value_completions( text_edit: range.map(|range| { CompletionTextEdit::Edit(TextEdit { range, - new_text: r#"false$0"#.into(), + new_text: r"false$0".into(), }) }), ..Default::default() @@ -649,7 +645,7 @@ fn add_value_completions( } "array" => { completions.push(CompletionItem { - label: r#"[]"#.into(), + label: r"[]".into(), kind: Some(CompletionItemKind::VALUE), documentation: Some(Documentation::MarkupContent(MarkupContent { kind: lsp_types::MarkupKind::Markdown, @@ -659,7 +655,7 @@ fn add_value_completions( text_edit: range.map(|range| { CompletionTextEdit::Edit(TextEdit { range, - new_text: r#"[$0]"#.into(), + new_text: r"[$0]".into(), }) }), ..Default::default() @@ -667,7 +663,7 @@ fn add_value_completions( } "object" => { completions.push(CompletionItem { - label: r#"{ }"#.into(), + label: r"{ }".into(), kind: Some(CompletionItemKind::VALUE), documentation: Some(Documentation::MarkupContent(MarkupContent { kind: lsp_types::MarkupKind::Markdown, @@ -677,7 +673,7 @@ fn add_value_completions( text_edit: range.map(|range| { CompletionTextEdit::Edit(TextEdit { range, - new_text: r#"{ $0 }"#.into(), + new_text: r"{ $0 }".into(), }) }), ..Default::default() diff --git a/crates/taplo-lsp/src/handlers/document_symbols.rs b/crates/taplo-lsp/src/handlers/document_symbols.rs index 46f8c8157..979dcaf3d 100644 --- a/crates/taplo-lsp/src/handlers/document_symbols.rs +++ b/crates/taplo-lsp/src/handlers/document_symbols.rs @@ -162,7 +162,7 @@ fn symbols_for_value( fn ensure_non_empty_key(s: String) -> String { if s.is_empty() { - r#"''"#.into() + r"''".into() } else { s } diff --git a/crates/taplo-lsp/src/handlers/hover.rs b/crates/taplo-lsp/src/handlers/hover.rs index 3c03dd8a2..48d80ba2b 100644 --- a/crates/taplo-lsp/src/handlers/hover.rs +++ b/crates/taplo-lsp/src/handlers/hover.rs @@ -40,12 +40,9 @@ pub(crate) async fn hover( }; let position = p.text_document_position_params.position; - let offset = match doc.mapper.offset(Position::from_lsp(position)) { - Some(ofs) => ofs, - None => { - tracing::error!(?position, "document position not found"); - return Ok(None); - } + let Some(offset) = doc.mapper.offset(Position::from_lsp(position)) else { + tracing::error!(?position, "document position not found"); + return Ok(None); }; let query = Query::at(&doc.dom, offset); @@ -86,9 +83,8 @@ pub(crate) async fn hover( } }; - let (keys, _) = match &position_info.dom_node { - Some(n) => n, - None => return Ok(None), + let Some((keys, _)) = &position_info.dom_node else { + return Ok(None); }; let links_in_hover = !ws.config.schema.links; @@ -108,9 +104,8 @@ pub(crate) async fn hover( ); } - let node = match doc.dom.path(&keys) { - Some(n) => n, - None => return Ok(None), + let Some(node) = doc.dom.path(&keys) else { + return Ok(None); }; if position_info.syntax.kind() == SyntaxKind::IDENT { @@ -262,7 +257,7 @@ pub(crate) async fn hover( } else if let Some(title) = schema["title"].as_str() { title.to_string() } else { - "".to_string() + String::new() } }) .join("\n"); diff --git a/crates/taplo-lsp/src/handlers/rename.rs b/crates/taplo-lsp/src/handlers/rename.rs index 89f23422f..f4f3f00d2 100644 --- a/crates/taplo-lsp/src/handlers/rename.rs +++ b/crates/taplo-lsp/src/handlers/rename.rs @@ -31,12 +31,9 @@ pub async fn prepare_rename( }; let position = p.position; - let offset = match doc.mapper.offset(Position::from_lsp(position)) { - Some(ofs) => ofs, - None => { - tracing::error!(?position, "document position not found"); - return Ok(None); - } + let Some(offset) = doc.mapper.offset(Position::from_lsp(position)) else { + tracing::error!(?position, "document position not found"); + return Ok(None); }; let query = Query::at(&doc.dom, offset); @@ -88,12 +85,9 @@ pub async fn rename( }; let position = p.text_document_position.position; - let offset = match doc.mapper.offset(Position::from_lsp(position)) { - Some(ofs) => ofs, - None => { - tracing::error!(?position, "document position not found"); - return Ok(None); - } + let Some(offset) = doc.mapper.offset(Position::from_lsp(position)) else { + tracing::error!(?position, "document position not found"); + return Ok(None); }; let query = Query::at(&doc.dom, offset); diff --git a/crates/taplo-lsp/src/handlers/schema.rs b/crates/taplo-lsp/src/handlers/schema.rs index 3a92c6d07..c4778b6d0 100644 --- a/crates/taplo-lsp/src/handlers/schema.rs +++ b/crates/taplo-lsp/src/handlers/schema.rs @@ -45,9 +45,8 @@ pub async fn associate_schema( context: Context>, params: Params, ) { - let p = match params.required() { - Ok(p) => p, - Err(_) => return, + let Ok(p) = params.required() else { + return; }; let workspaces = context.workspaces.read().await; diff --git a/crates/taplo-lsp/src/handlers/workspaces.rs b/crates/taplo-lsp/src/handlers/workspaces.rs index 396978518..d225f5f8a 100644 --- a/crates/taplo-lsp/src/handlers/workspaces.rs +++ b/crates/taplo-lsp/src/handlers/workspaces.rs @@ -17,7 +17,7 @@ pub async fn workspace_change( let init_config = context.init_config.load(); for removed in p.event.removed { - workspaces.remove(&removed.uri); + workspaces.shift_remove(&removed.uri); } for added in p.event.added { diff --git a/crates/taplo-lsp/src/query.rs b/crates/taplo-lsp/src/query.rs index fe39bf909..14899ccc7 100644 --- a/crates/taplo-lsp/src/query.rs +++ b/crates/taplo-lsp/src/query.rs @@ -73,39 +73,36 @@ impl Query { pub fn in_table_header(&self) -> bool { match (&self.before, &self.after) { (Some(before), Some(after)) => { - let header_syntax = match before + let Some(header_syntax) = before .syntax .parent_ancestors() .find(|s| s.kind() == TABLE_HEADER) - { - Some(h) => h, - None => return false, + else { + return false; }; if !after.syntax.parent_ancestors().any(|a| a == header_syntax) { return false; } - let bracket_start = match header_syntax.children_with_tokens().find_map(|t| { + let Some(bracket_start) = header_syntax.children_with_tokens().find_map(|t| { if t.kind() == BRACKET_START { t.into_token() } else { None } - }) { - Some(t) => t, - None => return false, + }) else { + return false; }; - let bracket_end = match header_syntax.children_with_tokens().find_map(|t| { + let Some(bracket_end) = header_syntax.children_with_tokens().find_map(|t| { if t.kind() == BRACKET_END { t.into_token() } else { None } - }) { - Some(t) => t, - None => return false, + }) else { + return false; }; (before.syntax == bracket_start @@ -121,20 +118,19 @@ impl Query { pub fn in_table_array_header(&self) -> bool { match (&self.before, &self.after) { (Some(before), Some(after)) => { - let header_syntax = match before + let Some(header_syntax) = before .syntax .parent_ancestors() .find(|s| s.kind() == TABLE_ARRAY_HEADER) - { - Some(h) => h, - None => return false, + else { + return false; }; if !after.syntax.parent_ancestors().any(|a| a == header_syntax) { return false; } - let bracket_start = match header_syntax + let Some(bracket_start) = header_syntax .children_with_tokens() .filter_map(|t| { if t.kind() == BRACKET_START { @@ -144,20 +140,18 @@ impl Query { } }) .nth(1) - { - Some(t) => t, - None => return false, + else { + return false; }; - let bracket_end = match header_syntax.children_with_tokens().find_map(|t| { + let Some(bracket_end) = header_syntax.children_with_tokens().find_map(|t| { if t.kind() == BRACKET_END { t.into_token() } else { None } - }) { - Some(t) => t, - None => return false, + }) else { + return false; }; (before.syntax == bracket_start @@ -173,13 +167,12 @@ impl Query { pub fn header_key(&self) -> Option { match (&self.before, &self.after) { (Some(before), _) => { - let header_syntax = match before + let Some(header_syntax) = before .syntax .parent_ancestors() .find(|s| matches!(s.kind(), TABLE_ARRAY_HEADER | TABLE_HEADER)) - { - Some(h) => h, - None => return None, + else { + return None; }; header_syntax.descendants().find(|n| n.kind() == KEY) @@ -195,13 +188,12 @@ impl Query { None => return None, }; - let keys = match syntax + let Some(keys) = syntax .parent_ancestors() .find(|n| n.kind() == ENTRY) .and_then(|entry| entry.children().find(|c| c.kind() == KEY)) - { - Some(keys) => keys, - None => return None, + else { + return None; }; Some(keys) @@ -214,13 +206,12 @@ impl Query { None => return None, }; - let value = match syntax + let Some(value) = syntax .parent_ancestors() .find(|n| n.kind() == ENTRY) .and_then(|entry| entry.children().find(|c| c.kind() == VALUE)) - { - Some(value) => value, - None => return None, + else { + return None; }; Some(value) @@ -244,9 +235,8 @@ impl Query { .take_while(|n| n.text_range().end() <= syntax.text_range().end()) .last(); - let last_header = match last_header { - Some(h) => h, - None => return (Keys::empty(), root.clone()), + let Some(last_header) = last_header else { + return (Keys::empty(), root.clone()); }; let keys = Keys::from_syntax( @@ -309,9 +299,8 @@ impl Query { #[must_use] pub fn entry_has_eq(&self) -> bool { - let key_syntax = match self.entry_key() { - Some(p) => p, - None => return false, + let Some(key_syntax) = self.entry_key() else { + return false; }; key_syntax @@ -474,16 +463,13 @@ pub struct PositionInfo { } fn full_range(keys: &Keys, node: &Node) -> TextRange { - let last_key = match keys + let Some(last_key) = keys .iter() .filter_map(KeyOrIndex::as_key) .last() .map(Key::text_ranges) - { - Some(k) => k, - None => { - return join_ranges(node.text_ranges()); - } + else { + return join_ranges(node.text_ranges()); }; join_ranges(last_key.chain(node.text_ranges())) diff --git a/crates/taplo-lsp/src/world.rs b/crates/taplo-lsp/src/world.rs index fc413ac2d..c440b4365 100644 --- a/crates/taplo-lsp/src/world.rs +++ b/crates/taplo-lsp/src/world.rs @@ -151,7 +151,7 @@ impl WorkspaceState { env: &impl Environment, ) -> Result<(), anyhow::Error> { if let Err(error) = self - .load_config(env, &*context.world().default_config.load()) + .load_config(env, &context.world().default_config.load()) .await { tracing::warn!(%error, "failed to load workspace configuration"); @@ -247,7 +247,8 @@ impl WorkspaceState { if let Some(config_path) = config_path { tracing::info!(path = ?config_path, "using config file"); - self.taplo_config = toml::from_str(str::from_utf8(&env.read_file(&config_path).await?)?)?; + self.taplo_config = + toml::from_str(str::from_utf8(&env.read_file(&config_path).await?)?)?; } } diff --git a/crates/taplo-wasm/.cargo/config.toml b/crates/taplo-wasm/.cargo/config.toml new file mode 100644 index 000000000..f4e8c002f --- /dev/null +++ b/crates/taplo-wasm/.cargo/config.toml @@ -0,0 +1,2 @@ +[build] +target = "wasm32-unknown-unknown" diff --git a/crates/taplo-wasm/Cargo.lock b/crates/taplo-wasm/Cargo.lock index bf2a6a153..acbbd5a90 100644 --- a/crates/taplo-wasm/Cargo.lock +++ b/crates/taplo-wasm/Cargo.lock @@ -17,17 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "ahash" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" -dependencies = [ - "getrandom", - "once_cell", - "version_check", -] - [[package]] name = "ahash" version = "0.8.8" @@ -51,6 +40,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" + [[package]] name = "ansi_term" version = "0.12.1" @@ -60,6 +55,55 @@ dependencies = [ "winapi", ] +[[package]] +name = "anstream" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" + +[[package]] +name = "anstyle-parse" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "anyhow" version = "1.0.79" @@ -231,42 +275,43 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "3.2.25" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" +checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d" dependencies = [ - "atty", - "bitflags", + "clap_builder", "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708" +dependencies = [ + "anstream", + "anstyle", "clap_lex", - "indexmap 1.6.2", - "once_cell", "strsim", - "termcolor", - "textwrap", ] [[package]] name = "clap_derive" -version = "3.2.25" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae6371b8bdc8b7d3959e9cf7b22d4435ef3e79e138688421ec654acf8c81b008" +checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" dependencies = [ "heck", - "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.48", ] [[package]] name = "clap_lex" -version = "0.2.4" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" -dependencies = [ - "os_str_bytes", -] +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" [[package]] name = "codespan-reporting" @@ -278,6 +323,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "colorchoice" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -550,9 +601,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "js-sys", @@ -611,26 +662,21 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash 0.7.8", -] - [[package]] name = "hashbrown" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +dependencies = [ + "ahash", + "allocator-api2", +] [[package]] name = "heck" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" @@ -743,8 +789,6 @@ checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" dependencies = [ "autocfg", "hashbrown 0.9.1", - "rayon", - "serde", ] [[package]] @@ -755,6 +799,8 @@ checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177" dependencies = [ "equivalent", "hashbrown 0.14.3", + "rayon", + "serde", ] [[package]] @@ -763,6 +809,12 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + [[package]] name = "iso8601" version = "0.6.1" @@ -789,9 +841,9 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "js-sys" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] @@ -811,7 +863,7 @@ version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a071f4f7efc9a9118dfb627a0a94ef247986e1ab8606a4c806ae2b3aa3b6978" dependencies = [ - "ahash 0.8.8", + "ahash", "anyhow", "base64", "bytecount", @@ -841,9 +893,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "lock_api" @@ -886,16 +938,16 @@ dependencies = [ [[package]] name = "lru" -version = "0.7.8" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999beba7b6e8345721bd280141ed958096a2e4abdf74f67ff4ce49b4b54e47a" +checksum = "a4a83fb7698b3643a0e34f9ae6f2e8f0178c0fd42f8b59d493aa271ff3a5bf21" dependencies = [ - "hashbrown 0.12.3", + "hashbrown 0.14.3", ] [[package]] name = "lsp-async-stub" -version = "0.6.3" +version = "0.6.4" dependencies = [ "anyhow", "async-trait", @@ -975,7 +1027,7 @@ checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" dependencies = [ "libc", "wasi", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1110,12 +1162,6 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "os_str_bytes" -version = "6.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" - [[package]] name = "overload" version = "0.1.1" @@ -1151,7 +1197,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -1188,30 +1234,6 @@ dependencies = [ "pad", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" version = "1.0.78" @@ -1355,7 +1377,7 @@ dependencies = [ "libc", "spin", "untrusted", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1479,6 +1501,17 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-wasm-bindgen" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8302e169f0eddcc139c70f139d19d6467353af16f9fce27e8c30158036a1e16b" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", +] + [[package]] name = "serde_derive" version = "1.0.196" @@ -1587,7 +1620,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1598,9 +1631,9 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" @@ -1659,9 +1692,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "taplo" -version = "0.13.1" +version = "0.13.2" dependencies = [ - "ahash 0.8.8", + "ahash", "arc-swap", "either", "globset", @@ -1679,7 +1712,7 @@ dependencies = [ [[package]] name = "taplo-cli" -version = "0.9.2" +version = "0.9.3" dependencies = [ "ansi_term", "anyhow", @@ -1710,9 +1743,9 @@ dependencies = [ [[package]] name = "taplo-common" -version = "0.5.1" +version = "0.5.2" dependencies = [ - "ahash 0.8.8", + "ahash", "anyhow", "arc-swap", "async-recursion", @@ -1722,7 +1755,7 @@ dependencies = [ "glob", "globset", "hex", - "indexmap 1.6.2", + "indexmap 2.2.3", "itertools", "json_value_merge", "jsonschema", @@ -1748,14 +1781,14 @@ dependencies = [ [[package]] name = "taplo-lsp" -version = "0.7.1" +version = "0.7.2" dependencies = [ "anyhow", "arc-swap", "either", "figment", "futures", - "indexmap 1.6.2", + "indexmap 2.2.3", "itertools", "lsp-async-stub", "lsp-types", @@ -1788,6 +1821,7 @@ dependencies = [ "js-sys", "lsp-async-stub", "serde", + "serde-wasm-bindgen", "serde_json", "taplo", "taplo-cli", @@ -1816,12 +1850,6 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f18aa187839b2bdb1ad2fa35ead8c4c2976b64e4363c386d45ac0f7ee85c9233" -[[package]] -name = "textwrap" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" - [[package]] name = "thiserror" version = "1.0.57" @@ -1913,7 +1941,7 @@ dependencies = [ "pin-project-lite", "socket2", "tokio-macros", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2118,6 +2146,12 @@ dependencies = [ "serde", ] +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "uuid" version = "1.7.0" @@ -2153,21 +2187,19 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", - "serde", - "serde_json", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", @@ -2192,9 +2224,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2202,9 +2234,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", @@ -2215,9 +2247,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "web-sys" @@ -2272,7 +2304,16 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", ] [[package]] @@ -2281,13 +2322,29 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -2296,42 +2353,90 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "winnow" version = "0.5.40" @@ -2348,7 +2453,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ "cfg-if", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] diff --git a/crates/taplo-wasm/Cargo.toml b/crates/taplo-wasm/Cargo.toml index 9a5a34e2a..a05bbeb34 100644 --- a/crates/taplo-wasm/Cargo.toml +++ b/crates/taplo-wasm/Cargo.toml @@ -1,8 +1,8 @@ [package] -name = "taplo-wasm" -version = "0.2.1" -edition = "2021" -publish = false +name = "taplo-wasm" +version = "0.2.1" +edition = "2021" +publish = false repository = "https://github.com/tamasfe/taplo" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -11,33 +11,35 @@ repository = "https://github.com/tamasfe/taplo" crate-type = ["cdylib"] [dependencies] -anyhow = "1.0.57" -async-trait = "0.1.56" -clap = { version = "3.1.18", features = ["derive"] } -console_error_panic_hook = "0.1.7" -futures = "0.3.21" -getrandom = { version = "0.2.8", features = ["js"] } -indexmap = "~1.6" -js-sys = "0.3.57" lsp-async-stub = { path = "../lsp-async-stub" } -serde = { version = "1.0.137", features = ["derive"] } -serde_json = "1.0.81" -taplo = { path = "../taplo" } -taplo-cli = { path = "../taplo-cli", optional = true } -taplo-common = { path = "../taplo-common", features = ["rustls-tls"] } -taplo-lsp = { path = "../taplo-lsp", optional = true } -time = { version = "0.3.9", features = ["parsing"] } -tokio = { version = "1.19.2", default-features = false } -tracing = "0.1.35" -url = "2.2.2" -wasm-bindgen = { version = "0.2.90", features = ["serde-serialize"] } -wasm-bindgen-futures = "0.4.40" +taplo = { path = "../taplo" } +taplo-cli = { path = "../taplo-cli", optional = true, default-features = false } +taplo-common = { path = "../taplo-common", default-features = false, features = ["rustls-tls"] } +taplo-lsp = { path = "../taplo-lsp", optional = true, default-features = false } + +anyhow = { version = "1.0.57" } +async-trait = { version = "0.1.56" } +clap = { version = "4.5.8", features = ["derive"] } +console_error_panic_hook = { version = "0.1.7" } +futures = { version = "0.3.21" } +getrandom = { version = "0.2.15", features = ["js"] } +indexmap = { version = "~1.6" } +js-sys = { version = "0.3.69" } +serde = { version = "1.0.137", features = ["derive"] } +serde-wasm-bindgen = { version = "0.6.5" } +serde_json = { version = "1.0.81" } +time = { version = "0.3.9", features = ["parsing"] } +tokio = { version = "1.19.2", default-features = false } +tracing = { version = "0.1.35" } +url = { version = "2.2.2" } +wasm-bindgen = { version = "0.2.92" } +wasm-bindgen-futures = { version = "0.4.40" } [features] +cli = ["taplo-cli"] default = ["lsp", "cli"] -cli = ["taplo-cli"] -lsp = ["taplo-lsp"] +lsp = ["taplo-lsp"] [profile.release] +lto = true opt-level = 's' -lto = true diff --git a/crates/taplo-wasm/src/environment.rs b/crates/taplo-wasm/src/environment.rs index 68719bcb9..304dbf46a 100644 --- a/crates/taplo-wasm/src/environment.rs +++ b/crates/taplo-wasm/src/environment.rs @@ -281,7 +281,7 @@ impl Environment for WasmEnvironment { fn env_vars(&self) -> Vec<(String, String)> { let this = JsValue::null(); let res: JsValue = self.js_env_vars.call0(&this).unwrap(); - res.into_serde() + serde_wasm_bindgen::from_value(res) .map_err(|err| anyhow!("{err}")) .unwrap_or_default() } @@ -310,7 +310,7 @@ impl Environment for WasmEnvironment { .js_glob_files .call1(&this, &JsValue::from_str(glob)) .unwrap(); - res.into_serde().map_err(|err| anyhow!("{err}")) + serde_wasm_bindgen::from_value(res).map_err(|err| anyhow!("{err}")) } async fn read_file(&self, path: &Path) -> Result, anyhow::Error> { @@ -332,12 +332,11 @@ impl Environment for WasmEnvironment { .js_write_file .call2(&this, &path_str, &JsValue::from(Uint8Array::from(bytes))) .unwrap(); - - Ok(JsFuture::from(Promise::from(res)) + let future = JsFuture::from(Promise::from(res)) .await - .map_err(|err| anyhow!("{:?}", err))? - .into_serde() - .map_err(|err| anyhow!("{err}"))?) + .map_err(|err| anyhow!("{:?}", err))?; + + Ok(serde_wasm_bindgen::from_value(future).map_err(|err| anyhow!("{err}"))?) } fn to_file_path(&self, url: &Url) -> Option { diff --git a/crates/taplo-wasm/src/lib.rs b/crates/taplo-wasm/src/lib.rs index fceb9efb1..c90148778 100644 --- a/crates/taplo-wasm/src/lib.rs +++ b/crates/taplo-wasm/src/lib.rs @@ -43,7 +43,7 @@ pub fn format( let mut config = if config.is_undefined() { Config::default() } else { - config.into_serde()? + serde_wasm_bindgen::from_value(config)? }; let env = WasmEnvironment::from(env); @@ -51,7 +51,7 @@ pub fn format( .prepare(&env, Path::new("/")) .map_err(|err| JsError::new(&err.to_string()))?; - let camel_opts: formatter::OptionsIncompleteCamel = options.into_serde()?; + let camel_opts: formatter::OptionsIncompleteCamel = serde_wasm_bindgen::from_value(options)?; let mut options = formatter::Options::default(); if let Some(cfg_opts) = config.global_options.formatting.clone() { options.update(cfg_opts); @@ -74,7 +74,7 @@ pub async fn lint(env: JsValue, toml: String, config: JsValue) -> Result Result Result Result Result<(), JsError> { use tracing::Instrument; let env = WasmEnvironment::from(env); - let args: Vec = args.into_serde()?; + let args: Vec = serde_wasm_bindgen::from_value(args)?; let cli = match TaploArgs::try_parse_from(args) { Ok(v) => v, diff --git a/crates/taplo-wasm/src/lsp.rs b/crates/taplo-wasm/src/lsp.rs index 76cbcb94f..86eb5b768 100644 --- a/crates/taplo-wasm/src/lsp.rs +++ b/crates/taplo-wasm/src/lsp.rs @@ -17,7 +17,7 @@ pub struct TaploWasmLsp { #[wasm_bindgen] impl TaploWasmLsp { pub fn send(&self, message: JsValue) -> Result<(), JsError> { - let message: lsp_async_stub::rpc::Message = message.into_serde()?; + let message: lsp_async_stub::rpc::Message = serde_wasm_bindgen::from_value(message)?; let world = self.world.clone(); let writer = self.lsp_interface.clone(); @@ -64,7 +64,7 @@ impl Sink for WasmLspInterface { ) -> Result<(), Self::Error> { let this = JsValue::null(); self.js_on_message - .call1(&this, &JsValue::from_serde(&message).unwrap()) + .call1(&this, &serde_wasm_bindgen::to_value(&message).unwrap()) .unwrap(); Ok(()) } diff --git a/crates/taplo/Cargo.toml b/crates/taplo/Cargo.toml index b44df82f0..49be8235e 100644 --- a/crates/taplo/Cargo.toml +++ b/crates/taplo/Cargo.toml @@ -1,44 +1,45 @@ [package] -authors = ["tamasfe"] -categories = ["parser-implementations", "parsing"] -description = "A TOML parser, analyzer and formatter library" -edition = "2021" -homepage = "https://taplo.tamasfe.dev" -keywords = ["toml", "parser", "formatter", "linter"] -license = "MIT" -name = "taplo" -readme = false -repository = "https://github.com/tamasfe/taplo" -version = "0.13.2" +name = "taplo" +description = "A TOML parser, analyzer and formatter library" +version = "0.13.2" +rust-version = "1.70" # clap 4.4 = MSRV 1.70, clap 4.5 = MSRV 1.74 +categories = ["parser-implementations", "parsing"] +keywords = ["toml", "parser", "formatter", "linter"] +readme = false +authors = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +repository = { workspace = true } [features] default = ["serde"] -schema = ["schemars"] +schema = ["schemars"] [dependencies] -ahash = "0.8.3" -arc-swap = "1.5.0" -either = "1.6.1" -globset = { version = "0.4.8" } -itertools = "0.10.3" -logos = "0.12.0" -once_cell = "1.9.0" -rowan = "0.15.3" -serde_json = "1.0.79" -thiserror = "1.0.30" -time = { version = "0.3.3", features = ["parsing", "formatting", "macros"] } -tracing = "0.1.30" - -schemars = { version = "0.8.3", optional = true } -serde = { version = "1", features = ["derive"], optional = true } +ahash = { workspace = true } +arc-swap = { workspace = true } +either = { workspace = true } +globset = { workspace = true } +itertools = { workspace = true } +logos = { version = "0.12.0" } +once_cell = { workspace = true } +rowan = { workspace = true } +serde_json = { workspace = true } +thiserror = { workspace = true } +time = { workspace = true, features = ["parsing", "formatting", "macros"] } +tracing = { workspace = true } + +schemars = { workspace = true, optional = true } +serde = { workspace = true, features = ["derive"], optional = true } [dev-dependencies] -assert-json-diff = "2" -criterion = "0.3" -difference = "2.0.0" -pprof = { version = "0.9.1", features = ["flamegraph", "criterion"] } -serde_json = "1" -toml = "0.7" +assert-json-diff = { version = "2" } +criterion = { version = "0.5" } # criterion -> clap +difference = { version = "2.0.0" } +pprof = { version = "0.13", features = ["flamegraph", "criterion"] } # pprof -> criterion -> clap +serde_json = { version = "1" } +toml = { version = "0.7" } [package.metadata.docs.rs] features = ["serde", "schema"] @@ -47,9 +48,9 @@ features = ["serde", "schema"] enabled = true [[bench]] -name = "taplo" harness = false +name = "taplo" [[bench]] -name = "profile" harness = false +name = "profile" diff --git a/crates/taplo/src/dom/mod.rs b/crates/taplo/src/dom/mod.rs index 93dbbf5ec..5b1bafa13 100644 --- a/crates/taplo/src/dom/mod.rs +++ b/crates/taplo/src/dom/mod.rs @@ -140,7 +140,7 @@ impl Keys { } pub fn dotted(&self) -> &str { - &*self.dotted + &self.dotted } pub fn len(&self) -> usize { diff --git a/crates/taplo/src/dom/node.rs b/crates/taplo/src/dom/node.rs index af2c51d76..5ccff3dc4 100644 --- a/crates/taplo/src/dom/node.rs +++ b/crates/taplo/src/dom/node.rs @@ -114,7 +114,7 @@ impl Node { pub fn get_matches( &self, pattern: &str, - ) -> Result + ExactSizeIterator, Error> { + ) -> Result, Error> { let glob = globset::Glob::new(pattern) .map_err(QueryError::from)? .compile_matcher(); @@ -132,7 +132,7 @@ impl Node { Node::Array(arr) => { let items = arr.items().read(); for (idx, node) in items.iter().enumerate() { - if glob.is_match(&idx.to_string()) { + if glob.is_match(idx.to_string()) { matched.push((KeyOrIndex::from(idx), node.clone())); } } @@ -211,7 +211,7 @@ impl Node { } } KeyOrIndex::Index(idx) => { - if !glob.is_match(&idx.to_string()) { + if !glob.is_match(idx.to_string()) { return false; } } diff --git a/crates/taplo/src/dom/serde.rs b/crates/taplo/src/dom/serde.rs index de5f8fa55..915debd4b 100644 --- a/crates/taplo/src/dom/serde.rs +++ b/crates/taplo/src/dom/serde.rs @@ -265,6 +265,6 @@ impl<'de> Deserialize<'de> for Node { where D: serde::Deserializer<'de>, { - de.deserialize_any(TomlVisitor::default()) + de.deserialize_any(TomlVisitor) } } diff --git a/crates/taplo/src/formatter/mod.rs b/crates/taplo/src/formatter/mod.rs index 091b9e5b7..85b0cc9fd 100644 --- a/crates/taplo/src/formatter/mod.rs +++ b/crates/taplo/src/formatter/mod.rs @@ -32,7 +32,7 @@ pub struct ScopedOptions(Vec<(TextRange, OptionsIncomplete)>); impl FromIterator<(TextRange, OptionsIncomplete)> for ScopedOptions { fn from_iter>(iter: T) -> Self { - Self(Vec::from_iter(iter.into_iter())) + Self(Vec::from_iter(iter)) } } @@ -318,7 +318,7 @@ where let matched = dom.find_all_matches(keys, false)?; for (_, node) in matched { - s.extend(node.text_ranges().into_iter().map(|r| (r, opts.clone()))); + s.extend(node.text_ranges().map(|r| (r, opts.clone()))); } } @@ -681,7 +681,9 @@ fn add_entries( entry.value.clear(); if let Some(c) = value.trailing_comment() { - debug_assert!(entry.comment.is_none() || entry.comment.clone().unwrap() == c); + debug_assert!( + entry.comment.is_none() || entry.comment.clone().unwrap() == c + ); entry.comment = Some(c); } diff --git a/docker-bake.hcl b/docker-bake.hcl new file mode 100644 index 000000000..a32ee9fb1 --- /dev/null +++ b/docker-bake.hcl @@ -0,0 +1,78 @@ +variable "RUST_VERSION" { + default = "1" +} + +variable "XX_VERSION" { + default = "master" +} + +variable "RELEASE_TAG" { + default = null +} + +variable "REPO" { + default = "tamasfe/taplo" +} + +variable "PUSH" { + default = false +} + +variable "APK_FAMILY_PACKAGES" { + default = [ + "make", + "clang", + "git", + "lld", + "build-base", + "openssl-dev", + "openssl-libs-static", + ] +} + + +variable "platforms" { + default = [ + "linux/i386", + "linux/amd64", + "linux/arm64", + // "linux/riscv64", + // "linux/s390x", + "linux/arm/v7", + // "linux/arm/v6", + ] +} + +target "_platforms" { + platforms = platforms +} + +group "default" { + targets = ["binary", "oci"] +} + +target "binary" { + inherits = ["alpine"] + output = ["type=local,dest=target/alpine"] + target = "binary" +} + +target "oci" { + inherits = ["alpine"] + output = ["type=image,push=${PUSH}"] + target = "oci" + tags = flatten(["${REPO}:latest", RELEASE_TAG != null ? ["${REPO}:${RELEASE_TAG}"] : []]) +} + +target "alpine" { + context = "." + platforms = platforms + pull = true + dockerfile = "docker/alpine/Dockerfile" + args = { + RUST_VERSION = RUST_VERSION + XX_VERSION = XX_VERSION + DISTRIBUTION_VERSION = "3.20" + DISTRIBUTION_PACKAGES = join(" ", APK_FAMILY_PACKAGES) + } +} diff --git a/docker/alpine/Dockerfile b/docker/alpine/Dockerfile new file mode 100644 index 000000000..2e300b750 --- /dev/null +++ b/docker/alpine/Dockerfile @@ -0,0 +1,105 @@ +# syntax=docker/dockerfile:1 + +ARG DISTRIBUTION_VERSION +ARG RUST_VERSION +ARG XX_VERSION=latest + +FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx +FROM --platform=$BUILDPLATFORM rust:${RUST_VERSION}-alpine${DISTRIBUTION_VERSION} AS build-base +COPY --from=xx / / + +SHELL [ "/bin/ash", "-c" ] + +# install host dependencies +ARG DISTRIBUTION_PACKAGES +RUN \ + --mount=type=cache,id=apk,sharing=private,target=/var/cache/apk \ + --mount=type=cache,id=apk,sharing=private,target=/etc/apk/cache \ + <"] edition = "2018" -name = "test-gen" +name = "test-gen" version = "0.1.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -getopts = "0.2" +getopts = "0.2" proc-macro2 = "1.0.13" -quote = "1.0" -serde = "1" -serde_json = "1" -serde_yaml = "0.8" -walkdir = "2" +quote = "1.0" +serde = "1" +serde_json = "1" +serde_yaml = "0.8" +walkdir = "2"