difftreelog
ci bump Rust version and resolve clippy issues (#160)
in: master
* build: bump Rust version and update dependencies * chore: resolve all reported Clippy issues * build: use the correct Toolchain version * ci: update GitHub Workflows to use valid actions * ci: add permissions to `clippy_check` * chore(GH-160): bump dependencies and disable `thread_local_initializer_can_be_made_const` lint * chore(GH-160): try fixing `thread_local_initializer_can_be_made_const` * fix(GH-160): `serialized-stdlib` feature * ci(GH-160): fix `Test Suite` * fix(GH-160): resolve `insta` deprecation * ci(GH-160): add formatting check job * ci(GH-160): reorganize jobs * style(GH-160): fix formatting * build(GH-160): fix `#[cfg(never)]` * build(GH-160): `#[allow(dead_code)]` on `FinishedRanger::end_token` * build(GH-160): allow more dead code * test(GH-160): fix `golden.rs`
26 files changed
.github/workflows/checks.yamldiffbeforeafterboth--- /dev/null
+++ b/.github/workflows/checks.yaml
@@ -0,0 +1,25 @@
+name: Checks
+on: [ pull_request ]
+jobs:
+ tests:
+ name: Tests
+ uses: ./.github/workflows/test.yaml
+ lints:
+ name: Lints
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4.1.4
+ - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
+ - uses: auguwu/clippy-action@1.3.0
+ with:
+ token: ${{ secrets.GITHUB_TOKEN }}
+ permissions:
+ checks: write
+ formatting:
+ name: Formatting
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4.1.4
+ - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
+ - uses: actions-rust-lang/rustfmt@v1.1.0
+
.github/workflows/clippy_check.ymldiffbeforeafterboth--- a/.github/workflows/clippy_check.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-on: [push, pull_request]
-name: Clippy check
-jobs:
- clippy_check:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - uses: actions-rs/toolchain@v1
- with:
- toolchain: nightly-2023-10-28
- components: clippy
- override: true
- - uses: actions-rs/clippy-check@v1
- with:
- token: ${{ secrets.GITHUB_TOKEN }}
.github/workflows/release.yamldiffbeforeafterboth--- /dev/null
+++ b/.github/workflows/release.yaml
@@ -0,0 +1,140 @@
+name: Release
+on:
+ push:
+ tags: [ 'v*' ]
+jobs:
+ tests:
+ uses: ./.github/workflows/test.yaml
+
+ cargo-release:
+ if: !endsWith(github.ref, '-test')
+ needs: [ tests ]
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4.1.4
+ - name: Install stable toolchain
+ uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
+ with:
+ toolchain: stable
+ - run: cargo install cargo-release
+ - run: cargo login ${{ secrets.CARGO_TOKEN }}
+ - run: cargo release --no-dev-version --skip-push --skip-tag --no-confirm
+
+ github-release:
+ needs: [ tests ]
+ strategy:
+ matrix:
+ target:
+ # Linux build notes:
+ # While musl targets are not as supported as gnu, those are most relevant to users,
+ # which want to download binaries from github, as glibc has compatibility issues
+ # with older distros
+
+ # Tier 1
+ - i686-pc-windows-msvc
+ - x86_64-apple-darwin
+ - x86_64-pc-windows-msvc
+
+ # Tier 2
+ - aarch64-apple-darwin
+ - aarch64-unknown-linux-musl
+ - i686-unknown-linux-musl
+ - x86_64-unknown-linux-musl
+ include:
+ # Linux
+ - target: aarch64-unknown-linux-musl
+ os: ubuntu-latest
+ bin: jrsonnet
+ name: jrsonnet-linux-aarch64
+ - target: i686-unknown-linux-musl
+ os: ubuntu-latest
+ bin: jrsonnet
+ name: jrsonnet-linux-i686
+ - target: x86_64-unknown-linux-musl
+ os: ubuntu-latest
+ bin: jrsonnet
+ name: jrsonnet-linux-amd64
+
+ # Windows
+ - target: i686-pc-windows-msvc
+ os: windows-latest
+ bin: jrsonnet.exe
+ name: jrsonnet-windows-i686.exe
+ - target: x86_64-pc-windows-msvc
+ os: windows-latest
+ bin: jrsonnet.exe
+ name: jrsonnet-windows-amd64.exe
+
+ # Apple
+ - target: aarch64-apple-darwin
+ os: macOS-latest
+ bin: jrsonnet
+ name: jrsonnet-darwin-aarch64
+ - target: x86_64-apple-darwin
+ os: macOS-latest
+ bin: jrsonnet
+ name: jrsonnet-darwin-amd64
+ runs-on: ${{ matrix.os }}
+ steps:
+ - name: Fetch apt repo updates
+ if: ${{ startsWith(matrix.os, 'ubuntu-') }}
+ run: sudo apt update
+
+ - name: Install stable toolchain
+ uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
+ with:
+ toolchain: stable
+ target: ${{ matrix.target }}
+
+ - uses: actions/checkout@v4.1.4
+
+ - name: Add experimental flags
+ if: ${{ endsWith(github.ref, '-test' )}}
+ run: echo 'EXPERIMENTAL_FLAGS=--features=experimental' >> $GITHUB_ENV
+
+ - name: Linux x86 cross compiler
+ if: ${{ startsWith(matrix.target, 'i686-unknown-linux-') }}
+ run: sudo apt install gcc-multilib
+
+ - name: ARM cross compiler
+ if: ${{ startsWith(matrix.target, 'aarch64-unknown-linux-') }}
+ uses: actions-rs/cargo@v1
+ with:
+ command: install
+ args: cross
+
+ - name: ARM gcc
+ if: ${{ startsWith(matrix.target, 'aarch64-unknown-linux-') }}
+ run: sudo apt install gcc-aarch64-linux-gnu
+
+ - name: Musl gcc
+ if: ${{ endsWith(matrix.target, '-musl') }}
+ run: sudo apt install musl musl-tools
+
+ - name: Run cross build
+ if: ${{ startsWith(matrix.target, 'aarch64-unknown-linux-') }}
+ shell: bash
+ run: cross build --bin=jrsonnet --release --target ${{ matrix.target }} ${{ env.EXPERIMENTAL_FLAGS }}
+
+ - name: Run build
+ if: ${{ !startsWith(matrix.target, 'aarch64-unknown-linux-') }}
+ run: cargo build --bin=jrsonnet --release --target ${{ matrix.target }} ${{ env.EXPERIMENTAL_FLAGS }}
+
+ - name: Package
+ shell: bash
+ run: |
+ cd target/${{ matrix.target }}/release
+
+ cp ${{ matrix.bin }} ../../../${{ matrix.name }}
+ cd -
+
+ - name: Generate SHA-256
+ run: shasum -a 256 ${{ matrix.name }} > ${{ matrix.name }}.sha256
+
+ - name: Publish
+ uses: softprops/action-gh-release@v2.0.4
+ with:
+ draft: true
+ files: "jrsonnet*"
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
.github/workflows/release.ymldiffbeforeafterboth--- a/.github/workflows/release.yml
+++ /dev/null
@@ -1,172 +0,0 @@
-name: CI
-on: [push]
-jobs:
- test:
- name: Test Suite
- runs-on: ubuntu-latest
- steps:
- - name: Checkout sources
- uses: actions/checkout@v2
- - name: Install stable toolchain
- uses: actions-rs/toolchain@v1
- with:
- toolchain: stable
- override: true
- - name: Run tests
- uses: actions-rs/cargo@v1
- with:
- command: test
- args: --all
-
- cargo-release:
- if: startsWith(github.ref, 'refs/tags/') && !endsWith(github.ref, '-test')
- needs: [test]
- runs-on: ubuntu-latest
- steps:
- - name: Checkout sources
- uses: actions/checkout@v2
- - name: Install stable toolchain
- uses: actions-rs/toolchain@v1
- with:
- toolchain: stable
- override: true
- - name: Install cargo release command
- uses: actions-rs/cargo@v1
- with:
- command: install
- args: cargo-release
- - name: Run cargo login
- uses: actions-rs/cargo@v1
- with:
- command: login
- args: ${{ secrets.CARGO_TOKEN }}
- - name: Publish crates
- uses: actions-rs/cargo@v1
- with:
- command: release
- args: --no-dev-version --skip-push --skip-tag --no-confirm
-
- github-release:
- if: startsWith(github.ref, 'refs/tags/')
- needs: [test]
- strategy:
- matrix:
- target:
- # Linux build notes:
- # While musl targets are not as supported as gnu, those are most relevant to users,
- # which want to download binaries from github, as glibc has compatibility issues
- # with older distros
-
- # Tier 1
- - i686-pc-windows-msvc
- - x86_64-apple-darwin
- - x86_64-pc-windows-msvc
-
- # Tier 2
- - aarch64-apple-darwin
- - aarch64-unknown-linux-musl
- - i686-unknown-linux-musl
- - x86_64-unknown-linux-musl
- include:
- # Linux
- - target: aarch64-unknown-linux-musl
- os: ubuntu-latest
- bin: jrsonnet
- name: jrsonnet-linux-aarch64
- - target: i686-unknown-linux-musl
- os: ubuntu-latest
- bin: jrsonnet
- name: jrsonnet-linux-i686
- - target: x86_64-unknown-linux-musl
- os: ubuntu-latest
- bin: jrsonnet
- name: jrsonnet-linux-amd64
-
- # Windows
- - target: i686-pc-windows-msvc
- os: windows-latest
- bin: jrsonnet.exe
- name: jrsonnet-windows-i686.exe
- - target: x86_64-pc-windows-msvc
- os: windows-latest
- bin: jrsonnet.exe
- name: jrsonnet-windows-amd64.exe
-
- # Apple
- - target: aarch64-apple-darwin
- os: macOS-latest
- bin: jrsonnet
- name: jrsonnet-darwin-aarch64
- - target: x86_64-apple-darwin
- os: macOS-latest
- bin: jrsonnet
- name: jrsonnet-darwin-amd64
- runs-on: ${{ matrix.os }}
- steps:
- - name: Fetch apt repo updates
- if: ${{ startsWith(matrix.os, 'ubuntu-') }}
- run: sudo apt update
-
- - name: Install stable toolchain
- uses: actions-rs/toolchain@v1
- with:
- toolchain: stable
- override: true
- target: ${{ matrix.target }}
-
- - name: Checkout
- uses: actions/checkout@v2
-
- - name: Add experimental flags
- if: ${{ endsWith(github.ref, '-test' )}}
- run: echo 'EXPERIMENTAL_FLAGS=--features=experimental' >> $GITHUB_ENV
-
- - name: Linux x86 cross compiler
- if: ${{ startsWith(matrix.target, 'i686-unknown-linux-') }}
- run: sudo apt install gcc-multilib
-
- - name: ARM cross compiler
- if: ${{ startsWith(matrix.target, 'aarch64-unknown-linux-') }}
- uses: actions-rs/cargo@v1
- with:
- command: install
- args: cross
-
- - name: ARM gcc
- if: ${{ startsWith(matrix.target, 'aarch64-unknown-linux-') }}
- run: sudo apt install gcc-aarch64-linux-gnu
-
- - name: Musl gcc
- if: ${{ endsWith(matrix.target, '-musl') }}
- run: sudo apt install musl musl-tools
-
- - name: Run cross build
- if: ${{ startsWith(matrix.target, 'aarch64-unknown-linux-') }}
- shell: bash
- run: cross build --bin=jrsonnet --release --target ${{ matrix.target }} ${{ env.EXPERIMENTAL_FLAGS }}
-
- - name: Run build
- if: ${{ !startsWith(matrix.target, 'aarch64-unknown-linux-') }}
- uses: actions-rs/cargo@v1
- with:
- command: build
- args: --bin=jrsonnet --release --target ${{ matrix.target }} ${{ env.EXPERIMENTAL_FLAGS }}
-
- - name: Package
- shell: bash
- run: |
- cd target/${{ matrix.target }}/release
-
- cp ${{ matrix.bin }} ../../../${{ matrix.name }}
- cd -
-
- - name: Generate SHA-256
- run: shasum -a 256 ${{ matrix.name }} > ${{ matrix.name }}.sha256
-
- - name: Publish
- uses: softprops/action-gh-release@v1
- with:
- draft: true
- files: "jrsonnet*"
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
.github/workflows/test.yamldiffbeforeafterboth--- /dev/null
+++ b/.github/workflows/test.yaml
@@ -0,0 +1,21 @@
+name: Test
+on: [ workflow_call ]
+jobs:
+ test:
+ name: Test
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4.1.4
+ - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
+ - run: cargo test --all
+ test-stable:
+ name: Test on stable
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4.1.4
+ - name: Install the latest stable toolchain
+ uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
+ with:
+ toolchain: stable
+ - run: cargo test --all
+
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4,9 +4,9 @@
[[package]]
name = "ahash"
-version = "0.8.9"
+version = "0.8.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d713b3834d76b85304d4d525563c1276e2e30dc97cc67bfb4585a4a29fc2c89f"
+checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011"
dependencies = [
"cfg-if",
"once_cell",
@@ -16,24 +16,24 @@
[[package]]
name = "aho-corasick"
-version = "1.1.2"
+version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"
+checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]
[[package]]
name = "allocator-api2"
-version = "0.2.16"
+version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
+checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
[[package]]
name = "annotate-snippets"
-version = "0.10.1"
+version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0a433302f833baa830c0092100c481c7ea768c5981a3c36f549517a502f246dd"
+checksum = "6d9b665789884a7e8fb06c84b295e923b03ca51edbb7d08f91a6a50322ecbfe6"
dependencies = [
"anstyle",
"unicode-width",
@@ -41,47 +41,48 @@
[[package]]
name = "anstream"
-version = "0.6.12"
+version = "0.6.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "96b09b5178381e0874812a9b157f7fe84982617e48f71f4e3235482775e5b540"
+checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
+ "is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
-version = "1.0.6"
+version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc"
+checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b"
[[package]]
name = "anstyle-parse"
-version = "0.2.3"
+version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c"
+checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
-version = "1.0.2"
+version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648"
+checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5"
dependencies = [
"windows-sys",
]
[[package]]
name = "anstyle-wincon"
-version = "3.0.2"
+version = "3.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7"
+checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19"
dependencies = [
"anstyle",
"windows-sys",
@@ -89,15 +90,15 @@
[[package]]
name = "anyhow"
-version = "1.0.80"
+version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1"
+checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3"
[[package]]
name = "autocfg"
-version = "1.1.0"
+version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
+checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
[[package]]
name = "base64"
@@ -122,15 +123,9 @@
[[package]]
name = "bitflags"
-version = "1.3.2"
+version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
-
-[[package]]
-name = "bitflags"
-version = "2.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf"
+checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
[[package]]
name = "block-buffer"
@@ -143,18 +138,15 @@
[[package]]
name = "bumpalo"
-version = "3.15.1"
+version = "3.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c764d619ca78fccbf3069b37bd7af92577f044bb15236036662d79b6559f25b7"
+checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
[[package]]
name = "cc"
-version = "1.0.83"
+version = "1.0.97"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
-dependencies = [
- "libc",
-]
+checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4"
[[package]]
name = "cfg-if"
@@ -164,9 +156,9 @@
[[package]]
name = "clap"
-version = "4.5.1"
+version = "4.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da"
+checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0"
dependencies = [
"clap_builder",
"clap_derive",
@@ -174,9 +166,9 @@
[[package]]
name = "clap_builder"
-version = "4.5.1"
+version = "4.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb"
+checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4"
dependencies = [
"anstream",
"anstyle",
@@ -186,23 +178,23 @@
[[package]]
name = "clap_complete"
-version = "4.5.1"
+version = "4.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "885e4d7d5af40bfb99ae6f9433e292feac98d452dcb3ec3d25dfe7552b77da8c"
+checksum = "dd79504325bf38b10165b02e89b4347300f855f273c4cb30c4a3209e6583275e"
dependencies = [
"clap",
]
[[package]]
name = "clap_derive"
-version = "4.5.0"
+version = "4.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47"
+checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64"
dependencies = [
"heck",
"proc-macro2",
"quote",
- "syn 2.0.50",
+ "syn 2.0.61",
]
[[package]]
@@ -213,9 +205,9 @@
[[package]]
name = "colorchoice"
-version = "1.0.0"
+version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
+checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422"
[[package]]
name = "console"
@@ -283,7 +275,7 @@
dependencies = [
"anyhow",
"bumpalo",
- "indexmap 2.2.3",
+ "indexmap 2.2.6",
"rustc-hash",
"serde",
"unicode-width",
@@ -297,9 +289,9 @@
[[package]]
name = "either"
-version = "1.10.0"
+version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a"
+checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2"
[[package]]
name = "encode_unicode"
@@ -315,9 +307,9 @@
[[package]]
name = "errno"
-version = "0.3.8"
+version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245"
+checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
dependencies = [
"libc",
"windows-sys",
@@ -325,9 +317,9 @@
[[package]]
name = "fastrand"
-version = "2.0.1"
+version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
+checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a"
[[package]]
name = "fnv"
@@ -347,9 +339,9 @@
[[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",
"libc",
@@ -364,9 +356,9 @@
[[package]]
name = "hashbrown"
-version = "0.14.3"
+version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
+checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
dependencies = [
"ahash",
"allocator-api2",
@@ -374,9 +366,9 @@
[[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 = "hi-doc"
@@ -403,35 +395,40 @@
[[package]]
name = "indexmap"
-version = "2.2.3"
+version = "2.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177"
+checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
dependencies = [
"equivalent",
- "hashbrown 0.14.3",
+ "hashbrown 0.14.5",
"serde",
]
[[package]]
name = "indoc"
-version = "2.0.4"
+version = "2.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8"
+checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5"
[[package]]
name = "insta"
-version = "1.35.1"
+version = "1.38.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7c985c1bef99cf13c58fade470483d81a2bfe846ebde60ed28cc2dddec2df9e2"
+checksum = "3eab73f58e59ca6526037208f0e98851159ec1633cf17b6cd2e1f2c3fd5d53cc"
dependencies = [
"console",
"lazy_static",
"linked-hash-map",
"similar",
- "yaml-rust",
]
[[package]]
+name = "is_terminal_polyfill"
+version = "1.70.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800"
+
+[[package]]
name = "itertools"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -442,9 +439,9 @@
[[package]]
name = "itoa"
-version = "1.0.10"
+version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
+checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
[[package]]
name = "jrsonnet"
@@ -482,7 +479,7 @@
"anyhow",
"bincode",
"derivative",
- "hashbrown 0.14.3",
+ "hashbrown 0.14.5",
"hi-doc",
"jrsonnet-gcmodule",
"jrsonnet-interner",
@@ -537,7 +534,7 @@
name = "jrsonnet-interner"
version = "0.5.0-pre96"
dependencies = [
- "hashbrown 0.14.3",
+ "hashbrown 0.14.5",
"jrsonnet-gcmodule",
"rustc-hash",
"serde",
@@ -550,7 +547,7 @@
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.50",
+ "syn 2.0.61",
]
[[package]]
@@ -627,9 +624,9 @@
[[package]]
name = "libc"
-version = "0.2.153"
+version = "0.2.154"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
+checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
[[package]]
name = "libjsonnet"
@@ -655,9 +652,9 @@
[[package]]
name = "lock_api"
-version = "0.4.11"
+version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45"
+checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
dependencies = [
"autocfg",
"scopeguard",
@@ -684,7 +681,7 @@
"proc-macro2",
"quote",
"regex-syntax",
- "syn 2.0.50",
+ "syn 2.0.61",
]
[[package]]
@@ -698,11 +695,11 @@
[[package]]
name = "lru"
-version = "0.12.2"
+version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "db2c024b41519440580066ba82aab04092b333e09066a5eb86c7c4890df31f22"
+checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc"
dependencies = [
- "hashbrown 0.14.3",
+ "hashbrown 0.14.5",
]
[[package]]
@@ -713,15 +710,15 @@
[[package]]
name = "memchr"
-version = "2.7.1"
+version = "2.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
+checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
[[package]]
name = "memoffset"
-version = "0.9.0"
+version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c"
+checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
dependencies = [
"autocfg",
]
@@ -747,11 +744,10 @@
[[package]]
name = "num-bigint"
-version = "0.4.4"
+version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0"
+checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7"
dependencies = [
- "autocfg",
"num-integer",
"num-traits",
"serde",
@@ -768,9 +764,9 @@
[[package]]
name = "num-traits"
-version = "0.2.18"
+version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a"
+checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
dependencies = [
"autocfg",
]
@@ -783,9 +779,9 @@
[[package]]
name = "parking_lot"
-version = "0.12.1"
+version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
+checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb"
dependencies = [
"lock_api",
"parking_lot_core",
@@ -793,15 +789,15 @@
[[package]]
name = "parking_lot_core"
-version = "0.9.9"
+version = "0.9.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e"
+checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
- "windows-targets 0.48.5",
+ "windows-targets",
]
[[package]]
@@ -812,9 +808,9 @@
[[package]]
name = "peg"
-version = "0.8.2"
+version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "400bcab7d219c38abf8bd7cc2054eb9bbbd4312d66f6a5557d572a203f646f61"
+checksum = "8a625d12ad770914cbf7eff6f9314c3ef803bfe364a1b20bc36ddf56673e71e5"
dependencies = [
"peg-macros",
"peg-runtime",
@@ -822,9 +818,9 @@
[[package]]
name = "peg-macros"
-version = "0.8.2"
+version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "46e61cce859b76d19090f62da50a9fe92bab7c2a5f09e183763559a2ac392c90"
+checksum = "f241d42067ed3ab6a4fece1db720838e1418f36d868585a27931f95d6bc03582"
dependencies = [
"peg-runtime",
"proc-macro2",
@@ -833,9 +829,9 @@
[[package]]
name = "peg-runtime"
-version = "0.8.2"
+version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "36bae92c60fa2398ce4678b98b2c4b5a7c61099961ca1fa305aec04a9ad28922"
+checksum = "e3aeb8f54c078314c2065ee649a7241f46b9d8e418e1a9581ba0546657d7aa3a"
[[package]]
name = "ppv-lite86"
@@ -845,18 +841,18 @@
[[package]]
name = "proc-macro2"
-version = "1.0.78"
+version = "1.0.82"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae"
+checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
-version = "1.0.35"
+version = "1.0.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
+checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
dependencies = [
"proc-macro2",
]
@@ -911,18 +907,18 @@
[[package]]
name = "redox_syscall"
-version = "0.4.1"
+version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
+checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e"
dependencies = [
- "bitflags 1.3.2",
+ "bitflags",
]
[[package]]
name = "regex"
-version = "1.10.3"
+version = "1.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15"
+checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
dependencies = [
"aho-corasick",
"memchr",
@@ -932,9 +928,9 @@
[[package]]
name = "regex-automata"
-version = "0.4.5"
+version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd"
+checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea"
dependencies = [
"aho-corasick",
"memchr",
@@ -943,9 +939,9 @@
[[package]]
name = "regex-syntax"
-version = "0.8.2"
+version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
+checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
[[package]]
name = "rowan"
@@ -954,7 +950,7 @@
checksum = "32a58fa8a7ccff2aec4f39cc45bf5f985cec7125ab271cf681c279fd00192b49"
dependencies = [
"countme",
- "hashbrown 0.14.3",
+ "hashbrown 0.14.5",
"memoffset",
"rustc-hash",
"text-size",
@@ -968,11 +964,11 @@
[[package]]
name = "rustix"
-version = "0.38.31"
+version = "0.38.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949"
+checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
dependencies = [
- "bitflags 2.4.2",
+ "bitflags",
"errno",
"libc",
"linux-raw-sys",
@@ -981,9 +977,9 @@
[[package]]
name = "ryu"
-version = "1.0.17"
+version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1"
+checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
[[package]]
name = "scopeguard"
@@ -993,29 +989,29 @@
[[package]]
name = "serde"
-version = "1.0.197"
+version = "1.0.201"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2"
+checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.197"
+version = "1.0.201"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
+checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.50",
+ "syn 2.0.61",
]
[[package]]
name = "serde_json"
-version = "1.0.114"
+version = "1.0.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0"
+checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3"
dependencies = [
"itoa",
"ryu",
@@ -1068,9 +1064,9 @@
[[package]]
name = "similar"
-version = "2.4.0"
+version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "32fea41aca09ee824cc9724996433064c89f7777e60762749a4170a14abbfa21"
+checksum = "fa42c91313f1d05da9b26f267f931cf178d4aba455b4c4622dd7355eb80c6640"
[[package]]
name = "smallvec"
@@ -1086,9 +1082,9 @@
[[package]]
name = "strsim"
-version = "0.11.0"
+version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01"
+checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "structdump"
@@ -1125,9 +1121,9 @@
[[package]]
name = "syn"
-version = "2.0.50"
+version = "2.0.61"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "74f1bdc9872430ce9b75da68329d1c1746faf50ffac5f19e02b71e37ff881ffb"
+checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9"
dependencies = [
"proc-macro2",
"quote",
@@ -1136,9 +1132,9 @@
[[package]]
name = "tempfile"
-version = "3.10.0"
+version = "3.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67"
+checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1"
dependencies = [
"cfg-if",
"fastrand",
@@ -1164,22 +1160,22 @@
[[package]]
name = "thiserror"
-version = "1.0.57"
+version = "1.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b"
+checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
-version = "1.0.57"
+version = "1.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81"
+checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.50",
+ "syn 2.0.61",
]
[[package]]
@@ -1202,9 +1198,9 @@
[[package]]
name = "unicode-width"
-version = "0.1.11"
+version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
+checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6"
[[package]]
name = "utf8parse"
@@ -1230,144 +1226,94 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
- "windows-targets 0.52.0",
+ "windows-targets",
]
[[package]]
name = "windows-targets"
-version = "0.48.5"
+version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
+checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb"
dependencies = [
- "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.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
-dependencies = [
- "windows_aarch64_gnullvm 0.52.0",
- "windows_aarch64_msvc 0.52.0",
- "windows_i686_gnu 0.52.0",
- "windows_i686_msvc 0.52.0",
- "windows_x86_64_gnu 0.52.0",
- "windows_x86_64_gnullvm 0.52.0",
- "windows_x86_64_msvc 0.52.0",
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_gnullvm",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
-version = "0.48.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
-
-[[package]]
-name = "windows_aarch64_gnullvm"
-version = "0.52.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
-
-[[package]]
-name = "windows_aarch64_msvc"
-version = "0.48.5"
+version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
+checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
[[package]]
name = "windows_aarch64_msvc"
-version = "0.52.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
-
-[[package]]
-name = "windows_i686_gnu"
-version = "0.48.5"
+version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
+checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
[[package]]
name = "windows_i686_gnu"
-version = "0.52.0"
+version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
+checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670"
[[package]]
-name = "windows_i686_msvc"
-version = "0.48.5"
+name = "windows_i686_gnullvm"
+version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
+checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9"
[[package]]
name = "windows_i686_msvc"
-version = "0.52.0"
+version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
-
-[[package]]
-name = "windows_x86_64_gnu"
-version = "0.48.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
+checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf"
[[package]]
name = "windows_x86_64_gnu"
-version = "0.52.0"
+version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
+checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9"
[[package]]
name = "windows_x86_64_gnullvm"
-version = "0.48.5"
+version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
-
-[[package]]
-name = "windows_x86_64_gnullvm"
-version = "0.52.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
-
-[[package]]
-name = "windows_x86_64_msvc"
-version = "0.48.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
+checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
[[package]]
name = "windows_x86_64_msvc"
-version = "0.52.0"
+version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
+checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
[[package]]
name = "xshell"
-version = "0.2.5"
+version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ce2107fe03e558353b4c71ad7626d58ed82efaf56c54134228608893c77023ad"
+checksum = "6db0ab86eae739efd1b054a8d3d16041914030ac4e01cd1dca0cf252fd8b6437"
dependencies = [
"xshell-macros",
]
[[package]]
name = "xshell-macros"
-version = "0.2.5"
+version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7e2c411759b501fb9501aac2b1b2d287a6e93e5bdcf13c25306b23e1b716dd0e"
+checksum = "9d422e8e38ec76e2f06ee439ccc765e9c6a9638b9e7c9f2e8255e4d41e8bd852"
[[package]]
name = "xtask"
version = "0.1.0"
dependencies = [
"anyhow",
- "indexmap 2.2.3",
+ "indexmap 2.2.6",
"itertools",
"proc-macro2",
"quote",
@@ -1386,20 +1332,20 @@
[[package]]
name = "zerocopy"
-version = "0.7.32"
+version = "0.7.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be"
+checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
-version = "0.7.32"
+version = "0.7.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
+checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.50",
+ "syn 2.0.61",
]
cmds/jrsonnet-fmt/src/tests.rsdiffbeforeafterboth--- a/cmds/jrsonnet-fmt/src/tests.rs
+++ b/cmds/jrsonnet-fmt/src/tests.rs
@@ -23,7 +23,7 @@
#[test]
fn complex_comments_snapshot() {
- insta::assert_display_snapshot!(reformat(indoc!(
+ insta::assert_snapshot!(reformat(indoc!(
"{
comments: {
_: '',
crates/jrsonnet-cli/src/tla.rsdiffbeforeafterboth--- a/crates/jrsonnet-cli/src/tla.rs
+++ b/crates/jrsonnet-cli/src/tla.rs
@@ -14,7 +14,7 @@
pub struct TlaOpts {
/// Add top level string argument.
/// Top level arguments will be passed to function before manifestification stage.
- /// This is preferred to ExtVars method.
+ /// This is preferred to [`ExtVars`] method.
/// If [=data] is not set then it will be read from `name` env variable.
#[clap(long, short = 'A', name = "name[=tla data]", number_of_values = 1)]
tla_str: Vec<ExtStr>,
crates/jrsonnet-evaluator/src/arr/mod.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/arr/mod.rs
+++ b/crates/jrsonnet-evaluator/src/arr/mod.rs
@@ -7,8 +7,7 @@
use crate::{function::FuncVal, gc::TraceBox, tb, Context, Result, Thunk, Val};
mod spec;
-pub use spec::ArrayLike;
-pub(crate) use spec::*;
+pub use spec::{ArrayLike, *};
/// Represents a Jsonnet array value.
#[derive(Debug, Clone, Trace)]
crates/jrsonnet-evaluator/src/function/arglike.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/function/arglike.rs
+++ b/crates/jrsonnet-evaluator/src/function/arglike.rs
@@ -76,13 +76,6 @@
}
}
-mod sealed {
- /// Implemented for `ArgsLike`, where only unnamed arguments present
- pub trait Unnamed {}
- /// Implemented for `ArgsLike`, where only named arguments present
- pub trait Named {}
-}
-
pub trait ArgsLike {
fn unnamed_len(&self) -> usize;
fn unnamed_iter(
@@ -182,7 +175,6 @@
}
}
-impl<V: ArgLike, S> sealed::Named for HashMap<IStr, V, S> {}
impl<V: ArgLike, S> ArgsLike for HashMap<IStr, V, S> {
fn unnamed_len(&self) -> usize {
0
@@ -247,7 +239,6 @@
macro_rules! impl_args_like {
($count:expr; $($gen:ident)*) => {
- impl<$($gen: ArgLike,)*> sealed::Unnamed for ($($gen,)*) {}
impl<$($gen: ArgLike,)*> ArgsLike for ($($gen,)*) {
fn unnamed_len(&self) -> usize {
$count
@@ -279,7 +270,6 @@
}
impl<$($gen: ArgLike,)*> OptionalContext for ($($gen,)*) where $($gen: OptionalContext),* {}
- impl<$($gen: ArgLike,)*> sealed::Named for ($((IStr, $gen),)*) {}
impl<$($gen: ArgLike,)*> ArgsLike for ($((IStr, $gen),)*) {
fn unnamed_len(&self) -> usize {
0
crates/jrsonnet-evaluator/src/integrations/serde.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/integrations/serde.rs
+++ b/crates/jrsonnet-evaluator/src/integrations/serde.rs
@@ -346,9 +346,9 @@
type Ok = Val;
type Error = JrError;
- fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<()>
+ fn serialize_key<T>(&mut self, key: &T) -> Result<()>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let key = key.serialize(IntoValSerializer)?;
let key = key.to_string()?;
@@ -356,9 +356,9 @@
Ok(())
}
- fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<()>
+ fn serialize_value<T>(&mut self, value: &T) -> Result<()>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let key = self.key.take().expect("no serialize_key called");
let value = value.serialize(IntoValSerializer)?;
@@ -367,10 +367,10 @@
}
// TODO: serialize_key/serialize_value
- fn serialize_entry<K: ?Sized, V: ?Sized>(&mut self, key: &K, value: &V) -> Result<()>
+ fn serialize_entry<K, V>(&mut self, key: &K, value: &V) -> Result<()>
where
- K: Serialize,
- V: Serialize,
+ K: ?Sized + Serialize,
+ V: ?Sized + Serialize,
{
let key = key.serialize(IntoValSerializer)?;
let key = key.to_string()?;
@@ -394,9 +394,9 @@
type Ok = Val;
type Error = JrError;
- fn serialize_field<T: ?Sized>(&mut self, key: &'static str, value: &T) -> Result<()>
+ fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<()>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
SerializeMap::serialize_entry(self, key, value)?;
Ok(())
@@ -411,9 +411,9 @@
type Error = JrError;
- fn serialize_field<T: ?Sized>(&mut self, key: &'static str, value: &T) -> Result<()>
+ fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<()>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
SerializeMap::serialize_entry(self, key, value)?;
Ok(())
@@ -504,9 +504,9 @@
Ok(Val::Null)
}
- fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Val>
+ fn serialize_some<T>(self, value: &T) -> Result<Val>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
value.serialize(self)
}
@@ -528,14 +528,14 @@
Ok(Val::Str(variant.into()))
}
- fn serialize_newtype_struct<T: ?Sized>(self, _name: &'static str, value: &T) -> Result<Val>
+ fn serialize_newtype_struct<T>(self, _name: &'static str, value: &T) -> Result<Val>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
value.serialize(self)
}
- fn serialize_newtype_variant<T: ?Sized>(
+ fn serialize_newtype_variant<T>(
self,
_name: &'static str,
_variant_index: u32,
@@ -543,7 +543,7 @@
value: &T,
) -> Result<Val>
where
- T: Serialize,
+ T: ?Sized + Serialize,
{
let mut out = ObjValue::builder_with_capacity(1);
let value = value.serialize(self)?;
crates/jrsonnet-evaluator/src/manifest.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/manifest.rs
+++ b/crates/jrsonnet-evaluator/src/manifest.rs
@@ -1,4 +1,4 @@
-use std::{borrow::Cow, fmt::Write};
+use std::{borrow::Cow, fmt::Write, ptr};
use crate::{bail, Result, ResultExt, State, Val};
@@ -404,7 +404,7 @@
pub fn escape_string_json_buf(value: &str, buf: &mut String) {
// Safety: we only write correct utf-8 in this function
- let buf: &mut Vec<u8> = unsafe { &mut *(buf as *mut String).cast::<Vec<u8>>() };
+ let buf: &mut Vec<u8> = unsafe { &mut *ptr::from_mut(buf).cast::<Vec<u8>>() };
let bytes = value.as_bytes();
// Perfect for ascii strings, removes any reallocations
crates/jrsonnet-evaluator/src/obj.rsdiffbeforeafterboth1use std::{2 any::Any,3 cell::RefCell,4 fmt::Debug,5 hash::{Hash, Hasher},6 ptr::addr_of,7};89use jrsonnet_gcmodule::{Cc, Trace, Weak};10use jrsonnet_interner::IStr;11use jrsonnet_parser::{ExprLocation, Visibility};12use rustc_hash::FxHashMap;1314use crate::{15 arr::{PickObjectKeyValues, PickObjectValues},16 bail,17 error::{suggest_object_fields, Error, ErrorKind::*},18 function::{CallLocation, FuncVal},19 gc::{GcHashMap, GcHashSet, TraceBox},20 operator::evaluate_add_op,21 tb,22 val::{ArrValue, ThunkValue},23 MaybeUnbound, Result, State, Thunk, Unbound, Val,24};2526#[cfg(not(feature = "exp-preserve-order"))]27mod ordering {28 #![allow(29 // This module works as stub for preserve-order feature30 clippy::unused_self,31 )]3233 use jrsonnet_gcmodule::Trace;3435 #[derive(Clone, Copy, Default, Debug, Trace)]36 pub struct FieldIndex(());37 impl FieldIndex {38 pub const fn next(self) -> Self {39 Self(())40 }41 }4243 #[derive(Clone, Copy, Default, Debug, Trace)]44 pub struct SuperDepth(());45 impl SuperDepth {46 pub const fn deeper(self) -> Self {47 Self(())48 }49 }5051 #[derive(Clone, Copy)]52 pub struct FieldSortKey(());53 impl FieldSortKey {54 pub const fn new(_: SuperDepth, _: FieldIndex) -> Self {55 Self(())56 }57 }58}5960#[cfg(feature = "exp-preserve-order")]61mod ordering {62 use std::cmp::Reverse;6364 use jrsonnet_gcmodule::Trace;6566 #[derive(Clone, Copy, Default, Debug, Trace, PartialEq, Eq, PartialOrd, Ord)]67 pub struct FieldIndex(u32);68 impl FieldIndex {69 pub fn next(self) -> Self {70 Self(self.0 + 1)71 }72 }7374 #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Debug)]75 pub struct SuperDepth(u32);76 impl SuperDepth {77 pub fn deeper(self) -> Self {78 Self(self.0 + 1)79 }80 }8182 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]83 pub struct FieldSortKey(Reverse<SuperDepth>, FieldIndex);84 impl FieldSortKey {85 pub fn new(depth: SuperDepth, index: FieldIndex) -> Self {86 Self(Reverse(depth), index)87 }88 }89}9091use ordering::*;9293// 0 - add94// 12 - visibility95#[derive(Clone, Copy)]96pub struct ObjFieldFlags(u8);97impl ObjFieldFlags {98 fn new(add: bool, visibility: Visibility) -> Self {99 let mut v = 0;100 if add {101 v |= 1;102 }103 v |= match visibility {104 Visibility::Normal => 0b000,105 Visibility::Hidden => 0b010,106 Visibility::Unhide => 0b100,107 };108 Self(v)109 }110 pub fn add(&self) -> bool {111 self.0 & 1 != 0112 }113 pub fn visibility(&self) -> Visibility {114 match (self.0 & 0b110) >> 1 {115 0b00 => Visibility::Normal,116 0b01 => Visibility::Hidden,117 0b10 => Visibility::Unhide,118 _ => unreachable!(),119 }120 }121}122impl Debug for ObjFieldFlags {123 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {124 f.debug_struct("ObjFieldFlags")125 .field("add", &self.add())126 .field("visibility", &self.visibility())127 .finish()128 }129}130131#[allow(clippy::module_name_repetitions)]132#[derive(Debug, Trace)]133pub struct ObjMember {134 #[trace(skip)]135 flags: ObjFieldFlags,136 original_index: FieldIndex,137 pub invoke: MaybeUnbound,138 pub location: Option<ExprLocation>,139}140141pub trait ObjectAssertion: Trace {142 fn run(&self, super_obj: Option<ObjValue>, this: Option<ObjValue>) -> Result<()>;143}144145// Field => This146147#[derive(Trace)]148enum CacheValue {149 Cached(Val),150 NotFound,151 Pending,152 Errored(Error),153}154155#[allow(clippy::module_name_repetitions)]156#[derive(Trace)]157#[trace(tracking(force))]158pub struct OopObject {159 sup: Option<ObjValue>,160 // this: Option<ObjValue>,161 assertions: Cc<Vec<TraceBox<dyn ObjectAssertion>>>,162 assertions_ran: RefCell<GcHashSet<ObjValue>>,163 this_entries: Cc<GcHashMap<IStr, ObjMember>>,164 value_cache: RefCell<GcHashMap<(IStr, Option<WeakObjValue>), CacheValue>>,165}166impl Debug for OopObject {167 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {168 f.debug_struct("OopObject")169 .field("sup", &self.sup)170 // .field("assertions", &self.assertions)171 // .field("assertions_ran", &self.assertions_ran)172 .field("this_entries", &self.this_entries)173 // .field("value_cache", &self.value_cache)174 .finish_non_exhaustive()175 }176}177178type EnumFieldsHandler<'a> = dyn FnMut(SuperDepth, FieldIndex, IStr, Visibility) -> bool + 'a;179180pub trait ObjectLike: Trace + Any + Debug {181 fn extend_from(&self, sup: ObjValue) -> ObjValue;182 /// When using standalone super in object, `this.super_obj.with_this(this)` is executed183 fn with_this(&self, me: ObjValue, this: ObjValue) -> ObjValue {184 ObjValue::new(ThisOverride { inner: me, this })185 }186 fn this(&self) -> Option<ObjValue> {187 None188 }189 fn len(&self) -> usize;190 fn is_empty(&self) -> bool;191 // If callback returns false, iteration stops192 fn enum_fields(&self, depth: SuperDepth, handler: &mut EnumFieldsHandler<'_>) -> bool;193194 fn has_field_include_hidden(&self, name: IStr) -> bool;195 fn has_field(&self, name: IStr) -> bool;196197 fn get_for(&self, key: IStr, this: ObjValue) -> Result<Option<Val>>;198 fn get_for_uncached(&self, key: IStr, this: ObjValue) -> Result<Option<Val>>;199 fn field_visibility(&self, field: IStr) -> Option<Visibility>;200201 fn run_assertions_raw(&self, this: ObjValue) -> Result<()>;202}203204#[derive(Clone, Trace)]205pub struct WeakObjValue(#[trace(skip)] pub(crate) Weak<TraceBox<dyn ObjectLike>>);206207impl PartialEq for WeakObjValue {208 fn eq(&self, other: &Self) -> bool {209 Weak::ptr_eq(&self.0, &other.0)210 }211}212213impl Eq for WeakObjValue {}214impl Hash for WeakObjValue {215 fn hash<H: Hasher>(&self, hasher: &mut H) {216 // Safety: usize is POD217 let addr = unsafe { *std::ptr::addr_of!(self.0).cast() };218 hasher.write_usize(addr);219 }220}221222#[allow(clippy::module_name_repetitions)]223#[derive(Clone, Trace, Debug)]224pub struct ObjValue(pub(crate) Cc<TraceBox<dyn ObjectLike>>);225226#[derive(Debug, Trace)]227struct EmptyObject;228impl ObjectLike for EmptyObject {229 fn extend_from(&self, sup: ObjValue) -> ObjValue {230 // obj + {} == obj231 sup232 }233234 fn this(&self) -> Option<ObjValue> {235 None236 }237238 fn len(&self) -> usize {239 0240 }241242 fn is_empty(&self) -> bool {243 true244 }245246 fn enum_fields(&self, _depth: SuperDepth, _handler: &mut EnumFieldsHandler<'_>) -> bool {247 false248 }249250 fn has_field_include_hidden(&self, _name: IStr) -> bool {251 false252 }253254 fn has_field(&self, _name: IStr) -> bool {255 false256 }257258 fn get_for(&self, _key: IStr, _this: ObjValue) -> Result<Option<Val>> {259 Ok(None)260 }261 fn get_for_uncached(&self, _key: IStr, _this: ObjValue) -> Result<Option<Val>> {262 Ok(None)263 }264265 fn run_assertions_raw(&self, _this: ObjValue) -> Result<()> {266 Ok(())267 }268269 fn field_visibility(&self, _field: IStr) -> Option<Visibility> {270 None271 }272}273274#[derive(Trace, Debug)]275struct ThisOverride {276 inner: ObjValue,277 this: ObjValue,278}279impl ObjectLike for ThisOverride {280 fn with_this(&self, _me: ObjValue, this: ObjValue) -> ObjValue {281 ObjValue::new(Self {282 inner: self.inner.clone(),283 this,284 })285 }286287 fn extend_from(&self, sup: ObjValue) -> ObjValue {288 self.inner.extend_from(sup).with_this(self.this.clone())289 }290291 fn this(&self) -> Option<ObjValue> {292 Some(self.this.clone())293 }294295 fn len(&self) -> usize {296 self.inner.len()297 }298299 fn is_empty(&self) -> bool {300 self.inner.is_empty()301 }302303 fn enum_fields(&self, depth: SuperDepth, handler: &mut EnumFieldsHandler<'_>) -> bool {304 self.inner.enum_fields(depth, handler)305 }306307 fn has_field_include_hidden(&self, name: IStr) -> bool {308 self.inner.has_field_include_hidden(name)309 }310311 fn has_field(&self, name: IStr) -> bool {312 self.inner.has_field(name)313 }314315 fn get_for(&self, key: IStr, this: ObjValue) -> Result<Option<Val>> {316 self.inner.get_for(key, this)317 }318319 fn get_for_uncached(&self, key: IStr, this: ObjValue) -> Result<Option<Val>> {320 self.inner.get_raw(key, this)321 }322323 fn field_visibility(&self, field: IStr) -> Option<Visibility> {324 self.inner.field_visibility(field)325 }326327 fn run_assertions_raw(&self, this: ObjValue) -> Result<()> {328 self.inner.run_assertions_raw(this)329 }330}331332impl ObjValue {333 pub fn new(v: impl ObjectLike) -> Self {334 Self(Cc::new(tb!(v)))335 }336 pub fn new_empty() -> Self {337 Self::new(EmptyObject)338 }339 pub fn builder() -> ObjValueBuilder {340 ObjValueBuilder::new()341 }342 pub fn builder_with_capacity(capacity: usize) -> ObjValueBuilder {343 ObjValueBuilder::with_capacity(capacity)344 }345 pub(crate) fn extend_with_raw_member(self, key: IStr, value: ObjMember) -> Self {346 let mut out = ObjValueBuilder::with_capacity(1);347 out.with_super(self);348 let mut member = out.field(key);349 if value.flags.add() {350 member = member.add();351 }352 if let Some(loc) = value.location {353 member = member.with_location(loc);354 }355 let _ = member356 .with_visibility(value.flags.visibility())357 .binding(value.invoke);358 out.build()359 }360 pub fn extend_field(&mut self, name: IStr) -> ObjMemberBuilder<ExtendBuilder<'_>> {361 ObjMemberBuilder::new(ExtendBuilder(self), name, FieldIndex::default())362 }363364 #[must_use]365 pub fn extend_from(&self, sup: Self) -> Self {366 self.0.extend_from(sup)367 }368 #[must_use]369 pub fn with_this(&self, this: Self) -> Self {370 self.0.with_this(self.clone(), this)371 }372 pub fn len(&self) -> usize {373 self.0.len()374 }375 pub fn is_empty(&self) -> bool {376 self.0.is_empty()377 }378 pub fn enum_fields(&self, depth: SuperDepth, handler: &mut EnumFieldsHandler<'_>) -> bool {379 self.0.enum_fields(depth, handler)380 }381382 pub fn has_field_include_hidden(&self, name: IStr) -> bool {383 self.0.has_field_include_hidden(name)384 }385 pub fn has_field(&self, name: IStr) -> bool {386 self.0.has_field(name)387 }388 pub fn has_field_ex(&self, name: IStr, include_hidden: bool) -> bool {389 if include_hidden {390 self.has_field_include_hidden(name)391 } else {392 self.has_field(name)393 }394 }395396 pub fn get(&self, key: IStr) -> Result<Option<Val>> {397 self.run_assertions()?;398 self.get_for(key, self.0.this().unwrap_or_else(|| self.clone()))399 }400401 pub fn get_for(&self, key: IStr, this: Self) -> Result<Option<Val>> {402 self.0.get_for(key, this)403 }404405 pub fn get_or_bail(&self, key: IStr) -> Result<Val> {406 let Some(value) = self.get(key.clone())? else {407 let suggestions = suggest_object_fields(self, key.clone());408 bail!(NoSuchField(key, suggestions))409 };410 Ok(value)411 }412413 fn get_raw(&self, key: IStr, this: Self) -> Result<Option<Val>> {414 self.0.get_for_uncached(key, this)415 }416417 fn field_visibility(&self, field: IStr) -> Option<Visibility> {418 self.0.field_visibility(field)419 }420421 pub fn run_assertions(&self) -> Result<()> {422 // FIXME: Should it use `self.0.this()` in case of standalone super?423 self.run_assertions_raw(self.clone())424 }425 fn run_assertions_raw(&self, this: Self) -> Result<()> {426 self.0.run_assertions_raw(this)427 }428429 pub fn iter(430 &self,431 #[cfg(feature = "exp-preserve-order")] preserve_order: bool,432 ) -> impl Iterator<Item = (IStr, Result<Val>)> + '_ {433 let fields = self.fields(434 #[cfg(feature = "exp-preserve-order")]435 preserve_order,436 );437 fields.into_iter().map(|field| {438 (439 field.clone(),440 self.get(field)441 .map(|opt| opt.expect("iterating over keys, field exists")),442 )443 })444 }445 pub fn get_lazy(&self, key: IStr) -> Option<Thunk<Val>> {446 #[derive(Trace)]447 struct ThunkGet {448 obj: ObjValue,449 key: IStr,450 }451 impl ThunkValue for ThunkGet {452 type Output = Val;453454 fn get(self: Box<Self>) -> Result<Self::Output> {455 Ok(self.obj.get(self.key)?.expect("field exists"))456 }457 }458459 if !self.has_field_ex(key.clone(), true) {460 return None;461 }462 Some(Thunk::new(ThunkGet {463 obj: self.clone(),464 key,465 }))466 }467 pub fn get_lazy_or_bail(&self, key: IStr) -> Thunk<Val> {468 #[derive(Trace)]469 struct ThunkGet {470 obj: ObjValue,471 key: IStr,472 }473 impl ThunkValue for ThunkGet {474 type Output = Val;475476 fn get(self: Box<Self>) -> Result<Self::Output> {477 self.obj.get_or_bail(self.key)478 }479 }480481 Thunk::new(ThunkGet {482 obj: self.clone(),483 key,484 })485 }486 pub fn ptr_eq(a: &Self, b: &Self) -> bool {487 Cc::ptr_eq(&a.0, &b.0)488 }489 pub fn downgrade(self) -> WeakObjValue {490 WeakObjValue(self.0.downgrade())491 }492 fn fields_visibility(&self) -> FxHashMap<IStr, (bool, FieldSortKey)> {493 let mut out = FxHashMap::default();494 self.enum_fields(495 SuperDepth::default(),496 &mut |depth, index, name, visibility| {497 let new_sort_key = FieldSortKey::new(depth, index);498 let entry = out.entry(name);499 let (visible, _) = entry.or_insert((true, new_sort_key));500 match visibility {501 Visibility::Normal => {}502 Visibility::Hidden => {503 *visible = false;504 }505 Visibility::Unhide => {506 *visible = true;507 }508 };509 false510 },511 );512 out513 }514 pub fn fields_ex(515 &self,516 include_hidden: bool,517 #[cfg(feature = "exp-preserve-order")] preserve_order: bool,518 ) -> Vec<IStr> {519 #[cfg(feature = "exp-preserve-order")]520 if preserve_order {521 let (mut fields, mut keys): (Vec<_>, Vec<_>) = self522 .fields_visibility()523 .into_iter()524 .filter(|(_, (visible, _))| include_hidden || *visible)525 .enumerate()526 .map(|(idx, (k, (_, sk)))| (k, (sk, idx)))527 .unzip();528 keys.sort_unstable_by_key(|v| v.0);529 // Reorder in-place by resulting indexes530 for i in 0..fields.len() {531 let x = fields[i].clone();532 let mut j = i;533 loop {534 let k = keys[j].1;535 keys[j].1 = j;536 if k == i {537 break;538 }539 fields[j] = fields[k].clone();540 j = k;541 }542 fields[j] = x;543 }544 return fields;545 }546547 let mut fields: Vec<_> = self548 .fields_visibility()549 .into_iter()550 .filter(|(_, (visible, _))| include_hidden || *visible)551 .map(|(k, _)| k)552 .collect();553 fields.sort_unstable();554 fields555 }556 pub fn fields(&self, #[cfg(feature = "exp-preserve-order")] preserve_order: bool) -> Vec<IStr> {557 self.fields_ex(558 false,559 #[cfg(feature = "exp-preserve-order")]560 preserve_order,561 )562 }563 pub fn values_ex(564 &self,565 include_hidden: bool,566 #[cfg(feature = "exp-preserve-order")] preserve_order: bool,567 ) -> ArrValue {568 ArrValue::new(PickObjectValues::new(569 self.clone(),570 self.fields_ex(571 include_hidden,572 #[cfg(feature = "exp-preserve-order")]573 preserve_order,574 ),575 ))576 }577 pub fn values(&self, #[cfg(feature = "exp-preserve-order")] preserve_order: bool) -> ArrValue {578 self.values_ex(579 false,580 #[cfg(feature = "exp-preserve-order")]581 preserve_order,582 )583 }584 pub fn key_values_ex(585 &self,586 include_hidden: bool,587 #[cfg(feature = "exp-preserve-order")] preserve_order: bool,588 ) -> ArrValue {589 ArrValue::new(PickObjectKeyValues::new(590 self.clone(),591 self.fields_ex(592 include_hidden,593 #[cfg(feature = "exp-preserve-order")]594 preserve_order,595 ),596 ))597 }598 pub fn key_values(599 &self,600 #[cfg(feature = "exp-preserve-order")] preserve_order: bool,601 ) -> ArrValue {602 self.key_values_ex(603 false,604 #[cfg(feature = "exp-preserve-order")]605 preserve_order,606 )607 }608}609610impl OopObject {611 pub fn new(612 sup: Option<ObjValue>,613 this_entries: Cc<GcHashMap<IStr, ObjMember>>,614 assertions: Cc<Vec<TraceBox<dyn ObjectAssertion>>>,615 ) -> Self {616 Self {617 sup,618 // this: None,619 assertions,620 assertions_ran: RefCell::new(GcHashSet::new()),621 this_entries,622 value_cache: RefCell::new(GcHashMap::new()),623 }624 }625626 fn evaluate_this(&self, v: &ObjMember, real_this: ObjValue) -> Result<Val> {627 v.invoke.evaluate(self.sup.clone(), Some(real_this))628 }629630 // FIXME: Duplication between ObjValue and OopObject631 fn fields_visibility(&self) -> FxHashMap<IStr, (bool, FieldSortKey)> {632 let mut out = FxHashMap::default();633 self.enum_fields(634 SuperDepth::default(),635 &mut |depth, index, name, visibility| {636 let new_sort_key = FieldSortKey::new(depth, index);637 let entry = out.entry(name);638 let (visible, _) = entry.or_insert((true, new_sort_key));639 match visibility {640 Visibility::Normal => {}641 Visibility::Hidden => {642 *visible = false;643 }644 Visibility::Unhide => {645 *visible = true;646 }647 };648 false649 },650 );651 out652 }653}654655impl ObjectLike for OopObject {656 fn extend_from(&self, sup: ObjValue) -> ObjValue {657 ObjValue::new(match &self.sup {658 None => Self::new(659 Some(sup),660 self.this_entries.clone(),661 self.assertions.clone(),662 ),663 Some(v) => Self::new(664 Some(v.extend_from(sup)),665 self.this_entries.clone(),666 self.assertions.clone(),667 ),668 })669 }670671 fn len(&self) -> usize {672 self.fields_visibility()673 .into_iter()674 .filter(|(_, (visible, _))| *visible)675 .count()676 }677678 fn is_empty(&self) -> bool {679 if !self.this_entries.is_empty() {680 return false;681 }682 self.sup.as_ref().map_or(true, ObjValue::is_empty)683 }684685 /// Run callback for every field found in object686 ///687 /// Returns true if ended prematurely688 fn enum_fields(&self, depth: SuperDepth, handler: &mut EnumFieldsHandler<'_>) -> bool {689 if let Some(s) = &self.sup {690 if s.enum_fields(depth.deeper(), handler) {691 return true;692 }693 }694 for (name, member) in self.this_entries.iter() {695 if handler(696 depth,697 member.original_index,698 name.clone(),699 member.flags.visibility(),700 ) {701 return true;702 }703 }704 false705 }706707 fn has_field_include_hidden(&self, name: IStr) -> bool {708 if self.this_entries.contains_key(&name) {709 true710 } else if let Some(super_obj) = &self.sup {711 super_obj.has_field_include_hidden(name)712 } else {713 false714 }715 }716 fn has_field(&self, name: IStr) -> bool {717 self.field_visibility(name)718 .map_or(false, |v| v.is_visible())719 }720721 fn get_for(&self, key: IStr, this: ObjValue) -> Result<Option<Val>> {722 let cache_key = (key.clone(), Some(this.clone().downgrade()));723 if let Some(v) = self.value_cache.borrow().get(&cache_key) {724 return Ok(match v {725 CacheValue::Cached(v) => Some(v.clone()),726 CacheValue::NotFound => None,727 CacheValue::Pending => bail!(InfiniteRecursionDetected),728 CacheValue::Errored(e) => return Err(e.clone()),729 });730 }731 self.value_cache732 .borrow_mut()733 .insert(cache_key.clone(), CacheValue::Pending);734 let value = self.get_for_uncached(key, this).map_err(|e| {735 self.value_cache736 .borrow_mut()737 .insert(cache_key.clone(), CacheValue::Errored(e.clone()));738 e739 })?;740 self.value_cache.borrow_mut().insert(741 cache_key,742 value743 .as_ref()744 .map_or(CacheValue::NotFound, |v| CacheValue::Cached(v.clone())),745 );746 Ok(value)747 }748 fn get_for_uncached(&self, key: IStr, real_this: ObjValue) -> Result<Option<Val>> {749 match (self.this_entries.get(&key), &self.sup) {750 (Some(k), None) => Ok(Some(self.evaluate_this(k, real_this)?)),751 (Some(k), Some(super_obj)) => {752 let our = self.evaluate_this(k, real_this.clone())?;753 if k.flags.add() {754 super_obj755 .get_raw(key, real_this)?756 .map_or(Ok(Some(our.clone())), |v| {757 Ok(Some(evaluate_add_op(&v, &our)?))758 })759 } else {760 Ok(Some(our))761 }762 }763 (None, Some(super_obj)) => super_obj.get_raw(key, real_this),764 (None, None) => Ok(None),765 }766 }767 fn field_visibility(&self, name: IStr) -> Option<Visibility> {768 if let Some(m) = self.this_entries.get(&name) {769 Some(match &m.flags.visibility() {770 Visibility::Normal => self771 .sup772 .as_ref()773 .and_then(|super_obj| super_obj.field_visibility(name))774 .unwrap_or(Visibility::Normal),775 v => *v,776 })777 } else if let Some(super_obj) = &self.sup {778 super_obj.field_visibility(name)779 } else {780 None781 }782 }783784 fn run_assertions_raw(&self, real_this: ObjValue) -> Result<()> {785 if self.assertions.is_empty() {786 if let Some(super_obj) = &self.sup {787 super_obj.run_assertions_raw(real_this)?;788 }789 return Ok(());790 }791 if self.assertions_ran.borrow_mut().insert(real_this.clone()) {792 for assertion in self.assertions.iter() {793 if let Err(e) = assertion.run(self.sup.clone(), Some(real_this.clone())) {794 self.assertions_ran.borrow_mut().remove(&real_this);795 return Err(e);796 }797 }798 if let Some(super_obj) = &self.sup {799 super_obj.run_assertions_raw(real_this)?;800 }801 }802 Ok(())803 }804}805806impl PartialEq for ObjValue {807 fn eq(&self, other: &Self) -> bool {808 Cc::ptr_eq(&self.0, &other.0)809 }810}811812impl Eq for ObjValue {}813impl Hash for ObjValue {814 fn hash<H: Hasher>(&self, hasher: &mut H) {815 hasher.write_usize(addr_of!(*self.0) as usize);816 }817}818819#[allow(clippy::module_name_repetitions)]820pub struct ObjValueBuilder {821 sup: Option<ObjValue>,822 map: GcHashMap<IStr, ObjMember>,823 assertions: Vec<TraceBox<dyn ObjectAssertion>>,824 next_field_index: FieldIndex,825}826impl ObjValueBuilder {827 pub fn new() -> Self {828 Self::with_capacity(0)829 }830 pub fn with_capacity(capacity: usize) -> Self {831 Self {832 sup: None,833 map: GcHashMap::with_capacity(capacity),834 assertions: Vec::new(),835 next_field_index: FieldIndex::default(),836 }837 }838 pub fn reserve_asserts(&mut self, capacity: usize) -> &mut Self {839 self.assertions.reserve_exact(capacity);840 self841 }842 pub fn with_super(&mut self, super_obj: ObjValue) -> &mut Self {843 self.sup = Some(super_obj);844 self845 }846847 pub fn assert(&mut self, assertion: impl ObjectAssertion + 'static) -> &mut Self {848 self.assertions.push(tb!(assertion));849 self850 }851 pub fn field(&mut self, name: impl Into<IStr>) -> ObjMemberBuilder<ValueBuilder<'_>> {852 let field_index = self.next_field_index;853 self.next_field_index = self.next_field_index.next();854 ObjMemberBuilder::new(ValueBuilder(self), name.into(), field_index)855 }856 /// Preset for common method definiton pattern:857 /// Create a hidden field with the function value.858 ///859 /// `.field(name).hide().value(Val::function(value))`860 pub fn method(&mut self, name: impl Into<IStr>, value: impl Into<FuncVal>) -> &mut Self {861 self.field(name).hide().value(Val::Func(value.into()));862 self863 }864 pub fn try_method(865 &mut self,866 name: impl Into<IStr>,867 value: impl Into<FuncVal>,868 ) -> Result<&mut Self> {869 self.field(name).hide().try_value(Val::Func(value.into()))?;870 Ok(self)871 }872873 pub fn build(self) -> ObjValue {874 if self.sup.is_none() && self.map.is_empty() && self.assertions.is_empty() {875 return ObjValue::new_empty();876 }877 ObjValue::new(OopObject::new(878 self.sup,879 Cc::new(self.map),880 Cc::new(self.assertions),881 ))882 }883}884impl Default for ObjValueBuilder {885 fn default() -> Self {886 Self::with_capacity(0)887 }888}889890#[allow(clippy::module_name_repetitions)]891#[must_use = "value not added unless binding() was called"]892pub struct ObjMemberBuilder<Kind> {893 kind: Kind,894 name: IStr,895 add: bool,896 visibility: Visibility,897 original_index: FieldIndex,898 location: Option<ExprLocation>,899}900901#[allow(clippy::missing_const_for_fn)]902impl<Kind> ObjMemberBuilder<Kind> {903 pub(crate) fn new(kind: Kind, name: IStr, original_index: FieldIndex) -> Self {904 Self {905 kind,906 name,907 original_index,908 add: false,909 visibility: Visibility::Normal,910 location: None,911 }912 }913914 pub const fn with_add(mut self, add: bool) -> Self {915 self.add = add;916 self917 }918 pub fn add(self) -> Self {919 self.with_add(true)920 }921 pub fn with_visibility(mut self, visibility: Visibility) -> Self {922 self.visibility = visibility;923 self924 }925 pub fn hide(self) -> Self {926 self.with_visibility(Visibility::Hidden)927 }928 pub fn with_location(mut self, location: ExprLocation) -> Self {929 self.location = Some(location);930 self931 }932 fn build_member(self, binding: MaybeUnbound) -> (Kind, IStr, ObjMember) {933 (934 self.kind,935 self.name,936 ObjMember {937 flags: ObjFieldFlags::new(self.add, self.visibility),938 original_index: self.original_index,939 invoke: binding,940 location: self.location,941 },942 )943 }944}945946pub struct ValueBuilder<'v>(&'v mut ObjValueBuilder);947impl ObjMemberBuilder<ValueBuilder<'_>> {948 /// Inserts value, replacing if it is already defined949 pub fn value(self, value: impl Into<Val>) {950 let (receiver, name, member) =951 self.build_member(MaybeUnbound::Bound(Thunk::evaluated(value.into())));952 let entry = receiver.0.map.entry(name);953 entry.insert(member);954 }955956 /// Tries to insert value, returns an error if it was already defined957 pub fn try_value(self, value: impl Into<Val>) -> Result<()> {958 self.thunk(Thunk::evaluated(value.into()))959 }960 pub fn thunk(self, value: impl Into<Thunk<Val>>) -> Result<()> {961 self.binding(MaybeUnbound::Bound(value.into()))962 }963 pub fn bindable(self, bindable: impl Unbound<Bound = Val>) -> Result<()> {964 self.binding(MaybeUnbound::Unbound(Cc::new(tb!(bindable))))965 }966 pub fn binding(self, binding: MaybeUnbound) -> Result<()> {967 let (receiver, name, member) = self.build_member(binding);968 let location = member.location.clone();969 let old = receiver.0.map.insert(name.clone(), member);970 if old.is_some() {971 State::push(972 CallLocation(location.as_ref()),973 || format!("field <{}> initializtion", name.clone()),974 || bail!(DuplicateFieldName(name.clone())),975 )?;976 }977 Ok(())978 }979}980981pub struct ExtendBuilder<'v>(&'v mut ObjValue);982impl ObjMemberBuilder<ExtendBuilder<'_>> {983 pub fn value(self, value: impl Into<Val>) {984 self.binding(MaybeUnbound::Bound(Thunk::evaluated(value.into())));985 }986 pub fn bindable(self, bindable: TraceBox<dyn Unbound<Bound = Val>>) {987 self.binding(MaybeUnbound::Unbound(Cc::new(bindable)));988 }989 pub fn binding(self, binding: MaybeUnbound) {990 let (receiver, name, member) = self.build_member(binding);991 let new = receiver.0.clone();992 *receiver.0 = new.extend_with_raw_member(name, member);993 }994}1use std::{2 any::Any,3 cell::RefCell,4 fmt::Debug,5 hash::{Hash, Hasher},6 ptr::addr_of,7};89use jrsonnet_gcmodule::{Cc, Trace, Weak};10use jrsonnet_interner::IStr;11use jrsonnet_parser::{ExprLocation, Visibility};12use rustc_hash::FxHashMap;1314use crate::{15 arr::{PickObjectKeyValues, PickObjectValues},16 bail,17 error::{suggest_object_fields, Error, ErrorKind::*},18 function::{CallLocation, FuncVal},19 gc::{GcHashMap, GcHashSet, TraceBox},20 operator::evaluate_add_op,21 tb,22 val::{ArrValue, ThunkValue},23 MaybeUnbound, Result, State, Thunk, Unbound, Val,24};2526#[cfg(not(feature = "exp-preserve-order"))]27mod ordering {28 #![allow(29 // This module works as stub for preserve-order feature30 clippy::unused_self,31 )]3233 use jrsonnet_gcmodule::Trace;3435 #[derive(Clone, Copy, Default, Debug, Trace)]36 pub struct FieldIndex(());37 impl FieldIndex {38 pub const fn next(self) -> Self {39 Self(())40 }41 }4243 #[derive(Clone, Copy, Default, Debug, Trace)]44 pub struct SuperDepth(());45 impl SuperDepth {46 pub const fn deeper(self) -> Self {47 Self(())48 }49 }5051 #[derive(Clone, Copy)]52 pub struct FieldSortKey(());53 impl FieldSortKey {54 pub const fn new(_: SuperDepth, _: FieldIndex) -> Self {55 Self(())56 }57 }58}5960#[cfg(feature = "exp-preserve-order")]61mod ordering {62 use std::cmp::Reverse;6364 use jrsonnet_gcmodule::Trace;6566 #[derive(Clone, Copy, Default, Debug, Trace, PartialEq, Eq, PartialOrd, Ord)]67 pub struct FieldIndex(u32);68 impl FieldIndex {69 pub fn next(self) -> Self {70 Self(self.0 + 1)71 }72 }7374 #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Debug)]75 pub struct SuperDepth(u32);76 impl SuperDepth {77 pub fn deeper(self) -> Self {78 Self(self.0 + 1)79 }80 }8182 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]83 pub struct FieldSortKey(Reverse<SuperDepth>, FieldIndex);84 impl FieldSortKey {85 pub fn new(depth: SuperDepth, index: FieldIndex) -> Self {86 Self(Reverse(depth), index)87 }88 }89}9091use ordering::{FieldIndex, FieldSortKey, SuperDepth};9293// 0 - add94// 12 - visibility95#[derive(Clone, Copy)]96pub struct ObjFieldFlags(u8);97impl ObjFieldFlags {98 fn new(add: bool, visibility: Visibility) -> Self {99 let mut v = 0;100 if add {101 v |= 1;102 }103 v |= match visibility {104 Visibility::Normal => 0b000,105 Visibility::Hidden => 0b010,106 Visibility::Unhide => 0b100,107 };108 Self(v)109 }110 pub fn add(&self) -> bool {111 self.0 & 1 != 0112 }113 pub fn visibility(&self) -> Visibility {114 match (self.0 & 0b110) >> 1 {115 0b00 => Visibility::Normal,116 0b01 => Visibility::Hidden,117 0b10 => Visibility::Unhide,118 _ => unreachable!(),119 }120 }121}122impl Debug for ObjFieldFlags {123 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {124 f.debug_struct("ObjFieldFlags")125 .field("add", &self.add())126 .field("visibility", &self.visibility())127 .finish()128 }129}130131#[allow(clippy::module_name_repetitions)]132#[derive(Debug, Trace)]133pub struct ObjMember {134 #[trace(skip)]135 flags: ObjFieldFlags,136 original_index: FieldIndex,137 pub invoke: MaybeUnbound,138 pub location: Option<ExprLocation>,139}140141pub trait ObjectAssertion: Trace {142 fn run(&self, super_obj: Option<ObjValue>, this: Option<ObjValue>) -> Result<()>;143}144145// Field => This146147#[derive(Trace)]148enum CacheValue {149 Cached(Val),150 NotFound,151 Pending,152 Errored(Error),153}154155#[allow(clippy::module_name_repetitions)]156#[derive(Trace)]157#[trace(tracking(force))]158pub struct OopObject {159 sup: Option<ObjValue>,160 // this: Option<ObjValue>,161 assertions: Cc<Vec<TraceBox<dyn ObjectAssertion>>>,162 assertions_ran: RefCell<GcHashSet<ObjValue>>,163 this_entries: Cc<GcHashMap<IStr, ObjMember>>,164 value_cache: RefCell<GcHashMap<(IStr, Option<WeakObjValue>), CacheValue>>,165}166impl Debug for OopObject {167 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {168 f.debug_struct("OopObject")169 .field("sup", &self.sup)170 // .field("assertions", &self.assertions)171 // .field("assertions_ran", &self.assertions_ran)172 .field("this_entries", &self.this_entries)173 // .field("value_cache", &self.value_cache)174 .finish_non_exhaustive()175 }176}177178type EnumFieldsHandler<'a> = dyn FnMut(SuperDepth, FieldIndex, IStr, Visibility) -> bool + 'a;179180pub trait ObjectLike: Trace + Any + Debug {181 fn extend_from(&self, sup: ObjValue) -> ObjValue;182 /// When using standalone super in object, `this.super_obj.with_this(this)` is executed183 fn with_this(&self, me: ObjValue, this: ObjValue) -> ObjValue {184 ObjValue::new(ThisOverride { inner: me, this })185 }186 fn this(&self) -> Option<ObjValue> {187 None188 }189 fn len(&self) -> usize;190 fn is_empty(&self) -> bool;191 // If callback returns false, iteration stops192 fn enum_fields(&self, depth: SuperDepth, handler: &mut EnumFieldsHandler<'_>) -> bool;193194 fn has_field_include_hidden(&self, name: IStr) -> bool;195 fn has_field(&self, name: IStr) -> bool;196197 fn get_for(&self, key: IStr, this: ObjValue) -> Result<Option<Val>>;198 fn get_for_uncached(&self, key: IStr, this: ObjValue) -> Result<Option<Val>>;199 fn field_visibility(&self, field: IStr) -> Option<Visibility>;200201 fn run_assertions_raw(&self, this: ObjValue) -> Result<()>;202}203204#[derive(Clone, Trace)]205pub struct WeakObjValue(#[trace(skip)] pub(crate) Weak<TraceBox<dyn ObjectLike>>);206207impl PartialEq for WeakObjValue {208 fn eq(&self, other: &Self) -> bool {209 Weak::ptr_eq(&self.0, &other.0)210 }211}212213impl Eq for WeakObjValue {}214impl Hash for WeakObjValue {215 fn hash<H: Hasher>(&self, hasher: &mut H) {216 // Safety: usize is POD217 let addr = unsafe { *std::ptr::addr_of!(self.0).cast() };218 hasher.write_usize(addr);219 }220}221222#[allow(clippy::module_name_repetitions)]223#[derive(Clone, Trace, Debug)]224pub struct ObjValue(pub(crate) Cc<TraceBox<dyn ObjectLike>>);225226#[derive(Debug, Trace)]227struct EmptyObject;228impl ObjectLike for EmptyObject {229 fn extend_from(&self, sup: ObjValue) -> ObjValue {230 // obj + {} == obj231 sup232 }233234 fn this(&self) -> Option<ObjValue> {235 None236 }237238 fn len(&self) -> usize {239 0240 }241242 fn is_empty(&self) -> bool {243 true244 }245246 fn enum_fields(&self, _depth: SuperDepth, _handler: &mut EnumFieldsHandler<'_>) -> bool {247 false248 }249250 fn has_field_include_hidden(&self, _name: IStr) -> bool {251 false252 }253254 fn has_field(&self, _name: IStr) -> bool {255 false256 }257258 fn get_for(&self, _key: IStr, _this: ObjValue) -> Result<Option<Val>> {259 Ok(None)260 }261 fn get_for_uncached(&self, _key: IStr, _this: ObjValue) -> Result<Option<Val>> {262 Ok(None)263 }264265 fn run_assertions_raw(&self, _this: ObjValue) -> Result<()> {266 Ok(())267 }268269 fn field_visibility(&self, _field: IStr) -> Option<Visibility> {270 None271 }272}273274#[derive(Trace, Debug)]275struct ThisOverride {276 inner: ObjValue,277 this: ObjValue,278}279impl ObjectLike for ThisOverride {280 fn with_this(&self, _me: ObjValue, this: ObjValue) -> ObjValue {281 ObjValue::new(Self {282 inner: self.inner.clone(),283 this,284 })285 }286287 fn extend_from(&self, sup: ObjValue) -> ObjValue {288 self.inner.extend_from(sup).with_this(self.this.clone())289 }290291 fn this(&self) -> Option<ObjValue> {292 Some(self.this.clone())293 }294295 fn len(&self) -> usize {296 self.inner.len()297 }298299 fn is_empty(&self) -> bool {300 self.inner.is_empty()301 }302303 fn enum_fields(&self, depth: SuperDepth, handler: &mut EnumFieldsHandler<'_>) -> bool {304 self.inner.enum_fields(depth, handler)305 }306307 fn has_field_include_hidden(&self, name: IStr) -> bool {308 self.inner.has_field_include_hidden(name)309 }310311 fn has_field(&self, name: IStr) -> bool {312 self.inner.has_field(name)313 }314315 fn get_for(&self, key: IStr, this: ObjValue) -> Result<Option<Val>> {316 self.inner.get_for(key, this)317 }318319 fn get_for_uncached(&self, key: IStr, this: ObjValue) -> Result<Option<Val>> {320 self.inner.get_raw(key, this)321 }322323 fn field_visibility(&self, field: IStr) -> Option<Visibility> {324 self.inner.field_visibility(field)325 }326327 fn run_assertions_raw(&self, this: ObjValue) -> Result<()> {328 self.inner.run_assertions_raw(this)329 }330}331332impl ObjValue {333 pub fn new(v: impl ObjectLike) -> Self {334 Self(Cc::new(tb!(v)))335 }336 pub fn new_empty() -> Self {337 Self::new(EmptyObject)338 }339 pub fn builder() -> ObjValueBuilder {340 ObjValueBuilder::new()341 }342 pub fn builder_with_capacity(capacity: usize) -> ObjValueBuilder {343 ObjValueBuilder::with_capacity(capacity)344 }345 pub(crate) fn extend_with_raw_member(self, key: IStr, value: ObjMember) -> Self {346 let mut out = ObjValueBuilder::with_capacity(1);347 out.with_super(self);348 let mut member = out.field(key);349 if value.flags.add() {350 member = member.add();351 }352 if let Some(loc) = value.location {353 member = member.with_location(loc);354 }355 let _ = member356 .with_visibility(value.flags.visibility())357 .binding(value.invoke);358 out.build()359 }360 pub fn extend_field(&mut self, name: IStr) -> ObjMemberBuilder<ExtendBuilder<'_>> {361 ObjMemberBuilder::new(ExtendBuilder(self), name, FieldIndex::default())362 }363364 #[must_use]365 pub fn extend_from(&self, sup: Self) -> Self {366 self.0.extend_from(sup)367 }368 #[must_use]369 pub fn with_this(&self, this: Self) -> Self {370 self.0.with_this(self.clone(), this)371 }372 pub fn len(&self) -> usize {373 self.0.len()374 }375 pub fn is_empty(&self) -> bool {376 self.0.is_empty()377 }378 pub fn enum_fields(&self, depth: SuperDepth, handler: &mut EnumFieldsHandler<'_>) -> bool {379 self.0.enum_fields(depth, handler)380 }381382 pub fn has_field_include_hidden(&self, name: IStr) -> bool {383 self.0.has_field_include_hidden(name)384 }385 pub fn has_field(&self, name: IStr) -> bool {386 self.0.has_field(name)387 }388 pub fn has_field_ex(&self, name: IStr, include_hidden: bool) -> bool {389 if include_hidden {390 self.has_field_include_hidden(name)391 } else {392 self.has_field(name)393 }394 }395396 pub fn get(&self, key: IStr) -> Result<Option<Val>> {397 self.run_assertions()?;398 self.get_for(key, self.0.this().unwrap_or_else(|| self.clone()))399 }400401 pub fn get_for(&self, key: IStr, this: Self) -> Result<Option<Val>> {402 self.0.get_for(key, this)403 }404405 pub fn get_or_bail(&self, key: IStr) -> Result<Val> {406 let Some(value) = self.get(key.clone())? else {407 let suggestions = suggest_object_fields(self, key.clone());408 bail!(NoSuchField(key, suggestions))409 };410 Ok(value)411 }412413 fn get_raw(&self, key: IStr, this: Self) -> Result<Option<Val>> {414 self.0.get_for_uncached(key, this)415 }416417 fn field_visibility(&self, field: IStr) -> Option<Visibility> {418 self.0.field_visibility(field)419 }420421 pub fn run_assertions(&self) -> Result<()> {422 // FIXME: Should it use `self.0.this()` in case of standalone super?423 self.run_assertions_raw(self.clone())424 }425 fn run_assertions_raw(&self, this: Self) -> Result<()> {426 self.0.run_assertions_raw(this)427 }428429 pub fn iter(430 &self,431 #[cfg(feature = "exp-preserve-order")] preserve_order: bool,432 ) -> impl Iterator<Item = (IStr, Result<Val>)> + '_ {433 let fields = self.fields(434 #[cfg(feature = "exp-preserve-order")]435 preserve_order,436 );437 fields.into_iter().map(|field| {438 (439 field.clone(),440 self.get(field)441 .map(|opt| opt.expect("iterating over keys, field exists")),442 )443 })444 }445 pub fn get_lazy(&self, key: IStr) -> Option<Thunk<Val>> {446 #[derive(Trace)]447 struct ThunkGet {448 obj: ObjValue,449 key: IStr,450 }451 impl ThunkValue for ThunkGet {452 type Output = Val;453454 fn get(self: Box<Self>) -> Result<Self::Output> {455 Ok(self.obj.get(self.key)?.expect("field exists"))456 }457 }458459 if !self.has_field_ex(key.clone(), true) {460 return None;461 }462 Some(Thunk::new(ThunkGet {463 obj: self.clone(),464 key,465 }))466 }467 pub fn get_lazy_or_bail(&self, key: IStr) -> Thunk<Val> {468 #[derive(Trace)]469 struct ThunkGet {470 obj: ObjValue,471 key: IStr,472 }473 impl ThunkValue for ThunkGet {474 type Output = Val;475476 fn get(self: Box<Self>) -> Result<Self::Output> {477 self.obj.get_or_bail(self.key)478 }479 }480481 Thunk::new(ThunkGet {482 obj: self.clone(),483 key,484 })485 }486 pub fn ptr_eq(a: &Self, b: &Self) -> bool {487 Cc::ptr_eq(&a.0, &b.0)488 }489 pub fn downgrade(self) -> WeakObjValue {490 WeakObjValue(self.0.downgrade())491 }492 fn fields_visibility(&self) -> FxHashMap<IStr, (bool, FieldSortKey)> {493 let mut out = FxHashMap::default();494 self.enum_fields(495 SuperDepth::default(),496 &mut |depth, index, name, visibility| {497 let new_sort_key = FieldSortKey::new(depth, index);498 let entry = out.entry(name);499 let (visible, _) = entry.or_insert((true, new_sort_key));500 match visibility {501 Visibility::Normal => {}502 Visibility::Hidden => {503 *visible = false;504 }505 Visibility::Unhide => {506 *visible = true;507 }508 };509 false510 },511 );512 out513 }514 pub fn fields_ex(515 &self,516 include_hidden: bool,517 #[cfg(feature = "exp-preserve-order")] preserve_order: bool,518 ) -> Vec<IStr> {519 #[cfg(feature = "exp-preserve-order")]520 if preserve_order {521 let (mut fields, mut keys): (Vec<_>, Vec<_>) = self522 .fields_visibility()523 .into_iter()524 .filter(|(_, (visible, _))| include_hidden || *visible)525 .enumerate()526 .map(|(idx, (k, (_, sk)))| (k, (sk, idx)))527 .unzip();528 keys.sort_unstable_by_key(|v| v.0);529 // Reorder in-place by resulting indexes530 for i in 0..fields.len() {531 let x = fields[i].clone();532 let mut j = i;533 loop {534 let k = keys[j].1;535 keys[j].1 = j;536 if k == i {537 break;538 }539 fields[j] = fields[k].clone();540 j = k;541 }542 fields[j] = x;543 }544 return fields;545 }546547 let mut fields: Vec<_> = self548 .fields_visibility()549 .into_iter()550 .filter(|(_, (visible, _))| include_hidden || *visible)551 .map(|(k, _)| k)552 .collect();553 fields.sort_unstable();554 fields555 }556 pub fn fields(&self, #[cfg(feature = "exp-preserve-order")] preserve_order: bool) -> Vec<IStr> {557 self.fields_ex(558 false,559 #[cfg(feature = "exp-preserve-order")]560 preserve_order,561 )562 }563 pub fn values_ex(564 &self,565 include_hidden: bool,566 #[cfg(feature = "exp-preserve-order")] preserve_order: bool,567 ) -> ArrValue {568 ArrValue::new(PickObjectValues::new(569 self.clone(),570 self.fields_ex(571 include_hidden,572 #[cfg(feature = "exp-preserve-order")]573 preserve_order,574 ),575 ))576 }577 pub fn values(&self, #[cfg(feature = "exp-preserve-order")] preserve_order: bool) -> ArrValue {578 self.values_ex(579 false,580 #[cfg(feature = "exp-preserve-order")]581 preserve_order,582 )583 }584 pub fn key_values_ex(585 &self,586 include_hidden: bool,587 #[cfg(feature = "exp-preserve-order")] preserve_order: bool,588 ) -> ArrValue {589 ArrValue::new(PickObjectKeyValues::new(590 self.clone(),591 self.fields_ex(592 include_hidden,593 #[cfg(feature = "exp-preserve-order")]594 preserve_order,595 ),596 ))597 }598 pub fn key_values(599 &self,600 #[cfg(feature = "exp-preserve-order")] preserve_order: bool,601 ) -> ArrValue {602 self.key_values_ex(603 false,604 #[cfg(feature = "exp-preserve-order")]605 preserve_order,606 )607 }608}609610impl OopObject {611 pub fn new(612 sup: Option<ObjValue>,613 this_entries: Cc<GcHashMap<IStr, ObjMember>>,614 assertions: Cc<Vec<TraceBox<dyn ObjectAssertion>>>,615 ) -> Self {616 Self {617 sup,618 // this: None,619 assertions,620 assertions_ran: RefCell::new(GcHashSet::new()),621 this_entries,622 value_cache: RefCell::new(GcHashMap::new()),623 }624 }625626 fn evaluate_this(&self, v: &ObjMember, real_this: ObjValue) -> Result<Val> {627 v.invoke.evaluate(self.sup.clone(), Some(real_this))628 }629630 // FIXME: Duplication between ObjValue and OopObject631 fn fields_visibility(&self) -> FxHashMap<IStr, (bool, FieldSortKey)> {632 let mut out = FxHashMap::default();633 self.enum_fields(634 SuperDepth::default(),635 &mut |depth, index, name, visibility| {636 let new_sort_key = FieldSortKey::new(depth, index);637 let entry = out.entry(name);638 let (visible, _) = entry.or_insert((true, new_sort_key));639 match visibility {640 Visibility::Normal => {}641 Visibility::Hidden => {642 *visible = false;643 }644 Visibility::Unhide => {645 *visible = true;646 }647 };648 false649 },650 );651 out652 }653}654655impl ObjectLike for OopObject {656 fn extend_from(&self, sup: ObjValue) -> ObjValue {657 ObjValue::new(match &self.sup {658 None => Self::new(659 Some(sup),660 self.this_entries.clone(),661 self.assertions.clone(),662 ),663 Some(v) => Self::new(664 Some(v.extend_from(sup)),665 self.this_entries.clone(),666 self.assertions.clone(),667 ),668 })669 }670671 fn len(&self) -> usize {672 self.fields_visibility()673 .into_iter()674 .filter(|(_, (visible, _))| *visible)675 .count()676 }677678 fn is_empty(&self) -> bool {679 if !self.this_entries.is_empty() {680 return false;681 }682 self.sup.as_ref().map_or(true, ObjValue::is_empty)683 }684685 /// Run callback for every field found in object686 ///687 /// Returns true if ended prematurely688 fn enum_fields(&self, depth: SuperDepth, handler: &mut EnumFieldsHandler<'_>) -> bool {689 if let Some(s) = &self.sup {690 if s.enum_fields(depth.deeper(), handler) {691 return true;692 }693 }694 for (name, member) in self.this_entries.iter() {695 if handler(696 depth,697 member.original_index,698 name.clone(),699 member.flags.visibility(),700 ) {701 return true;702 }703 }704 false705 }706707 fn has_field_include_hidden(&self, name: IStr) -> bool {708 if self.this_entries.contains_key(&name) {709 true710 } else if let Some(super_obj) = &self.sup {711 super_obj.has_field_include_hidden(name)712 } else {713 false714 }715 }716 fn has_field(&self, name: IStr) -> bool {717 self.field_visibility(name)718 .map_or(false, |v| v.is_visible())719 }720721 fn get_for(&self, key: IStr, this: ObjValue) -> Result<Option<Val>> {722 let cache_key = (key.clone(), Some(this.clone().downgrade()));723 if let Some(v) = self.value_cache.borrow().get(&cache_key) {724 return Ok(match v {725 CacheValue::Cached(v) => Some(v.clone()),726 CacheValue::NotFound => None,727 CacheValue::Pending => bail!(InfiniteRecursionDetected),728 CacheValue::Errored(e) => return Err(e.clone()),729 });730 }731 self.value_cache732 .borrow_mut()733 .insert(cache_key.clone(), CacheValue::Pending);734 let value = self.get_for_uncached(key, this).map_err(|e| {735 self.value_cache736 .borrow_mut()737 .insert(cache_key.clone(), CacheValue::Errored(e.clone()));738 e739 })?;740 self.value_cache.borrow_mut().insert(741 cache_key,742 value743 .as_ref()744 .map_or(CacheValue::NotFound, |v| CacheValue::Cached(v.clone())),745 );746 Ok(value)747 }748 fn get_for_uncached(&self, key: IStr, real_this: ObjValue) -> Result<Option<Val>> {749 match (self.this_entries.get(&key), &self.sup) {750 (Some(k), None) => Ok(Some(self.evaluate_this(k, real_this)?)),751 (Some(k), Some(super_obj)) => {752 let our = self.evaluate_this(k, real_this.clone())?;753 if k.flags.add() {754 super_obj755 .get_raw(key, real_this)?756 .map_or(Ok(Some(our.clone())), |v| {757 Ok(Some(evaluate_add_op(&v, &our)?))758 })759 } else {760 Ok(Some(our))761 }762 }763 (None, Some(super_obj)) => super_obj.get_raw(key, real_this),764 (None, None) => Ok(None),765 }766 }767 fn field_visibility(&self, name: IStr) -> Option<Visibility> {768 if let Some(m) = self.this_entries.get(&name) {769 Some(match &m.flags.visibility() {770 Visibility::Normal => self771 .sup772 .as_ref()773 .and_then(|super_obj| super_obj.field_visibility(name))774 .unwrap_or(Visibility::Normal),775 v => *v,776 })777 } else if let Some(super_obj) = &self.sup {778 super_obj.field_visibility(name)779 } else {780 None781 }782 }783784 fn run_assertions_raw(&self, real_this: ObjValue) -> Result<()> {785 if self.assertions.is_empty() {786 if let Some(super_obj) = &self.sup {787 super_obj.run_assertions_raw(real_this)?;788 }789 return Ok(());790 }791 if self.assertions_ran.borrow_mut().insert(real_this.clone()) {792 for assertion in self.assertions.iter() {793 if let Err(e) = assertion.run(self.sup.clone(), Some(real_this.clone())) {794 self.assertions_ran.borrow_mut().remove(&real_this);795 return Err(e);796 }797 }798 if let Some(super_obj) = &self.sup {799 super_obj.run_assertions_raw(real_this)?;800 }801 }802 Ok(())803 }804}805806impl PartialEq for ObjValue {807 fn eq(&self, other: &Self) -> bool {808 Cc::ptr_eq(&self.0, &other.0)809 }810}811812impl Eq for ObjValue {}813impl Hash for ObjValue {814 fn hash<H: Hasher>(&self, hasher: &mut H) {815 hasher.write_usize(addr_of!(*self.0) as usize);816 }817}818819#[allow(clippy::module_name_repetitions)]820pub struct ObjValueBuilder {821 sup: Option<ObjValue>,822 map: GcHashMap<IStr, ObjMember>,823 assertions: Vec<TraceBox<dyn ObjectAssertion>>,824 next_field_index: FieldIndex,825}826impl ObjValueBuilder {827 pub fn new() -> Self {828 Self::with_capacity(0)829 }830 pub fn with_capacity(capacity: usize) -> Self {831 Self {832 sup: None,833 map: GcHashMap::with_capacity(capacity),834 assertions: Vec::new(),835 next_field_index: FieldIndex::default(),836 }837 }838 pub fn reserve_asserts(&mut self, capacity: usize) -> &mut Self {839 self.assertions.reserve_exact(capacity);840 self841 }842 pub fn with_super(&mut self, super_obj: ObjValue) -> &mut Self {843 self.sup = Some(super_obj);844 self845 }846847 pub fn assert(&mut self, assertion: impl ObjectAssertion + 'static) -> &mut Self {848 self.assertions.push(tb!(assertion));849 self850 }851 pub fn field(&mut self, name: impl Into<IStr>) -> ObjMemberBuilder<ValueBuilder<'_>> {852 let field_index = self.next_field_index;853 self.next_field_index = self.next_field_index.next();854 ObjMemberBuilder::new(ValueBuilder(self), name.into(), field_index)855 }856 /// Preset for common method definiton pattern:857 /// Create a hidden field with the function value.858 ///859 /// `.field(name).hide().value(Val::function(value))`860 pub fn method(&mut self, name: impl Into<IStr>, value: impl Into<FuncVal>) -> &mut Self {861 self.field(name).hide().value(Val::Func(value.into()));862 self863 }864 pub fn try_method(865 &mut self,866 name: impl Into<IStr>,867 value: impl Into<FuncVal>,868 ) -> Result<&mut Self> {869 self.field(name).hide().try_value(Val::Func(value.into()))?;870 Ok(self)871 }872873 pub fn build(self) -> ObjValue {874 if self.sup.is_none() && self.map.is_empty() && self.assertions.is_empty() {875 return ObjValue::new_empty();876 }877 ObjValue::new(OopObject::new(878 self.sup,879 Cc::new(self.map),880 Cc::new(self.assertions),881 ))882 }883}884impl Default for ObjValueBuilder {885 fn default() -> Self {886 Self::with_capacity(0)887 }888}889890#[allow(clippy::module_name_repetitions)]891#[must_use = "value not added unless binding() was called"]892pub struct ObjMemberBuilder<Kind> {893 kind: Kind,894 name: IStr,895 add: bool,896 visibility: Visibility,897 original_index: FieldIndex,898 location: Option<ExprLocation>,899}900901#[allow(clippy::missing_const_for_fn)]902impl<Kind> ObjMemberBuilder<Kind> {903 pub(crate) fn new(kind: Kind, name: IStr, original_index: FieldIndex) -> Self {904 Self {905 kind,906 name,907 original_index,908 add: false,909 visibility: Visibility::Normal,910 location: None,911 }912 }913914 pub const fn with_add(mut self, add: bool) -> Self {915 self.add = add;916 self917 }918 pub fn add(self) -> Self {919 self.with_add(true)920 }921 pub fn with_visibility(mut self, visibility: Visibility) -> Self {922 self.visibility = visibility;923 self924 }925 pub fn hide(self) -> Self {926 self.with_visibility(Visibility::Hidden)927 }928 pub fn with_location(mut self, location: ExprLocation) -> Self {929 self.location = Some(location);930 self931 }932 fn build_member(self, binding: MaybeUnbound) -> (Kind, IStr, ObjMember) {933 (934 self.kind,935 self.name,936 ObjMember {937 flags: ObjFieldFlags::new(self.add, self.visibility),938 original_index: self.original_index,939 invoke: binding,940 location: self.location,941 },942 )943 }944}945946pub struct ValueBuilder<'v>(&'v mut ObjValueBuilder);947impl ObjMemberBuilder<ValueBuilder<'_>> {948 /// Inserts value, replacing if it is already defined949 pub fn value(self, value: impl Into<Val>) {950 let (receiver, name, member) =951 self.build_member(MaybeUnbound::Bound(Thunk::evaluated(value.into())));952 let entry = receiver.0.map.entry(name);953 entry.insert(member);954 }955956 /// Tries to insert value, returns an error if it was already defined957 pub fn try_value(self, value: impl Into<Val>) -> Result<()> {958 self.thunk(Thunk::evaluated(value.into()))959 }960 pub fn thunk(self, value: impl Into<Thunk<Val>>) -> Result<()> {961 self.binding(MaybeUnbound::Bound(value.into()))962 }963 pub fn bindable(self, bindable: impl Unbound<Bound = Val>) -> Result<()> {964 self.binding(MaybeUnbound::Unbound(Cc::new(tb!(bindable))))965 }966 pub fn binding(self, binding: MaybeUnbound) -> Result<()> {967 let (receiver, name, member) = self.build_member(binding);968 let location = member.location.clone();969 let old = receiver.0.map.insert(name.clone(), member);970 if old.is_some() {971 State::push(972 CallLocation(location.as_ref()),973 || format!("field <{}> initializtion", name.clone()),974 || bail!(DuplicateFieldName(name.clone())),975 )?;976 }977 Ok(())978 }979}980981pub struct ExtendBuilder<'v>(&'v mut ObjValue);982impl ObjMemberBuilder<ExtendBuilder<'_>> {983 pub fn value(self, value: impl Into<Val>) {984 self.binding(MaybeUnbound::Bound(Thunk::evaluated(value.into())));985 }986 pub fn bindable(self, bindable: TraceBox<dyn Unbound<Bound = Val>>) {987 self.binding(MaybeUnbound::Unbound(Cc::new(bindable)));988 }989 pub fn binding(self, binding: MaybeUnbound) {990 let (receiver, name, member) = self.build_member(binding);991 let new = receiver.0.clone();992 *receiver.0 = new.extend_with_raw_member(name, member);993 }994}crates/jrsonnet-evaluator/src/stack.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/stack.rs
+++ b/crates/jrsonnet-evaluator/src/stack.rs
@@ -8,6 +8,7 @@
}
#[cfg(feature = "nightly")]
+#[allow(clippy::thread_local_initializer_can_be_made_const)]
#[thread_local]
static STACK_LIMIT: StackLimit = StackLimit {
max_stack_size: Cell::new(200),
@@ -15,9 +16,11 @@
};
#[cfg(not(feature = "nightly"))]
thread_local! {
- static STACK_LIMIT: StackLimit = StackLimit {
- max_stack_size: Cell::new(200),
- current_depth: Cell::new(0),
+ static STACK_LIMIT: StackLimit = const {
+ StackLimit {
+ max_stack_size: Cell::new(200),
+ current_depth: Cell::new(0),
+ }
};
}
@@ -40,7 +43,7 @@
fn drop(&mut self) {
STACK_LIMIT
.current_depth
- .set(STACK_LIMIT.current_depth.get() - 1)
+ .set(STACK_LIMIT.current_depth.get() - 1);
}
#[cfg(not(feature = "nightly"))]
fn drop(&mut self) {
@@ -75,7 +78,7 @@
impl Drop for StackDepthLimitOverrideGuard {
#[cfg(feature = "nightly")]
fn drop(&mut self) {
- STACK_LIMIT.max_stack_size.set(self.old_limit)
+ STACK_LIMIT.max_stack_size.set(self.old_limit);
}
#[cfg(not(feature = "nightly"))]
fn drop(&mut self) {
crates/jrsonnet-evaluator/src/typed/conversions.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/typed/conversions.rs
+++ b/crates/jrsonnet-evaluator/src/typed/conversions.rs
@@ -143,6 +143,7 @@
_ => unreachable!(),
}
}
+ #[allow(clippy::cast_lossless)]
fn into_untyped(value: Self) -> Result<Val> {
Ok(Val::Num(value as f64))
}
@@ -199,6 +200,7 @@
}
}
+ #[allow(clippy::cast_lossless)]
fn into_untyped(value: Self) -> Result<Val> {
Ok(Val::Num(value.0 as f64))
}
crates/jrsonnet-rowan-parser/src/marker.rsdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/marker.rs
+++ b/crates/jrsonnet-rowan-parser/src/marker.rs
@@ -22,6 +22,7 @@
pub struct FinishedRanger {
pub start_token: usize,
+ #[allow(dead_code)]
pub end_token: usize,
}
impl FinishedRanger {
crates/jrsonnet-rowan-parser/src/tests.rsdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/tests.rs
+++ b/crates/jrsonnet-rowan-parser/src/tests.rs
@@ -1,4 +1,5 @@
-#![cfg(never)]
+// `never`
+#![cfg(any())]
use miette::{
Diagnostic, GraphicalReportHandler, GraphicalTheme, LabeledSpan, ThemeCharacters, ThemeStyles,
crates/jrsonnet-stdlib/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-stdlib/Cargo.toml
+++ b/crates/jrsonnet-stdlib/Cargo.toml
@@ -12,19 +12,23 @@
[features]
default = ["codegenerated-stdlib"]
-# Speed-up initialization by generating code for parsed stdlib, instead
-# of invoking parser for it
+# Speed-up initialization by generating code for parsed stdlib,
+# instead of invoking parser for it.
+# This is mutually exclusive with `serialized-stdlib`.
codegenerated-stdlib = ["jrsonnet-parser/structdump"]
+# Use the embedded serialized stdlib.
+# This is mutually exclusive with `codegenerated-stdlib`.
+serialized-stdlib = []
# Enables legacy `std.thisFile` support, at the cost of worse caching
legacy-this-file = []
# Add order preservation flag to some functions
exp-preserve-order = ["jrsonnet-evaluator/exp-preserve-order"]
# Bigint type
-exp-bigint = ["num-bigint", "jrsonnet-evaluator/exp-bigint"]
+exp-bigint = ["dep:num-bigint", "jrsonnet-evaluator/exp-bigint"]
exp-null-coaelse = ["jrsonnet-parser/exp-null-coaelse", "jrsonnet-evaluator/exp-null-coaelse"]
# std.regexMatch and other helpers
-exp-regex = ["regex", "lru", "rustc-hash"]
+exp-regex = ["dep:regex", "dep:lru", "dep:rustc-hash"]
[dependencies]
jrsonnet-evaluator.workspace = true
crates/jrsonnet-stdlib/src/expr.rsdiffbeforeafterboth--- a/crates/jrsonnet-stdlib/src/expr.rs
+++ b/crates/jrsonnet-stdlib/src/expr.rs
@@ -1,7 +1,11 @@
use jrsonnet_parser::LocExpr;
pub fn stdlib_expr() -> LocExpr {
- #[cfg(feature = "serialized-stdlib")]
+ #[cfg(all(feature = "serialized-stdlib", feature = "codegenerated-stdlib"))]
+ compile_error!(
+ "features `serialized-stdlib` and `codegenerated-stdlib` are mutually exclusive"
+ );
+ #[cfg(all(feature = "serialized-stdlib", not(feature = "codegenerated-stdlib")))]
{
use bincode::{BincodeRead, DefaultOptions, Options};
use serde::{Deserialize, Deserializer};
@@ -77,7 +81,7 @@
LocExpr::deserialize(&mut deserializer).unwrap()
}
- #[cfg(feature = "codegenerated-stdlib")]
+ #[cfg(all(feature = "codegenerated-stdlib", not(feature = "serialized-stdlib")))]
{
mod structdump_import {
pub(super) use std::{option::Option, rc::Rc, vec};
@@ -88,7 +92,7 @@
include!(concat!(env!("OUT_DIR"), "/stdlib.rs"))
}
- #[cfg(not(feature = "codegenerated-stdlib"))]
+ #[cfg(not(any(feature = "serialized-stdlib", feature = "codegenerated-stdlib")))]
{
use jrsonnet_parser::Source;
crates/jrsonnet-stdlib/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-stdlib/src/lib.rs
+++ b/crates/jrsonnet-stdlib/src/lib.rs
@@ -1,9 +1,15 @@
+#![allow(clippy::similar_names)]
+
use std::{
cell::{Ref, RefCell, RefMut},
collections::HashMap,
rc::Rc,
};
+pub use arrays::*;
+pub use compat::*;
+pub use encoding::*;
+pub use hash::*;
use jrsonnet_evaluator::{
error::{ErrorKind::*, Result},
function::{CallLocation, FuncVal, TlaArg},
@@ -13,40 +19,37 @@
};
use jrsonnet_gcmodule::Trace;
use jrsonnet_parser::Source;
-
-mod expr;
-mod types;
-pub use types::*;
-mod arrays;
-pub use arrays::*;
-mod math;
+pub use manifest::*;
pub use math::*;
-mod operator;
+pub use misc::*;
+pub use objects::*;
pub use operator::*;
-mod sort;
+pub use parse::*;
+pub use sets::*;
pub use sort::*;
-mod hash;
-pub use hash::*;
+pub use strings::*;
+pub use types::*;
+
+#[cfg(feature = "exp-regex")]
+pub use crate::regex::*;
+
+mod arrays;
+mod compat;
mod encoding;
-pub use encoding::*;
+mod expr;
+mod hash;
+mod manifest;
+mod math;
+mod misc;
mod objects;
-pub use objects::*;
-mod manifest;
-pub use manifest::*;
+mod operator;
mod parse;
-pub use parse::*;
-mod strings;
-pub use strings::*;
-mod misc;
-pub use misc::*;
-mod sets;
-pub use sets::*;
-mod compat;
-pub use compat::*;
#[cfg(feature = "exp-regex")]
mod regex;
-#[cfg(feature = "exp-regex")]
-pub use crate::regex::*;
+mod sets;
+mod sort;
+mod strings;
+mod types;
#[allow(clippy::too_many_lines)]
pub fn stdlib_uncached(settings: Rc<RefCell<Settings>>) -> ObjValue {
@@ -244,9 +247,7 @@
);
builder.method(
"regexGlobalReplace",
- builtin_regex_global_replace {
- cache: regex_cache.clone(),
- },
+ builtin_regex_global_replace { cache: regex_cache },
);
};
@@ -395,16 +396,15 @@
}
#[cfg(feature = "legacy-this-file")]
fn populate(&self, source: Source, builder: &mut ContextBuilder) {
- use jrsonnet_evaluator::val::StrValue;
-
let mut std = ObjValueBuilder::new();
std.with_super(self.stdlib_obj.clone());
- std.field("thisFile")
- .hide()
- .value(match source.source_path().path() {
- Some(p) => self.settings().path_resolver.resolve(p),
- None => source.source_path().to_string(),
- });
+ std.field("thisFile").hide().value({
+ let source_path = source.source_path();
+ source_path.path().map_or_else(
+ || source_path.to_string(),
+ |p| self.settings().path_resolver.resolve(p),
+ )
+ });
let stdlib_with_this_file = std.build();
builder.bind("std", Thunk::evaluated(Val::Obj(stdlib_with_this_file)));
crates/jrsonnet-stdlib/src/regex.rsdiffbeforeafterboth--- a/crates/jrsonnet-stdlib/src/regex.rs
+++ b/crates/jrsonnet-stdlib/src/regex.rs
@@ -50,16 +50,16 @@
for ele in captured.iter().skip(1) {
if let Some(ele) = ele {
- captures.push(Val::Str(StrValue::Flat(ele.as_str().into())))
+ captures.push(Val::Str(StrValue::Flat(ele.as_str().into())));
} else {
- captures.push(Val::Str(StrValue::Flat(IStr::empty())))
+ captures.push(Val::Str(StrValue::Flat(IStr::empty())));
}
}
for (i, name) in regex
.capture_names()
.skip(1)
.enumerate()
- .flat_map(|(i, v)| Some((i, v?)))
+ .filter_map(|(i, v)| Some((i, v?)))
{
let capture = captures[i].clone();
named_captures.field(name).try_value(capture)?;
flake.lockdiffbeforeafterboth--- a/flake.lock
+++ b/flake.lock
@@ -7,11 +7,11 @@
]
},
"locked": {
- "lastModified": 1711299236,
- "narHash": "sha256-6/JsyozOMKN8LUGqWMopKTSiK8N79T8Q+hcxu2KkTXg=",
+ "lastModified": 1714536327,
+ "narHash": "sha256-zu4+LcygJwdyFHunTMeDFltBZ9+hoWvR/1A7IEy7ChA=",
"owner": "ipetkov",
"repo": "crane",
- "rev": "880573f80d09e18a11713f402b9e6172a085449f",
+ "rev": "3124551aebd8db15d4560716d4f903bd44c64e4a",
"type": "github"
},
"original": {
@@ -25,11 +25,11 @@
"systems": "systems"
},
"locked": {
- "lastModified": 1705309234,
- "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
+ "lastModified": 1710146030,
+ "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
- "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
+ "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
@@ -40,11 +40,11 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1705391267,
- "narHash": "sha256-gGVm9QudiRtYTX8PN9cTTy7uuJcL4I2lRMoPx496kXk=",
+ "lastModified": 1714595735,
+ "narHash": "sha256-8MDOiHrg2mOylcC7wpx1U1mk9V5VranG7wKyenhHnic=",
"owner": "nixos",
"repo": "nixpkgs",
- "rev": "41a9a7f170c740acb24f3390323877d11c69d5ee",
+ "rev": "9d7a1659bc5c6be24ac46407b91807c6e3e0227d",
"type": "github"
},
"original": {
@@ -71,11 +71,11 @@
]
},
"locked": {
- "lastModified": 1705371439,
- "narHash": "sha256-P1kulUXpYWkcrjiX3sV4j8ACJZh9XXSaaD+jDLBDLKo=",
+ "lastModified": 1714529851,
+ "narHash": "sha256-YMKJW880f7LHXVRzu93xa6Ek+QLECIu0IRQbXbzZe38=",
"owner": "oxalica",
"repo": "rust-overlay",
- "rev": "b21f3c0d5bf0f0179f5f0140e8e0cd099618bd04",
+ "rev": "9ca720fdcf7865385ae3b93ecdf65f1a64cb475e",
"type": "github"
},
"original": {
rust-toolchain.tomldiffbeforeafterboth--- a/rust-toolchain.toml
+++ b/rust-toolchain.toml
@@ -1,3 +1,3 @@
[toolchain]
-channel = "nightly-2024-01-10"
+channel = "nightly-2024-05-10"
components = ["rustfmt", "clippy", "rust-analyzer", "rust-src"]
tests/tests/golden.rsdiffbeforeafterboth--- a/tests/tests/golden.rs
+++ b/tests/tests/golden.rs
@@ -27,11 +27,7 @@
Ok(v) => v,
Err(e) => return trace_format.format(&e).unwrap(),
};
- match v.manifest(
- JsonFormat::default(),
- #[cfg(feature = "exp-preserve-order")]
- false,
- ) {
+ match v.manifest(JsonFormat::default()) {
Ok(v) => v.to_string(),
Err(e) => trace_format.format(&e).unwrap(),
}
xtask/src/sourcegen/ast.rsdiffbeforeafterboth--- a/xtask/src/sourcegen/ast.rs
+++ b/xtask/src/sourcegen/ast.rs
@@ -62,6 +62,7 @@
#[derive(Debug, Clone)]
pub struct AstTokenEnumSrc {
+ #[allow(dead_code)]
pub doc: Vec<String>,
pub name: String,
pub variants: Vec<String>,
xtask/src/sourcegen/kinds.rsdiffbeforeafterboth--- a/xtask/src/sourcegen/kinds.rs
+++ b/xtask/src/sourcegen/kinds.rs
@@ -14,6 +14,7 @@
Error {
grammar_name: String,
name: String,
+ #[allow(dead_code)]
/// Is this error returned by lexer directly, or from lex.rs
is_lexer_error: bool,
regex: Option<String>,