From ec395ac14c6e7482fe8a26ebc8a01ccba0337329 Mon Sep 17 00:00:00 2001 From: Miles Wirht <114884788+philocalyst@users.noreply.github.com> Date: Mon, 15 Jun 2026 18:42:57 -0400 Subject: [PATCH] My stab at CI (#66) --- .cargo/ci-config.toml | 2 - .cargo/config.toml | 34 ++- .github/CODEOWNERS | 11 + .github/workflows/audit.yml | 36 +++ .github/workflows/ci.yml | 267 ++++++++++++++++++ .github/workflows/release.yml | 105 +++++++ Cargo.lock | 12 +- Cargo.toml | 171 +++++------ clippy.toml | 31 +- crates/gpui/Cargo.toml | 32 +-- crates/gpui/examples/learn/blur.rs | 8 +- crates/gpui/src/app.rs | 4 +- crates/gpui/src/elements/img.rs | 35 ++- crates/gpui/src/elements/surface.rs | 18 +- crates/gpui/src/style.rs | 3 +- crates/gpui/src/transition.rs | 2 +- crates/gpui/src/window.rs | 13 +- crates/gpui_elements/Cargo.toml | 3 + crates/gpui_linux/Cargo.toml | 96 +++---- crates/gpui_linux/src/linux/wayland/client.rs | 2 +- crates/gpui_linux/src/linux/x11/client.rs | 2 +- crates/gpui_macros/Cargo.toml | 2 +- crates/gpui_platform/Cargo.toml | 7 +- crates/gpui_web/Cargo.toml | 72 ++--- .../examples/hello_web/.cargo/config.toml | 24 +- crates/gpui_wgpu/src/wgpu_renderer.rs | 10 +- crates/gpui_windows/src/directx_renderer.rs | 4 + deny.toml | 60 ++++ flake.nix | 8 +- justfile | 2 +- tooling/perf/Cargo.toml | 6 +- typos.toml | 13 +- 32 files changed, 815 insertions(+), 280 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/workflows/audit.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml create mode 100644 deny.toml diff --git a/.cargo/ci-config.toml b/.cargo/ci-config.toml index 6a5feece64..7a740adfd7 100644 --- a/.cargo/ci-config.toml +++ b/.cargo/ci-config.toml @@ -14,5 +14,3 @@ rustflags = ["-D", "warnings"] # We don't need fullest debug information for dev stuff (tests etc.) in CI. [profile.dev] debug = "limited" - - diff --git a/.cargo/config.toml b/.cargo/config.toml index 8750875d86..c194bf5ce8 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -9,6 +9,32 @@ test-all = "test --workspace --no-fail-fast" test-doc = "test --workspace --doc" build-all = "build --workspace --all-targets" ci-fmt = "fmt --all -- --check" +xtask = "run --package xtask --" +perf-test = [ + "test", + "--profile", + "release-fast", + "--lib", + "--bins", + "--tests", + "--all-features", + "--config", + "target.'cfg(true)'.runner='cargo run -p perf --release'", + "--config", + "target.'cfg(true)'.rustflags=[\"--cfg\", \"perf_enabled\"]", +] +# Keep similar flags here to share some ccache +perf-compare = [ + "run", + "--profile", + "release-fast", + "-p", + "perf", + "--config", + "target.'cfg(true)'.rustflags=[\"--cfg\", \"perf_enabled\"]", + "--", + "compare", +] [profile.ci] inherits = "dev" @@ -17,10 +43,10 @@ incremental = false [target.'cfg(target_os = "windows")'] rustflags = [ - "--cfg", - "windows_slim_errors", # This cfg will reduce the size of `windows::core::Error` from 16 bytes to 4 bytes - "-C", - "target-feature=+crt-static", # This fixes the linking issue when compiling livekit on Windows + "--cfg", + "windows_slim_errors", # This cfg will reduce the size of `windows::core::Error` from 16 bytes to 4 bytes + "-C", + "target-feature=+crt-static", # This fixes the linking issue when compiling livekit on Windows ] # We need lld to link libwebrtc.a successfully on aarch64-linux diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000000..2f4a4501c3 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,11 @@ +# Default code owners for gpui-ce +* @gpui-ce/maintainers + +# CI/CD configuration +/.github/ @gpui-ce/maintainers + +# Platform-specific code +/crates/gpui_macos/ @gpui-ce/macos-maintainers +/crates/gpui_linux/ @gpui-ce/linux-maintainers +/crates/gpui_windows/ @gpui-ce/windows-maintainers +/crates/gpui_web/ @gpui-ce/web-maintainers diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml new file mode 100644 index 0000000000..9d220370da --- /dev/null +++ b/.github/workflows/audit.yml @@ -0,0 +1,36 @@ +# Security audit workflow +name: Security Audit + +on: + push: + branches: [main] + paths: + - '**/Cargo.toml' + - '**/Cargo.lock' + pull_request: + paths: + - '**/Cargo.toml' + - '**/Cargo.lock' + schedule: + - cron: '0 0 * * 1' + workflow_dispatch: + +jobs: + # cargo-audit: vulnerability scanning (advisory DB) + cargo-audit: + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/checkout@v4 + - uses: taiki-e/install-action@cargo-audit + - uses: rustsec/audit-check@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + # cargo-deny: license compliance + advisory + duplicate detection + cargo-deny: + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/checkout@v4 + - uses: EmbarkStudios/cargo-deny-action@v2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..de210d3156 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,267 @@ +# Main CI workflow +name: CI + +# TODO: Setup coverage using cargo-mutants, but only for minor/major version bumps (would probably take hours :() -- also our testing infra sucks + +on: + push: + branches: [main, 'v[0-9]+.[0-9]+.x'] + pull_request: + branches: ['**'] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: 1 + CARGO_INCREMENTAL: 0 + +jobs: + # Change detection + orchestrate: + runs-on: ubuntu-latest + outputs: + run_tests: ${{ steps.filter.outputs.run_tests }} + run_style: ${{ steps.filter.outputs.run_style }} + run_docs: ${{ steps.filter.outputs.run_docs }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: ${{ github.ref == 'refs/heads/main' && 2 || 350 }} + - id: filter + run: | + if [ -z "$GITHUB_BASE_REF" ]; then + COMPARE_REV="$(git rev-parse HEAD~1)" + else + git fetch origin "$GITHUB_BASE_REF" --depth=350 + COMPARE_REV="$(git merge-base "origin/${GITHUB_BASE_REF}" HEAD)" + fi + CHANGED_FILES="$(git diff --name-only "$COMPARE_REV" "$GITHUB_SHA")" + + check_pattern() { + local name="$1" pattern="$2" invert="${3:-false}" + if [ "$invert" = "true" ]; then + echo "$CHANGED_FILES" | grep -qvP "$pattern" && echo "${name}=true" >> "$GITHUB_OUTPUT" || echo "${name}=false" >> "$GITHUB_OUTPUT" + else + echo "$CHANGED_FILES" | grep -qP "$pattern" && echo "${name}=true" >> "$GITHUB_OUTPUT" || echo "${name}=false" >> "$GITHUB_OUTPUT" + fi + } + + check_pattern "run_tests" '^(docs/|\.github/(ISSUE_TEMPLATE|workflows/)|README\.md|CHANGELOG\.md)' true + check_pattern "run_style" '\.(rs|toml)$|rust-toolchain\.toml|\.cargo/|clippy\.toml|typos\.toml' + check_pattern "run_docs" '^docs/|\.rs$' + + # Formatting + fmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: rustfmt + - uses: hustcer/setup-nu@v3 + - uses: extractions/setup-just@v2 + - run: just fmt-check + + # Clippy + clippy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: clippy + - uses: Swatinem/rust-cache@v2 + - name: Install system deps + run: | + sudo apt-get update + sudo apt-get install -y libxkbcommon-dev libxkbcommon-x11-dev libwayland-dev libx11-dev libxcb-shape0-dev libxcb-xfixes0-dev libfontconfig-dev + - uses: hustcer/setup-nu@v3 + - uses: extractions/setup-just@v2 + - run: just clippy + + # Spell check + typos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: crate-ci/typos@v1.47.2 + with: + config: typos.toml + + # TOML formatting + taplo: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: uncenter/setup-taplo@v1 + - run: taplo fmt --check + + # Unused dependencies + machete: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2 + - uses: taiki-e/install-action@cargo-machete + - uses: hustcer/setup-nu@v3 + - uses: extractions/setup-just@v2 + - run: just machete + + # MSRV + msrv: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: 1.92.0 + - uses: Swatinem/rust-cache@v2 + - name: Install system deps + run: | + sudo apt-get update + sudo apt-get install -y libxkbcommon-dev libxkbcommon-x11-dev libwayland-dev libx11-dev libxcb-shape0-dev libxcb-xfixes0-dev libfontconfig-dev + - uses: hustcer/setup-nu@v3 + - uses: extractions/setup-just@v2 + - run: just msrv-check + + # WASM target (nightly + atomics) + check-wasm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install nightly toolchain with rust-src and WASM target + run: rustup toolchain install nightly --component rust-src --target wasm32-unknown-unknown + - uses: Swatinem/rust-cache@v2 + - uses: hustcer/setup-nu@v3 + - uses: extractions/setup-just@v2 + - run: just check-wasm-atomics + + # Linux build + test + test-linux: + runs-on: ubuntu-latest + needs: [orchestrate] + if: needs.orchestrate.outputs.run_tests == 'true' + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + - uses: Swatinem/rust-cache@v2 + - name: Install system deps + run: | + sudo apt-get update + sudo apt-get install -y \ + libxkbcommon-dev libwayland-dev libx11-dev \ + libxcb-shape0-dev libxcb-xfixes0-dev \ + libxcb-randr0-dev libxcb-xinput-dev \ + libxkbcommon-x11-dev libegl1-mesa-dev \ + libgles2-mesa-dev libglib2.0-dev libfontconfig-dev + - uses: hustcer/setup-nu@v3 + - uses: extractions/setup-just@v2 + - run: just build + - run: just test + - run: just test-doc + + # macOS build + test + test-mac: + runs-on: macos-latest + needs: [orchestrate] + if: needs.orchestrate.outputs.run_tests == 'true' + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + - uses: Swatinem/rust-cache@v2 + - uses: hustcer/setup-nu@v3 + - uses: extractions/setup-just@v2 + - run: just build + - run: just test + - run: just test-doc + + # Windows build + test + test-windows: + runs-on: windows-latest + needs: [orchestrate] + if: needs.orchestrate.outputs.run_tests == 'true' + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + - uses: Swatinem/rust-cache@v2 + - uses: hustcer/setup-nu@v3 + - uses: extractions/setup-just@v2 + - run: just build + - run: just test + + # Examples + check-examples: + runs-on: ubuntu-latest + needs: [orchestrate] + if: needs.orchestrate.outputs.run_tests == 'true' + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + - uses: Swatinem/rust-cache@v2 + - name: Install system deps + run: | + sudo apt-get update + sudo apt-get install -y libxkbcommon-dev libxkbcommon-x11-dev libwayland-dev libx11-dev libxcb-shape0-dev libxcb-xfixes0-dev libfontconfig-dev + - name: Add WASM target + run: rustup target add wasm32-unknown-unknown + - uses: hustcer/setup-nu@v3 + - uses: extractions/setup-just@v2 + - run: just check-examples + + # Beta toolchain (scheduled only) + beta-test: + if: github.event_name == 'schedule' + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/checkout@v4 + - run: rustup update beta && rustup default beta + - uses: Swatinem/rust-cache@v2 + - name: Install system deps + run: | + sudo apt-get update + sudo apt-get install -y libxkbcommon-dev libxkbcommon-x11-dev libwayland-dev libx11-dev libxcb-shape0-dev libxcb-xfixes0-dev libfontconfig-dev + - uses: hustcer/setup-nu@v3 + - uses: extractions/setup-just@v2 + - run: just check + - run: just test + + # Gate job + tests-pass: + if: always() + needs: + - fmt + - clippy + - typos + - taplo + - machete + - msrv + - check-wasm + - test-linux + - test-mac + - test-windows + - check-examples + runs-on: ubuntu-latest + steps: + - run: | + set +e + EXIT_CODE=0 + check_result() { + echo "* $1: $2" + if [[ "$2" != "skipped" && "$2" != "success" ]]; then EXIT_CODE=1; fi + } + check_result fmt ${{ needs.fmt.result }} + check_result clippy ${{ needs.clippy.result }} + check_result typos ${{ needs.typos.result }} + check_result taplo ${{ needs.taplo.result }} + check_result machete ${{ needs.machete.result }} + check_result msrv ${{ needs.msrv.result }} + check_result check-wasm ${{ needs.check-wasm.result }} + check_result test-linux ${{ needs.test-linux.result }} + check_result test-mac ${{ needs.test-mac.result }} + check_result test-windows ${{ needs.test-windows.result }} + check_result check-examples ${{ needs.check-examples.result }} + exit $EXIT_CODE diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..2ae23c790d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,105 @@ +# Publish to crates on a version tag push +name: Release + +on: + push: + tags: + - 'v*' + workflow_dispatch: + inputs: + dry_run: + description: 'Dry run (no actual publish)' + required: false + default: 'false' + +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: 1 + +jobs: + # Determine pre-release status + prerelease: + runs-on: ubuntu-latest + outputs: + value: ${{ steps.check.outputs.value }} + version: ${{ steps.check.outputs.version }} + steps: + - uses: actions/checkout@v4 + - id: check + run: | + VERSION="${GITHUB_REF_NAME#v}" + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + if [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "value=false" >> "$GITHUB_OUTPUT" + else + echo "value=true" >> "$GITHUB_OUTPUT" + fi + + # Run full CI on the tag via justfile + verify: + needs: [prerelease] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: clippy, rustfmt + - uses: Swatinem/rust-cache@v2 + - name: Install system deps + run: | + sudo apt-get update + sudo apt-get install -y \ + libxkbcommon-dev libwayland-dev libx11-dev \ + libxcb-shape0-dev libxcb-xfixes0-dev + - uses: hustcer/setup-nu@v3 + - uses: extractions/setup-just@v2 + - run: just fmt-check + - run: just clippy + - run: just build + - run: just test + - run: just test-doc + + # Verify packages are publishable + verify-publish: + needs: [prerelease, verify] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + - uses: Swatinem/rust-cache@v2 + - name: Dry-run publish check + run: | + for crate in crates/gpui_shared_string crates/gpui_macros crates/gpui crates/gpui_wgpu crates/gpui_tokio crates/gpui_platform; do + echo "Checking $crate..." + cargo publish --dry-run --manifest-path "$crate/Cargo.toml" 2>&1 | head -5 + done + + # Publish to crates.io + publish: + needs: [prerelease, verify-publish] + runs-on: ubuntu-latest + if: github.event_name != 'workflow_dispatch' || github.event.inputs.dry_run != 'true' + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + - uses: Swatinem/rust-cache@v2 + - uses: hustcer/setup-nu@v3 + - uses: extractions/setup-just@v2 + - run: just publish + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + + # Create GitHub Release + github-release: + needs: [prerelease, publish] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - uses: softprops/action-gh-release@v2 + with: + draft: true + prerelease: ${{ needs.prerelease.outputs.value }} + generate_release_notes: true + name: ${{ needs.prerelease.outputs.version }} diff --git a/Cargo.lock b/Cargo.lock index de1f1973c0..e46d802e70 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2565,7 +2565,6 @@ dependencies = [ "anyhow", "bytemuck", "collections 0.1.0 (git+https://github.com/zed-industries/zed?rev=876ec5a8a074ba83cce2129ed4d76b59c05a37e9)", - "core-video", "cosmic-text", "criterion", "etagere", @@ -4099,6 +4098,15 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" +[[package]] +name = "perf" +version = "0.1.0" +dependencies = [ + "collections 0.1.0 (git+https://github.com/zed-industries/zed?rev=876ec5a8a074ba83cce2129ed4d76b59c05a37e9)", + "serde", + "serde_json", +] + [[package]] name = "perf" version = "0.1.0" @@ -6155,7 +6163,7 @@ name = "util_macros" version = "0.1.0" source = "git+https://github.com/zed-industries/zed?rev=876ec5a8a074ba83cce2129ed4d76b59c05a37e9#876ec5a8a074ba83cce2129ed4d76b59c05a37e9" dependencies = [ - "perf", + "perf 0.1.0 (git+https://github.com/zed-industries/zed?rev=876ec5a8a074ba83cce2129ed4d76b59c05a37e9)", "quote", "syn", ] diff --git a/Cargo.toml b/Cargo.toml index 3f1be0109a..25c5b40144 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,20 +1,19 @@ [workspace] members = [ - "./crates/gpui/", - "./crates/gpui_web/", - "./crates/gpui_wgpu/", - "./crates/gpui_linux/", - "./crates/gpui_macos/", - "./crates/gpui_tokio/", - "./crates/gpui_macros/", - "./crates/gpui_windows/", - "./crates/gpui_platform/", - "./crates/gpui_shared_string/", - "./crates/gpui_elements/", -] -default-members = [ - "./crates/gpui/", + "./crates/gpui/", + "./crates/gpui_web/", + "./crates/gpui_wgpu/", + "./crates/gpui_linux/", + "./crates/gpui_macos/", + "./crates/gpui_tokio/", + "./crates/gpui_macros/", + "./crates/gpui_windows/", + "./crates/gpui_platform/", + "./crates/gpui_shared_string/", + "./crates/gpui_elements/", + "./tooling/perf/", ] +default-members = ["./crates/gpui/"] resolver = "3" [workspace.package] @@ -37,15 +36,15 @@ bitflags = "2.6.0" collections = { git = "https://github.com/zed-industries/zed", rev = "876ec5a8a074ba83cce2129ed4d76b59c05a37e9", version = "0.1.0" } ctor = "1.0.6" derive_more = { version = "2.1.1", features = [ - "add", - "add_assign", - "deref", - "deref_mut", - "display", - "from_str", - "mul", - "mul_assign", - "not", + "add", + "add_assign", + "deref", + "deref_mut", + "display", + "from_str", + "mul", + "mul_assign", + "not", ] } futures = "0.3.32" futures-concurrency = "7.7.1" @@ -56,7 +55,9 @@ itertools = "0.14.0" log = { version = "0.4.16", features = ["kv_unstable_serde", "serde"] } parking_lot = "0.12.1" postage = { version = "0.5", features = ["futures-traits"] } -proptest = { git = "https://github.com/proptest-rs/proptest", rev = "3dca198a8fef1b32e3a66f1e1897c955b4dc5b5b", features = ["attr-macro"] } +proptest = { git = "https://github.com/proptest-rs/proptest", rev = "3dca198a8fef1b32e3a66f1e1897c955b4dc5b5b", features = [ + "attr-macro", +] } chrono = { version = "0.4", features = ["serde"] } profiling = "1" rand = "0.9.4" @@ -98,19 +99,21 @@ proc-macro2 = "1.0.93" syn = { version = "2.0.101", features = ["full", "extra-traits", "visit-mut"] } quote = "1.0.9" ashpd = { version = "0.13", default-features = false, features = [ - "async-io", - "notification", - "open_uri", - "file_chooser", - "settings", - "trash" + "async-io", + "notification", + "open_uri", + "file_chooser", + "settings", + "trash", ] } libc = "0.2" smol = "2.0" util = { git = "https://github.com/zed-industries/zed", rev = "876ec5a8a074ba83cce2129ed4d76b59c05a37e9" } wgpu = { git = "https://github.com/zed-industries/wgpu.git", rev = "357a0c56e0070480ad9daea5d2eaa83150b79e88" } criterion = { version = "0.5", features = ["html_reports"] } -objc2-app-kit = { version = "0.3", default-features = false, features = [ "NSGraphics" ] } +objc2-app-kit = { version = "0.3", default-features = false, features = [ + "NSGraphics", +] } semver = { version = "1.0", features = ["serde"] } windows-core = "0.61" tokio = { version = "1" } @@ -132,59 +135,59 @@ gpui_tokio = { path = "./crates/gpui_tokio/" } [workspace.dependencies.windows] version = "0.61" features = [ - "Foundation_Numerics", - "Globalization_DateTimeFormatting", - "Storage_Search", - "Storage_Streams", - "System_Threading", - "UI_ViewManagement", - "Wdk_System_SystemServices", - "Win32_Foundation", - "Win32_Globalization", - "Win32_Graphics_Direct3D", - "Win32_Graphics_Direct3D11", - "Win32_Graphics_Direct3D_Fxc", - "Win32_Graphics_DirectComposition", - "Win32_Graphics_DirectWrite", - "Win32_Graphics_DirectManipulation", - "Win32_Graphics_Dwm", - "Win32_Graphics_Dxgi", - "Win32_Graphics_Dxgi_Common", - "Win32_Graphics_Gdi", - "Win32_Graphics_Imaging", - "Win32_Graphics_Hlsl", - "Win32_Networking_WinSock", - "Win32_Security", - "Win32_Security_Credentials", - "Win32_Security_Cryptography", - "Win32_Storage_FileSystem", - "Win32_System_Com", - "Win32_System_Com_StructuredStorage", - "Win32_System_Console", - "Win32_System_Diagnostics_Debug", - "Win32_System_DataExchange", - "Win32_System_IO", - "Win32_System_LibraryLoader", - "Win32_System_Memory", - "Win32_System_Ole", - "Win32_System_Performance", - "Win32_System_Pipes", - "Win32_System_RestartManager", - "Win32_System_SystemInformation", - "Win32_System_SystemServices", - "Win32_System_Threading", - "Win32_System_Variant", - "Win32_System_WinRT", - "Win32_UI_Controls", - "Win32_UI_HiDpi", - "Win32_UI_Input_Ime", - "Win32_UI_Input_KeyboardAndMouse", - "Win32_UI_Input_Pointer", - "Win32_UI_Shell", - "Win32_UI_Shell_Common", - "Win32_UI_Shell_PropertiesSystem", - "Win32_UI_WindowsAndMessaging", - "Win32_Media", + "Foundation_Numerics", + "Globalization_DateTimeFormatting", + "Storage_Search", + "Storage_Streams", + "System_Threading", + "UI_ViewManagement", + "Wdk_System_SystemServices", + "Win32_Foundation", + "Win32_Globalization", + "Win32_Graphics_Direct3D", + "Win32_Graphics_Direct3D11", + "Win32_Graphics_Direct3D_Fxc", + "Win32_Graphics_DirectComposition", + "Win32_Graphics_DirectWrite", + "Win32_Graphics_DirectManipulation", + "Win32_Graphics_Dwm", + "Win32_Graphics_Dxgi", + "Win32_Graphics_Dxgi_Common", + "Win32_Graphics_Gdi", + "Win32_Graphics_Imaging", + "Win32_Graphics_Hlsl", + "Win32_Networking_WinSock", + "Win32_Security", + "Win32_Security_Credentials", + "Win32_Security_Cryptography", + "Win32_Storage_FileSystem", + "Win32_System_Com", + "Win32_System_Com_StructuredStorage", + "Win32_System_Console", + "Win32_System_Diagnostics_Debug", + "Win32_System_DataExchange", + "Win32_System_IO", + "Win32_System_LibraryLoader", + "Win32_System_Memory", + "Win32_System_Ole", + "Win32_System_Performance", + "Win32_System_Pipes", + "Win32_System_RestartManager", + "Win32_System_SystemInformation", + "Win32_System_SystemServices", + "Win32_System_Threading", + "Win32_System_Variant", + "Win32_System_WinRT", + "Win32_UI_Controls", + "Win32_UI_HiDpi", + "Win32_UI_Input_Ime", + "Win32_UI_Input_KeyboardAndMouse", + "Win32_UI_Input_Pointer", + "Win32_UI_Shell", + "Win32_UI_Shell_Common", + "Win32_UI_Shell_PropertiesSystem", + "Win32_UI_WindowsAndMessaging", + "Win32_Media", ] [workspace.lints.rust] diff --git a/clippy.toml b/clippy.toml index 7977140657..eb4e8ea87c 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,24 +1,23 @@ allow-private-module-inception = true avoid-breaking-exported-api = false ignore-interior-mutability = [ - # Suppresses clippy::mutable_key_type, which is a false positive as the Eq - # and Hash impls do not use fields with interior mutability. - "agent_ui::context::AgentContextKey" + # Suppresses clippy::mutable_key_type, which is a false positive as the Eq + # and Hash impls do not use fields with interior mutability. + "agent_ui::context::AgentContextKey", ] disallowed-methods = [ - { path = "std::process::Command::spawn", reason = "Spawning `std::process::Command` can block the current thread for an unknown duration", replacement = "smol::process::Command::spawn" }, - { path = "std::process::Command::output", reason = "Spawning `std::process::Command` can block the current thread for an unknown duration", replacement = "smol::process::Command::output" }, - { path = "std::process::Command::status", reason = "Spawning `std::process::Command` can block the current thread for an unknown duration", replacement = "smol::process::Command::status" }, - { path = "std::process::Command::stdin", reason = "`smol::process::Command::from()` does not preserve stdio configuration", replacement = "smol::process::Command::stdin" }, - { path = "std::process::Command::stdout", reason = "`smol::process::Command::from()` does not preserve stdio configuration", replacement = "smol::process::Command::stdout" }, - { path = "std::process::Command::stderr", reason = "`smol::process::Command::from()` does not preserve stdio configuration", replacement = "smol::process::Command::stderr" }, - { path = "serde_json::from_reader", reason = "Parsing from a buffer is much slower than first reading the buffer into a Vec/String, see https://github.com/serde-rs/json/issues/160#issuecomment-253446892. Use `serde_json::from_slice` instead." }, - { path = "serde_json_lenient::from_reader", reason = "Parsing from a buffer is much slower than first reading the buffer into a Vec/String, see https://github.com/serde-rs/json/issues/160#issuecomment-253446892, Use `serde_json_lenient::from_slice` instead." }, + { path = "std::process::Command::spawn", reason = "Spawning `std::process::Command` can block the current thread for an unknown duration", replacement = "smol::process::Command::spawn" }, + { path = "std::process::Command::output", reason = "Spawning `std::process::Command` can block the current thread for an unknown duration", replacement = "smol::process::Command::output" }, + { path = "std::process::Command::status", reason = "Spawning `std::process::Command` can block the current thread for an unknown duration", replacement = "smol::process::Command::status" }, + { path = "std::process::Command::stdin", reason = "`smol::process::Command::from()` does not preserve stdio configuration", replacement = "smol::process::Command::stdin" }, + { path = "std::process::Command::stdout", reason = "`smol::process::Command::from()` does not preserve stdio configuration", replacement = "smol::process::Command::stdout" }, + { path = "std::process::Command::stderr", reason = "`smol::process::Command::from()` does not preserve stdio configuration", replacement = "smol::process::Command::stderr" }, + { path = "serde_json::from_reader", reason = "Parsing from a buffer is much slower than first reading the buffer into a Vec/String, see https://github.com/serde-rs/json/issues/160#issuecomment-253446892. Use `serde_json::from_slice` instead." }, + { path = "serde_json_lenient::from_reader", reason = "Parsing from a buffer is much slower than first reading the buffer into a Vec/String, see https://github.com/serde-rs/json/issues/160#issuecomment-253446892, Use `serde_json_lenient::from_slice` instead." }, ] disallowed-types = [ - # { path = "std::collections::HashMap", replacement = "collections::HashMap" }, - # { path = "std::collections::HashSet", replacement = "collections::HashSet" }, - # { path = "indexmap::IndexSet", replacement = "collections::IndexSet" }, - # { path = "indexmap::IndexMap", replacement = "collections::IndexMap" }, + # { path = "std::collections::HashMap", replacement = "collections::HashMap" }, + # { path = "std::collections::HashSet", replacement = "collections::HashSet" }, + # { path = "indexmap::IndexSet", replacement = "collections::IndexSet" }, + # { path = "indexmap::IndexMap", replacement = "collections::IndexMap" }, ] - diff --git a/crates/gpui/Cargo.toml b/crates/gpui/Cargo.toml index 343512a472..ac3cdcca70 100644 --- a/crates/gpui/Cargo.toml +++ b/crates/gpui/Cargo.toml @@ -19,23 +19,17 @@ workspace = true [features] default = ["font-kit", "wayland", "x11", "windows-manifest"] test-support = [ - "leak-detection", - "collections/test-support", - "wayland", - "x11", - "proptest", + "leak-detection", + "collections/test-support", + "wayland", + "x11", + "proptest", ] inspector = ["gpui_macros/inspector"] leak-detection = ["backtrace"] -wayland = [ - "bitflags", -] -x11 = [ - "scap?/x11", -] -screen-capture = [ - "scap", -] +wayland = ["bitflags"] +x11 = ["scap?/x11"] +screen-capture = ["scap"] windows-manifest = ["dep:embed-resource"] input-latency-histogram = ["dep:hdrhistogram"] @@ -76,10 +70,10 @@ regex.workspace = true refineable.workspace = true scheduler.workspace = true resvg = { version = "0.45.0", default-features = false, features = [ - "text", - "system-fonts", - "memmap-fonts", - "raster-images" + "text", + "system-fonts", + "memmap-fonts", + "raster-images", ] } usvg = { version = "0.45.0", default-features = false } ttf-parser = "0.25" @@ -140,7 +134,6 @@ pathfinder_geometry = "0.5" scap = { workspace = true, optional = true } - [target.'cfg(target_os = "windows")'.dependencies] windows = { version = "0.61", features = ["Win32_Foundation"] } @@ -159,7 +152,6 @@ scheduler = { workspace = true, features = ["test-support"] } unicode-segmentation = { workspace = true } - [target.'cfg(target_family = "wasm")'.dev-dependencies] wasm-bindgen = { workspace = true } gpui_web.workspace = true diff --git a/crates/gpui/examples/learn/blur.rs b/crates/gpui/examples/learn/blur.rs index bd4270bde8..482d5d7bb3 100644 --- a/crates/gpui/examples/learn/blur.rs +++ b/crates/gpui/examples/learn/blur.rs @@ -138,9 +138,11 @@ fn content_blurred_rich() -> impl IntoElement { .items_center() .justify_center() .gap_3() - .children([0xef4444, 0x22c55e, 0x3b82f6].into_iter().map(|hex| { - div().w(px(48.)).h(px(48.)).rounded_md().bg(rgb(hex)) - })) + .children( + [0xef4444, 0x22c55e, 0x3b82f6] + .into_iter() + .map(|hex| div().w(px(48.)).h(px(48.)).rounded_md().bg(rgb(hex))), + ) } /// Nested content blur: a `blur()` element inside another `blur()` element. The inner block is diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index cf40b04f50..9f20035681 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -22,6 +22,7 @@ use itertools::Itertools; use parking_lot::RwLock; use slotmap::SlotMap; +use crate::http_client::{HttpClient, NullHttpClient}; pub use async_context::*; use collections::{FxHashMap, FxHashSet, HashMap, VecDeque}; pub use context::*; @@ -29,7 +30,6 @@ pub use entity_map::*; use gpui_util::{ResultExt, debug_panic}; #[cfg(any(test, feature = "test-support"))] pub use headless_app_context::*; -use crate::http_client::{HttpClient, NullHttpClient}; use smallvec::SmallVec; #[cfg(any(test, feature = "test-support"))] pub use test_app::*; @@ -2710,8 +2710,6 @@ pub struct KeystrokeEvent { pub context_stack: Vec, } - - /// A mutable reference to an entity owned by GPUI pub struct GpuiBorrow<'a, T> { inner: Option>, diff --git a/crates/gpui/src/elements/img.rs b/crates/gpui/src/elements/img.rs index 89aa69765b..232d3b8f1d 100644 --- a/crates/gpui/src/elements/img.rs +++ b/crates/gpui/src/elements/img.rs @@ -618,25 +618,24 @@ impl Asset for ImageAssetLoader { async move { let bytes = match source.clone() { Resource::Path(uri) => fs::read(uri.as_ref())?, - Resource::Uri(uri) => { - use anyhow::Context as _; + Resource::Uri(uri) => { + use anyhow::Context as _; - let response = client - .get(uri.as_ref(), true) - .await - .with_context(|| format!("loading image asset from {uri:?}"))?; - if !response.status.is_success() { - let mut error_body = - String::from_utf8_lossy(&response.body).into_owned(); - let first_line = error_body.lines().next().unwrap_or("").trim_end(); - error_body.truncate(first_line.len()); - return Err(ImageCacheError::BadStatus { - uri, - status: response.status, - body: error_body, - }); - } - response.body + let response = client + .get(uri.as_ref(), true) + .await + .with_context(|| format!("loading image asset from {uri:?}"))?; + if !response.status.is_success() { + let mut error_body = String::from_utf8_lossy(&response.body).into_owned(); + let first_line = error_body.lines().next().unwrap_or("").trim_end(); + error_body.truncate(first_line.len()); + return Err(ImageCacheError::BadStatus { + uri, + status: response.status, + body: error_body, + }); + } + response.body } Resource::Embedded(path) => { let data = asset_source.load(&path).ok().flatten(); diff --git a/crates/gpui/src/elements/surface.rs b/crates/gpui/src/elements/surface.rs index 26daec817d..8e51963c2e 100644 --- a/crates/gpui/src/elements/surface.rs +++ b/crates/gpui/src/elements/surface.rs @@ -40,12 +40,12 @@ impl Clone for SurfaceSource { } impl std::fmt::Debug for SurfaceSource { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match *self { #[cfg(target_os = "macos")] - SurfaceSource::Surface(ref buf) => f.debug_tuple("Surface").field(buf).finish(), + SurfaceSource::Surface(ref buf) => _f.debug_tuple("Surface").field(buf).finish(), #[cfg(any(target_os = "linux", target_os = "freebsd"))] - SurfaceSource::Texture { size, .. } => f + SurfaceSource::Texture { size, .. } => _f .debug_struct("Texture") .field("size", &size) .finish_non_exhaustive(), @@ -124,27 +124,27 @@ impl Element for Surface { &mut self, _global_id: Option<&GlobalElementId>, _inspector_id: Option<&InspectorElementId>, - bounds: Bounds, + _bounds: Bounds, _: &mut Self::RequestLayoutState, _: &mut Self::PrepaintState, - window: &mut Window, + _window: &mut Window, _: &mut App, ) { match self.source { #[cfg(target_os = "macos")] SurfaceSource::Surface(ref surface) => { let size = crate::size(surface.get_width().into(), surface.get_height().into()); - let new_bounds = self.object_fit.get_bounds(bounds, size); + let new_bounds = self.object_fit.get_bounds(_bounds, size); // TODO: Add support for corner_radii - window.paint_surface(new_bounds, surface.clone()); + _window.paint_surface(new_bounds, surface.clone()); } #[cfg(any(target_os = "linux", target_os = "freebsd"))] SurfaceSource::Texture { ref texture, ref size, } => { - let new_bounds = self.object_fit.get_bounds(bounds, *size); - window.paint_surface(new_bounds, Arc::clone(texture), *size); + let new_bounds = self.object_fit.get_bounds(_bounds, *size); + _window.paint_surface(new_bounds, Arc::clone(texture), *size); } } } diff --git a/crates/gpui/src/style.rs b/crates/gpui/src/style.rs index c66768d4b8..e0b6632631 100644 --- a/crates/gpui/src/style.rs +++ b/crates/gpui/src/style.rs @@ -9,8 +9,7 @@ use crate::{ CornersRefinement, CursorStyle, DefiniteLength, DevicePixels, Edges, EdgesRefinement, Font, FontFallbacks, FontFeatures, FontStyle, FontWeight, GridLocation, Hsla, Length, Pixels, Point, PointRefinement, Rgba, ScaledPixels, SharedString, Size, SizeRefinement, Styled, TextRun, - Window, black, phi, - point, quad, rems, size, + Window, black, phi, point, quad, rems, size, }; use collections::HashSet; use refineable::Refineable; diff --git a/crates/gpui/src/transition.rs b/crates/gpui/src/transition.rs index 0bcfb94a96..1e62a53b08 100644 --- a/crates/gpui/src/transition.rs +++ b/crates/gpui/src/transition.rs @@ -702,7 +702,7 @@ mod tests { #[test] fn test_state_with_point() { let initial: Point = Point { x: 10.0, y: 20.0 }; - let state = TransitionState::new(initial.clone()); + let state = TransitionState::new(initial); assert_eq!(state.initial_goal.x, 10.0); assert_eq!(state.initial_goal.y, 20.0); diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index 69fc04f41d..ef538ae9cf 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -13,13 +13,12 @@ use crate::{ PolychromeSprite, Priority, PromptButton, PromptLevel, Quad, Render, RenderGlyphParams, RenderImage, RenderImageParams, RenderSvgParams, Replay, ResizeEdge, SMOOTH_SVG_SCALE_FACTOR, SUBPIXEL_VARIANTS_X, SUBPIXEL_VARIANTS_Y, ScaledFilter, ScaledPixels, Scene, Shadow, - SharedString, Size, - StrikethroughStyle, Style, SubpixelSprite, SubscriberSet, Subscription, SystemWindowTab, - SystemWindowTabController, TabStopMap, TaffyLayoutEngine, Task, TextRenderingMode, TextStyle, - TextStyleRefinement, ThermalState, TransformationMatrix, Transition, TransitionState, - Underline, UnderlineStyle, WindowAppearance, WindowBackgroundAppearance, WindowBounds, - WindowControls, WindowDecorations, WindowOptions, WindowParams, WindowTextSystem, point, - prelude::*, px, rems, size, transparent_black, + SharedString, Size, StrikethroughStyle, Style, SubpixelSprite, SubscriberSet, Subscription, + SystemWindowTab, SystemWindowTabController, TabStopMap, TaffyLayoutEngine, Task, + TextRenderingMode, TextStyle, TextStyleRefinement, ThermalState, TransformationMatrix, + Transition, TransitionState, Underline, UnderlineStyle, WindowAppearance, + WindowBackgroundAppearance, WindowBounds, WindowControls, WindowDecorations, WindowOptions, + WindowParams, WindowTextSystem, point, prelude::*, px, rems, size, transparent_black, }; use anyhow::{Context as _, Result, anyhow}; use collections::{FxHashMap, FxHashSet}; diff --git a/crates/gpui_elements/Cargo.toml b/crates/gpui_elements/Cargo.toml index 245634d8f2..2a53df02ef 100644 --- a/crates/gpui_elements/Cargo.toml +++ b/crates/gpui_elements/Cargo.toml @@ -8,6 +8,9 @@ license = "Apache-2.0" [lints] workspace = true +[package.metadata.cargo-machete] +ignored = ["gpui"] + [dependencies] gpui.workspace = true diff --git a/crates/gpui_linux/Cargo.toml b/crates/gpui_linux/Cargo.toml index a819ef22c5..f9db98371d 100644 --- a/crates/gpui_linux/Cargo.toml +++ b/crates/gpui_linux/Cargo.toml @@ -15,39 +15,36 @@ path = "src/gpui_linux.rs" default = ["wayland", "x11"] test-support = ["gpui/test-support"] wayland = [ - "bitflags", - "gpui_wgpu", - "ashpd/wayland", + "bitflags", + "gpui_wgpu", + "ashpd/wayland", - "calloop-wayland-source", - "wayland-backend", - "wayland-client", - "wayland-cursor", - "wayland-protocols", - "wayland-protocols-plasma", - "wayland-protocols-wlr", - "filedescriptor", - "xkbcommon", - "open", - "gpui/wayland", + "calloop-wayland-source", + "wayland-backend", + "wayland-client", + "wayland-cursor", + "wayland-protocols", + "wayland-protocols-plasma", + "wayland-protocols-wlr", + "filedescriptor", + "xkbcommon", + "open", + "gpui/wayland", ] x11 = [ - "gpui_wgpu", - "ashpd", + "gpui_wgpu", + "ashpd", - "as-raw-xcb-connection", - "x11rb", - "xkbcommon", - "xim", - "x11-clipboard", - "filedescriptor", - "open", - "scap?/x11", -] -screen-capture = [ - "gpui/screen-capture", - "scap", + "as-raw-xcb-connection", + "x11rb", + "xkbcommon", + "xim", + "x11-clipboard", + "filedescriptor", + "open", + "scap?/x11", ] +screen-capture = ["gpui/screen-capture", "scap"] [target.'cfg(any(target_os = "linux", target_os = "freebsd"))'.dependencies] @@ -76,8 +73,8 @@ uuid.workspace = true # Always used oo7 = { version = "0.6", default-features = false, features = [ - "async-std", - "native_crypto", + "async-std", + "native_crypto", ] } calloop = "0.14.3" raw-window-handle = "0.6" @@ -88,7 +85,10 @@ swash = { version = "0.2.6" } bitflags = { workspace = true, optional = true } filedescriptor = { version = "0.8.2", optional = true } open = { version = "5.2.0", optional = true } -xkbcommon = { version = "0.8.0", features = ["wayland", "x11"], optional = true } +xkbcommon = { version = "0.8.0", features = [ + "wayland", + "x11", +], optional = true } # Screen capture scap = { workspace = true, optional = true } @@ -96,38 +96,38 @@ scap = { workspace = true, optional = true } # Wayland calloop-wayland-source = { version = "0.4.1", optional = true } wayland-backend = { version = "0.3.3", features = [ - "client_system", - "dlopen", + "client_system", + "dlopen", ], optional = true } wayland-client = { version = "0.31.11", optional = true } wayland-cursor = { version = "0.31.11", optional = true } wayland-protocols = { version = "0.32.9", features = [ - "client", - "staging", - "unstable", + "client", + "staging", + "unstable", ], optional = true } wayland-protocols-plasma = { version = "0.3.9", features = [ - "client", + "client", ], optional = true } wayland-protocols-wlr = { version = "0.3.9", features = [ - "client", + "client", ], optional = true } # X11 as-raw-xcb-connection = { version = "1", optional = true } x11rb = { version = "0.13.1", features = [ - "allow-unsafe-code", - "xkb", - "randr", - "xinput", - "cursor", - "resource_manager", - "sync", - "dri3", + "allow-unsafe-code", + "xkb", + "randr", + "xinput", + "cursor", + "resource_manager", + "sync", + "dri3", ], optional = true } # WARNING: If you change this, you must also publish a new version of zed-xim to crates.io xim = { git = "https://github.com/zed-industries/xim-rs.git", rev = "16f35a2c881b815a2b6cdfd6687988e84f8447d8", features = [ - "x11rb-xcb", - "x11rb-client", + "x11rb-xcb", + "x11rb-client", ], package = "zed-xim", version = "0.4.0-zed", optional = true } x11-clipboard = { version = "0.9.3", optional = true } diff --git a/crates/gpui_linux/src/linux/wayland/client.rs b/crates/gpui_linux/src/linux/wayland/client.rs index fe53aba5d4..98ec884464 100644 --- a/crates/gpui_linux/src/linux/wayland/client.rs +++ b/crates/gpui_linux/src/linux/wayland/client.rs @@ -15,8 +15,8 @@ use calloop::{ use calloop_wayland_source::WaylandSource; use collections::HashMap; use filedescriptor::Pipe; -use url::Url; use smallvec::SmallVec; +use url::Url; use util::ResultExt as _; use wayland_backend::client::ObjectId; use wayland_backend::protocol::WEnum; diff --git a/crates/gpui_linux/src/linux/x11/client.rs b/crates/gpui_linux/src/linux/x11/client.rs index d22e25d063..96f6cbfc1b 100644 --- a/crates/gpui_linux/src/linux/x11/client.rs +++ b/crates/gpui_linux/src/linux/x11/client.rs @@ -7,7 +7,6 @@ use calloop::{ use collections::HashMap; use core::str; use gpui::{Capslock, TaskTiming, profiler}; -use url::Url; use log::Level; use smallvec::SmallVec; use std::{ @@ -18,6 +17,7 @@ use std::{ rc::{Rc, Weak}, time::{Duration, Instant}, }; +use url::Url; use util::ResultExt as _; use x11rb::{ diff --git a/crates/gpui_macros/Cargo.toml b/crates/gpui_macros/Cargo.toml index 513dd61d7b..30996af0b4 100644 --- a/crates/gpui_macros/Cargo.toml +++ b/crates/gpui_macros/Cargo.toml @@ -24,4 +24,4 @@ quote.workspace = true syn.workspace = true [dev-dependencies] -gpui = { workspace = true, features = ["inspector"] } \ No newline at end of file +gpui = { workspace = true, features = ["inspector", "test-support"] } diff --git a/crates/gpui_platform/Cargo.toml b/crates/gpui_platform/Cargo.toml index 22d44a96b2..d25b707211 100644 --- a/crates/gpui_platform/Cargo.toml +++ b/crates/gpui_platform/Cargo.toml @@ -15,7 +15,12 @@ path = "src/gpui_platform.rs" default = [] font-kit = ["gpui_macos/font-kit"] test-support = ["gpui/test-support", "gpui_macos/test-support"] -screen-capture = ["gpui/screen-capture", "gpui_macos/screen-capture", "gpui_windows/screen-capture", "gpui_linux/screen-capture"] +screen-capture = [ + "gpui/screen-capture", + "gpui_macos/screen-capture", + "gpui_windows/screen-capture", + "gpui_linux/screen-capture", +] runtime_shaders = ["gpui_macos/runtime_shaders"] wayland = ["gpui_linux/wayland"] x11 = ["gpui_linux/x11"] diff --git a/crates/gpui_web/Cargo.toml b/crates/gpui_web/Cargo.toml index 290667ce6f..de3345140c 100644 --- a/crates/gpui_web/Cargo.toml +++ b/crates/gpui_web/Cargo.toml @@ -20,7 +20,7 @@ path = "src/gpui_web.rs" gpui.workspace = true parking_lot = { workspace = true, features = ["nightly"] } gpui_wgpu.workspace = true -http_client.workspace = true +http.workspace = true anyhow.workspace = true futures.workspace = true log.workspace = true @@ -34,39 +34,39 @@ js-sys = "0.3" raw-window-handle = "0.6" wasm_thread = { version = "0.3", features = ["es_modules"], optional = true } web-sys = { version = "0.3", features = [ - "console", - "CompositionEvent", - "CssStyleDeclaration", - "DataTransfer", - "Document", - "DomRect", - "DragEvent", - "Element", - "EventTarget", - "File", - "FileList", - "HtmlCanvasElement", - "HtmlElement", - "HtmlInputElement", - "KeyboardEvent", - "MediaQueryList", - "MediaQueryListEvent", - "MouseEvent", - "Navigator", - "PointerEvent", - "ResizeObserver", - "ResizeObserverBoxOptions", - "ResizeObserverEntry", - "ResizeObserverSize", - "ResizeObserverOptions", - "Screen", - "Storage", - "VisualViewport", - "Headers", - "Request", - "RequestInit", - "RequestRedirect", - "Response", - "WheelEvent", - "Window", + "console", + "CompositionEvent", + "CssStyleDeclaration", + "DataTransfer", + "Document", + "DomRect", + "DragEvent", + "Element", + "EventTarget", + "File", + "FileList", + "HtmlCanvasElement", + "HtmlElement", + "HtmlInputElement", + "KeyboardEvent", + "MediaQueryList", + "MediaQueryListEvent", + "MouseEvent", + "Navigator", + "PointerEvent", + "ResizeObserver", + "ResizeObserverBoxOptions", + "ResizeObserverEntry", + "ResizeObserverSize", + "ResizeObserverOptions", + "Screen", + "Storage", + "VisualViewport", + "Headers", + "Request", + "RequestInit", + "RequestRedirect", + "Response", + "WheelEvent", + "Window", ] } diff --git a/crates/gpui_web/examples/hello_web/.cargo/config.toml b/crates/gpui_web/examples/hello_web/.cargo/config.toml index de4cb1a897..091cb375d9 100644 --- a/crates/gpui_web/examples/hello_web/.cargo/config.toml +++ b/crates/gpui_web/examples/hello_web/.cargo/config.toml @@ -1,13 +1,21 @@ [target.wasm32-unknown-unknown] rustflags = [ - "-C", "target-feature=+atomics,+bulk-memory,+mutable-globals", - "-C", "link-arg=--shared-memory", - "-C", "link-arg=--max-memory=1073741824", - "-C", "link-arg=--import-memory", - "-C", "link-arg=--export=__wasm_init_tls", - "-C", "link-arg=--export=__tls_size", - "-C", "link-arg=--export=__tls_align", - "-C", "link-arg=--export=__tls_base", + "-C", + "target-feature=+atomics,+bulk-memory,+mutable-globals", + "-C", + "link-arg=--shared-memory", + "-C", + "link-arg=--max-memory=1073741824", + "-C", + "link-arg=--import-memory", + "-C", + "link-arg=--export=__wasm_init_tls", + "-C", + "link-arg=--export=__tls_size", + "-C", + "link-arg=--export=__tls_align", + "-C", + "link-arg=--export=__tls_base", ] [unstable] diff --git a/crates/gpui_wgpu/src/wgpu_renderer.rs b/crates/gpui_wgpu/src/wgpu_renderer.rs index 0b8ce0bede..05c5ad7c84 100644 --- a/crates/gpui_wgpu/src/wgpu_renderer.rs +++ b/crates/gpui_wgpu/src/wgpu_renderer.rs @@ -135,6 +135,7 @@ struct WgpuPipelines { mono_sprites: wgpu::RenderPipeline, subpixel_sprites: Option, poly_sprites: wgpu::RenderPipeline, + #[allow(dead_code)] surfaces: wgpu::RenderPipeline, /// Copies a source texture into the (smaller) target with one bilinear tap. Used both to /// downsample the scene into the half-resolution blur texture and to blit the offscreen @@ -166,6 +167,7 @@ struct WgpuResources { bind_group_layouts: WgpuBindGroupLayouts, atlas_sampler: wgpu::Sampler, surface_sampler: wgpu::Sampler, + #[allow(dead_code)] surface_uniform_buffer: wgpu::Buffer, /// One reused uniform buffer holding [`BlurParams`] for every blur pass in a frame, each at a /// distinct (alignment-strided) offset. Avoids allocating a buffer per pass; distinct offsets @@ -1041,7 +1043,7 @@ impl WgpuRenderer { &layouts.globals, &layouts.surfaces, wgpu::PrimitiveTopology::TriangleStrip, - &[Some(color_target.clone())], + &[Some(color_target)], 1, &shader_module, ); @@ -1845,6 +1847,7 @@ impl WgpuRenderer { ) } + #[cfg(any(target_os = "linux", target_os = "freebsd"))] fn draw_surfaces(&self, surfaces: &[PaintSurface], pass: &mut wgpu::RenderPass<'_>) -> bool { let resources = self.resources(); for surface in surfaces { @@ -1894,6 +1897,11 @@ impl WgpuRenderer { true } + #[cfg(not(any(target_os = "linux", target_os = "freebsd")))] + fn draw_surfaces(&self, _surfaces: &[PaintSurface], _pass: &mut wgpu::RenderPass<'_>) -> bool { + true + } + /// Build a bind group for a blur pass. Writes `params` into the next slot of the shared /// `blur_params_buffer` (no per-pass allocation) and references that slot, the source texture, /// and the filtering sampler. Distinct per-pass offsets keep `write_buffer`'s diff --git a/crates/gpui_windows/src/directx_renderer.rs b/crates/gpui_windows/src/directx_renderer.rs index 47ea99d8c6..d514555051 100644 --- a/crates/gpui_windows/src/directx_renderer.rs +++ b/crates/gpui_windows/src/directx_renderer.rs @@ -114,16 +114,20 @@ struct DirectXResources { /// (indexed by isolation depth), up to [`MAX_FILTER_DEPTH`], so nested content blurs isolate /// correctly; deeper nests render inline. struct BlurResources { + #[expect(dead_code)] scene_color: ID3D11Texture2D, scene_color_rtv: Option, scene_color_srv: Option, + #[expect(dead_code)] ping: ID3D11Texture2D, ping_rtv: Option, ping_srv: Option, + #[expect(dead_code)] pong: ID3D11Texture2D, pong_rtv: Option, pong_srv: Option, // Kept alive for the lifetime of their views; indexed by isolation depth. + #[expect(dead_code)] groups: Vec, group_rtvs: Vec>, group_srvs: Vec>, diff --git a/deny.toml b/deny.toml new file mode 100644 index 0000000000..da80e30ead --- /dev/null +++ b/deny.toml @@ -0,0 +1,60 @@ +[graph] +targets = [] +all-features = false +no-default-features = false + +[output] +feature-depth = 1 + +[advisories] +ignore = [] +unmaintained = "none" +unsound = "none" + +[licenses] +allow = [ + "MIT", + "Apache-2.0", + "Apache-2.0 WITH LLVM-exception", + "BSD-2-Clause", + "BSD-3-Clause", + "ISC", + "Zlib", + "Unicode-3.0", + "0BSD", + "MPL-2.0", + "CC0-1.0", + "bzip2-1.0.6", + "NCSA", +] +confidence-threshold = 0.8 +exceptions = [] + +[licenses.private] +ignore = true +registries = [ + #"https://sekretz.com/registry +] + +[bans] +multiple-versions = "allow" +wildcards = "allow" +highlight = "all" +workspace-default-features = "allow" +external-default-features = "allow" +allow = [] +allow-workspace = true +deny = [] +skip = [] +skip-tree = [] + +[sources] +unknown-registry = "deny" +unknown-git = "deny" +allow-registry = ["https://github.com/rust-lang/crates.io-index"] +allow-git = [] + +[sources.allow-org] +github = ["zed-industries", "proptest-rs"] +gitlab = [] +bitbucket = [] diff --git a/flake.nix b/flake.nix index 0632bdfc4e..d924d89ca7 100644 --- a/flake.nix +++ b/flake.nix @@ -106,7 +106,13 @@ devShells.default = pkgs.mkShell { inputsFrom = [ gpui ]; - packages = [ toolchain ]; + packages = [ + toolchain + pkgs.cargo-machete + pkgs.taplo + pkgs.typos + pkgs.just + ]; shellHook = '' export RUST_BACKTRACE=1 diff --git a/justfile b/justfile index 205f8a9d42..80dcd190ef 100644 --- a/justfile +++ b/justfile @@ -6,7 +6,7 @@ set positional-arguments := true set allow-duplicate-variables := true project_root := justfile_directory() -msrv := "1.85.0" +msrv := "1.92.0" # ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰ # # Recipes # diff --git a/tooling/perf/Cargo.toml b/tooling/perf/Cargo.toml index c9018de010..5a7ee63844 100644 --- a/tooling/perf/Cargo.toml +++ b/tooling/perf/Cargo.toml @@ -13,18 +13,18 @@ description = "A tool for measuring GPUI test performance" missing_docs = "warn" [lints.clippy] -needless_continue = "allow" # For a convenience macro +needless_continue = "allow" # For a convenience macro all = "warn" pedantic = "warn" style = "warn" missing_docs_in_private_items = "warn" as_underscore = "deny" allow_attributes = "deny" -allow_attributes_without_reason = "deny" # This covers `expect` also, since we deny `allow` +allow_attributes_without_reason = "deny" # This covers `expect` also, since we deny `allow` let_underscore_must_use = "forbid" undocumented_unsafe_blocks = "forbid" missing_safety_doc = "forbid" -disallowed_methods = { level = "allow", priority = 1} +disallowed_methods = { level = "allow", priority = 1 } [dependencies] collections.workspace = true diff --git a/typos.toml b/typos.toml index 87088a065a..8cf280d09a 100644 --- a/typos.toml +++ b/typos.toml @@ -1,16 +1,15 @@ [files] ignore-files = true ignore-hidden = false -extend-exclude = [ - ".git/", -] +extend-exclude = [".git/"] [default] extend-ignore-re = [ - # macOS version - "Big Sur", - # Stripped version of reserved keyword `type` - "typ", + # macOS version + "Big Sur", + + # Stripped version of reserved keyword `type` + "typ", ] check-filename = true