From 6ba70b37febb23e47eceb057fa814c85d2cb2b90 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Wed, 17 May 2023 16:44:08 -0700 Subject: [PATCH 01/11] Add GitHub Actions workflows for CI and GitHub issue labels --- .github/dependabot.yml | 29 ++++ .github/labels.yaml | 120 +++++++++++++++ .github/markdown-link-check.json | 22 +++ .github/workflows/audit.yaml | 59 ++++++++ .github/workflows/block-merge.yaml | 16 ++ .github/workflows/ci.yaml | 167 +++++++++++++++++++++ .github/workflows/markdown-link-check.yaml | 34 +++++ .github/workflows/repo-labels.yaml | 31 ++++ .github/workflows/rustdoc.yaml | 51 +++++++ 9 files changed, 529 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/labels.yaml create mode 100644 .github/markdown-link-check.json create mode 100644 .github/workflows/audit.yaml create mode 100644 .github/workflows/block-merge.yaml create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/markdown-link-check.yaml create mode 100644 .github/workflows/repo-labels.yaml create mode 100644 .github/workflows/rustdoc.yaml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000000..cc4a2a0bbb6 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,29 @@ +--- +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + assignees: + - lopopolo + labels: + - A-deps + - package-ecosystem: cargo + directory: "/" + schedule: + interval: monthly + open-pull-requests-limit: 10 + assignees: + - lopopolo + labels: + - A-deps + - package-ecosystem: bundler + directory: "/" + schedule: + interval: monthly + open-pull-requests-limit: 10 + assignees: + - lopopolo + labels: + - A-deps diff --git a/.github/labels.yaml b/.github/labels.yaml new file mode 100644 index 00000000000..0f407a3034c --- /dev/null +++ b/.github/labels.yaml @@ -0,0 +1,120 @@ +--- +- name: "A-build" + color: "f7e101" + description: "Area: CI build infrastructure." +- name: "A-build-target" + color: "f7e101" + description: "Area: Support for builds of specific targets." +- name: "A-crate-features" + color: "f7e101" + description: "Area: Compile-time features or attributes." +- name: "A-deps" + color: "f7e101" + description: "Area: Source and library dependencies." +- name: "A-ffi" + color: "f7e101" + description: "Area: Native bindings and bindgen." +- name: "A-packaging" + color: "f7e101" + description: "Area: Packaging releases for distribution." +- name: "A-performance" + color: "f7e101" + description: "Area: Performance improvements and optimizations." +- name: "A-project" + color: "f7e101" + description: "Area: Infrastructure for running an open source project." +- name: "A-release" + color: "f7e101" + description: "Area: crates.io releases and version bumps." +- name: "A-security" + color: "f7e101" + description: "Area: Security vulnerabilities and unsoundness issues." +- name: "A-win-known-folders" + color: "f7e101" + description: "Area: Windows Known Folders API." +- name: "C-bug" + color: "c1c8ff" + description: "Category: This is a bug." +- name: "C-docs" + color: "c1c8ff" + description: "Category: Improvements or additions to documentation." +- name: "C-enhancement" + color: "c1c8ff" + description: "Category: New feature or request." +- name: "C-quality" + color: "c1c8ff" + description: "Category: Refactoring, cleanup, and quality improvements." +- name: "C-question" + color: "c1c8ff" + description: "Category: Further information is requested." +- name: "E-easy" + color: "02e10c" + description: + "Call for participation: Experience needed to fix: Easy / not much." +- name: "E-medium" + color: "02e10c" + description: + "Call for participation: Experience needed to fix: Medium / intermediate." +- name: "E-hard" + color: "02e10c" + description: "Call for participation: Experience needed to fix: Hard / a lot." +- name: "E-help-wanted" + color: "02e10c" + description: "Call for participation: Help is requested to fix this issue." +- name: "E-needs-test" + color: "02e10c" + description: "Call for participation: Writing correctness tests." +- name: "O-linux" + color: "6e6ec0" + description: "Target: Support for building on Linux (GNU / musl) targets." +- name: "O-macOS" + color: "6e6ec0" + description: "Target: Support for building on macOS / Darwin targets." +- name: "O-wasm-emscripten" + color: "6e6ec0" + description: + "Target: Support for building the `wasm32-unknown-emscripten` target." +- name: "O-wasm-unknown" + color: "6e6ec0" + description: + "Target: Support for building the `wasm32-unknown-unknown` target." +- name: "O-windows" + color: "6e6ec0" + description: + "Target: Support for building on Windows targets like + `x86_64-pc-windows-msvc`." +- name: "S-archive" + color: "d3dddd" + description: "Status: This pull request exists to archive an unmerged branch." +- name: "S-blocked" + color: "d3dddd" + description: + "Status: Marked as blocked ❌ on something else such as other implementation + work." +- name: "S-do-not-merge" + color: "d3dddd" + description: "Status: This pull request should not be merged." +- name: "S-duplicate" + color: "d3dddd" + description: "Status: This issue or pull request already exists." +- name: "S-invalid" + color: "d3dddd" + description: "Status: This issue or pull request is not well-formed." +- name: "S-postponed" + color: "d3dddd" + description: + "Status: This issue or pull request is being postponed until later." +- name: "S-speculative" + color: "d3dddd" + description: "Status: This is just an idea." +- name: "S-stale" + color: "d3dddd" + description: + "Status: This PR is stale. Please open a new PR if you'd like to pick this + back up." +- name: "S-wip" + color: "d3dddd" + description: "Status: This pull request is a work in progress." +- name: "S-wontfix" + color: "d3dddd" + description: "Status: This issue or pull request will not be worked on." diff --git a/.github/markdown-link-check.json b/.github/markdown-link-check.json new file mode 100644 index 00000000000..4ec268d3b23 --- /dev/null +++ b/.github/markdown-link-check.json @@ -0,0 +1,22 @@ +{ + "ignorePatterns": [ + { + "pattern": "img.shields.io" + }, + { + "pattern": "^https://twitter.com/artichokeruby" + } + ], + "replacementPatterns": [], + "httpHeaders": [ + { + "urls": ["https://crates.io"], + "headers": { + "Accept": "text/html" + } + } + ], + "retryOn429": true, + "retryCount": 3, + "fallbackRetryDelay": "60s" +} diff --git a/.github/workflows/audit.yaml b/.github/workflows/audit.yaml new file mode 100644 index 00000000000..20fc273b6af --- /dev/null +++ b/.github/workflows/audit.yaml @@ -0,0 +1,59 @@ +--- +name: Audit +"on": + push: + branches: + - trunk + pull_request: + branches: + - trunk + schedule: + - cron: "0 0 * * TUE" +jobs: + ruby: + name: Audit Ruby Dependencies + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3.5.2 + + - name: Install Ruby toolchain + uses: ruby/setup-ruby@d2b39ad0b52eca07d23f3aa14fdf2a3fcc1f411c # v1.148.0 + with: + ruby-version: ".ruby-version" + bundler-cache: true + + - name: bundler-audit + run: bundle exec bundle-audit check --update + + rust: + name: Audit Rust Dependencies + runs-on: ubuntu-latest + strategy: + matrix: + checks: + - advisories + - bans licenses sources + + # Prevent sudden announcement of a new advisory from failing ci: + continue-on-error: ${{ matrix.checks == 'advisories' }} + + steps: + - name: Checkout repository + uses: actions/checkout@v3.5.2 + + - name: Install Rust toolchain + uses: artichoke/setup-rust/audit@v1.9.0 + + - name: Generate Cargo.lock + run: | + if [[ ! -f "Cargo.lock" ]]; then + cargo generate-lockfile --verbose + fi + + - uses: EmbarkStudios/cargo-deny-action@e0a440755b184aa50374330fa75cca0f84fcb59a # v1.5.2 + with: + arguments: --locked --all-features + command: check ${{ matrix.checks }} + command-arguments: --show-stats diff --git a/.github/workflows/block-merge.yaml b/.github/workflows/block-merge.yaml new file mode 100644 index 00000000000..f3e71995208 --- /dev/null +++ b/.github/workflows/block-merge.yaml @@ -0,0 +1,16 @@ +--- +name: Merge +"on": + pull_request: + types: [opened, labeled, unlabeled, synchronize] +jobs: + labels: + name: Labels + runs-on: ubuntu-latest + + steps: + - uses: mheap/github-action-required-labels@422e4c352ef83db91089e6acfbf09d8725e08abc # v4.0.0 + with: + mode: exactly + count: 0 + labels: "S-do-not-merge, S-wip" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000000..4f72d287f38 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,167 @@ +--- +name: CI +"on": + push: + branches: + - trunk + pull_request: + branches: + - trunk + schedule: + - cron: "0 0 * * WED" +jobs: + build: + name: Build + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, windows-2019, windows-2022] + env: + RUSTFLAGS: -D warnings + RUST_BACKTRACE: 1 + steps: + - name: Checkout repository + uses: actions/checkout@v3.5.2 + + - name: Install Rust toolchain + uses: artichoke/setup-rust/build-and-test@v1.9.0 + with: + toolchain: stable + + - name: Compile + run: cargo build --verbose + + - name: Compile tests + run: cargo test --no-run + + - name: Test + run: cargo test + + - name: Test with all features + run: cargo test --all-features + + - name: Test with no default features + run: cargo test --no-default-features + + build-msrv: + name: Build (MSRV) + runs-on: windows-latest + env: + CARGO_INCREMENTAL: 0 + RUSTFLAGS: -D warnings + RUST_BACKTRACE: 1 + steps: + - name: Checkout repository + uses: actions/checkout@v3.5.2 + + - name: Install Rust toolchain + uses: artichoke/setup-rust/build-and-test@v1.9.0 + with: + toolchain: "1.56.0" + + - name: Compile + run: cargo build --verbose + + - name: Compile tests + run: cargo test --no-run + + - name: Test + run: cargo test + + - name: Test with all features + run: cargo test --all-features + + - name: Test with no default features + run: cargo test --no-default-features + + build-non-windows: + name: Build (non-Windows platforms) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macos-latest, ubuntu-latest] + env: + RUSTFLAGS: -D warnings + RUST_BACKTRACE: 1 + steps: + - name: Checkout repository + uses: actions/checkout@v3.5.2 + + - name: Install Rust toolchain + uses: artichoke/setup-rust/build-and-test@v1.9.0 + with: + toolchain: stable + + - name: Compile + run: cargo build --verbose + + - name: Compile tests + run: cargo test --no-run + + - name: Test + run: cargo test + + - name: Test with all features + run: cargo test --all-features + + - name: Test with no default features + run: cargo test --no-default-features + + - name: Build documentation + run: cargo doc + + rust: + name: Lint and format Rust + runs-on: windows-latest + env: + RUSTFLAGS: -D warnings + RUST_BACKTRACE: 1 + steps: + - name: Checkout repository + uses: actions/checkout@v3.5.2 + + - name: Install Rust toolchain + uses: artichoke/setup-rust/lint-and-format@v1.9.0 + with: + toolchain: stable + + - name: Check formatting + run: cargo fmt --check + + - name: Lint with Clippy + run: cargo clippy --workspace --all-features --all-targets + + ruby: + name: Lint and format Ruby + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3.5.2 + + - name: Install Ruby toolchain + uses: ruby/setup-ruby@d2b39ad0b52eca07d23f3aa14fdf2a3fcc1f411c # v1.148.0 + with: + ruby-version: ".ruby-version" + bundler-cache: true + + - name: Lint and check formatting with Rubocop + run: bundle exec rubocop --format github + + text: + name: Lint and format text + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3.5.2 + + - name: Format with prettier + run: npx prettier --check '**/*' + + - name: Lint YAML sources with yamllint + run: | + yamllint --version + echo "Linting YAML sources with yamllint ..." + yamllint --strict --format github . + echo "OK" diff --git a/.github/workflows/markdown-link-check.yaml b/.github/workflows/markdown-link-check.yaml new file mode 100644 index 00000000000..b0a593452cc --- /dev/null +++ b/.github/workflows/markdown-link-check.yaml @@ -0,0 +1,34 @@ +--- +"on": + push: + branches: + - trunk + paths: + - .github/markdown-link-check.json + - .github/workflows/markdown-link-check.yaml + - "**/*.md" + pull_request: + branches: + - trunk + paths: + - .github/markdown-link-check.json + - .github/workflows/markdown-link-check.yaml + - "**/*.md" + schedule: + - cron: "0 0 * * TUE" +name: Markdown Links Check +jobs: + check-links: + name: Check links + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3.5.2 + + - name: Check for broken links in markdown files + uses: gaurav-nelson/github-action-markdown-link-check@d53a906aa6b22b8979d33bc86170567e619495ec # v1.0.15 + with: + use-quiet-mode: "yes" + use-verbose-mode: "yes" + config-file: ".github/markdown-link-check.json" + folder-path: "." diff --git a/.github/workflows/repo-labels.yaml b/.github/workflows/repo-labels.yaml new file mode 100644 index 00000000000..2e372437ee1 --- /dev/null +++ b/.github/workflows/repo-labels.yaml @@ -0,0 +1,31 @@ +--- +"on": + push: + branches: + - trunk + paths: + - .github/labels.yaml + - .github/workflows/repo-labels.yaml + pull_request: + branches: + - trunk + paths: + - .github/labels.yaml + - .github/workflows/repo-labels.yaml + schedule: + - cron: "0 0 * * TUE" +name: Create Repository Labels +jobs: + labels: + name: Synchronize repository labels + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3.5.2 + + - name: Sync GitHub Issue Labels + uses: crazy-max/ghaction-github-labeler@3de87da19416edc45c90cd89e7a4ea922a3aae5a # v4.1.0 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + yaml-file: .github/labels.yaml + skip-delete: false + dry-run: ${{ github.ref != 'refs/heads/trunk' }} diff --git a/.github/workflows/rustdoc.yaml b/.github/workflows/rustdoc.yaml new file mode 100644 index 00000000000..7dda79fa1db --- /dev/null +++ b/.github/workflows/rustdoc.yaml @@ -0,0 +1,51 @@ +--- +name: Documentation +"on": + push: + branches: + - trunk + pull_request: + branches: + - trunk + schedule: + - cron: "0 0 * * TUE" +concurrency: + group: docs-${{ github.head_ref }} +env: + CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse +jobs: + rustdoc: + name: Build Rust API docs + runs-on: windows-latest + env: + RUSTDOCFLAGS: -D warnings -D rustdoc::broken_intra_doc_links --cfg docsrs + RUST_BACKTRACE: 1 + + steps: + - name: Checkout repository + uses: actions/checkout@v3.5.2 + + - name: Install Rust toolchain + uses: artichoke/setup-rust/rustdoc@v1.9.0 + + - name: Check docs with no default features + run: cargo doc --workspace --no-default-features + + - name: Clean docs + run: cargo clean + + - name: Build Documentation + run: cargo doc --workspace + + - name: Deploy Docs + uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # v3.9.2 + if: github.ref == 'refs/heads/trunk' + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./target/doc + publish_branch: gh-pages + user_name: artichoke-ci + user_email: ci@artichokeruby.org + # only have the most recent docs in the `gh-pages` branch + # https://github.com/artichoke/artichoke/issues/1826 + force_orphan: true From a563d417aaac51a0b5da0801a740120d5d90c1ce Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Wed, 17 May 2023 16:48:42 -0700 Subject: [PATCH 02/11] Remove erroneously added no-std crate attribute --- src/lib.rs | 1 - src/win.rs | 4 ++-- src/win/ffi.rs | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 73d375f9f3a..cb65a68b8e4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -52,7 +52,6 @@ //! //! [Known Folders]: https://learn.microsoft.com/en-us/windows/win32/shell/known-folders -#![no_std] #![doc(html_root_url = "https://docs.rs/known-folders/1.0.0")] // Ensure code blocks in `README.md` compile diff --git a/src/win.rs b/src/win.rs index 09a47b40eb0..a8a70187339 100644 --- a/src/win.rs +++ b/src/win.rs @@ -8,10 +8,10 @@ // project carrying such notice may not be copied, modified, or distributed // except according to those terms. -use std::mem::size_of; +use core::mem::size_of; +use core::slice; use std::os::windows::ffi::OsStringExt; use std::path::PathBuf; -use std::slice; use windows_sys::Win32::{ Foundation::{E_FAIL, E_INVALIDARG, HANDLE, S_OK}, diff --git a/src/win/ffi.rs b/src/win/ffi.rs index e25c1f2a69a..6356483d77e 100644 --- a/src/win/ffi.rs +++ b/src/win/ffi.rs @@ -8,8 +8,8 @@ // project carrying such notice may not be copied, modified, or distributed // except according to those terms. -use std::ffi::c_void; -use std::ptr; +use core::ffi::c_void; +use core::ptr; use windows_sys::core::PWSTR; use windows_sys::Win32::System::Com::CoTaskMemFree; From afdcf551ae5ba0fa1ee8f9be2f3c1bc218100f66 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Wed, 17 May 2023 16:48:57 -0700 Subject: [PATCH 03/11] Fix one missed rename from FreeGuard to Guard in ffi module --- src/win/ffi.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win/ffi.rs b/src/win/ffi.rs index 6356483d77e..9f0f4dd5995 100644 --- a/src/win/ffi.rs +++ b/src/win/ffi.rs @@ -48,7 +48,7 @@ impl Default for Guard { } } -impl Drop for FreeGuard { +impl Drop for Guard { fn drop(&mut self) { let ptr = self.0.cast::(); // SAFETY: `ptr` must always be freed per the API documentation: From 058bec0fe0af66676e1b4ee1d0839c32d872bde6 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Wed, 17 May 2023 16:53:05 -0700 Subject: [PATCH 04/11] Fix extraneous semicolon in unsafe block First time this crate is being compiled on windows! :sweat_smile: --- src/win.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win.rs b/src/win.rs index a8a70187339..92369fabc1a 100644 --- a/src/win.rs +++ b/src/win.rs @@ -100,7 +100,7 @@ pub fn get_known_folder_path(known_folder: KnownFolder) -> Option { // > path of the known folder let len = unsafe { let len = lstrlenW(path_ptr); - usize::try_from(len).ok()?; + usize::try_from(len).ok()? }; // SAFETY: `path_ptr` is valid for `len` bytes in a single string From 9212b089ef63b5c32802d71c93feca6d4ae14904 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Wed, 17 May 2023 16:56:29 -0700 Subject: [PATCH 05/11] Mark `KnownFolder::to_guid` as `pub(crate)` --- src/win/known_folder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win/known_folder.rs b/src/win/known_folder.rs index b942896598b..3bd6b22e724 100644 --- a/src/win/known_folder.rs +++ b/src/win/known_folder.rs @@ -1078,7 +1078,7 @@ pub enum KnownFolder { } impl KnownFolder { - const fn to_guid(self) -> &'static GUID { + pub(crate) const fn to_guid(self) -> &'static GUID { match self { Self::AccountPictures => &FOLDERID_AccountPictures, Self::AddNewPrograms => &FOLDERID_AddNewPrograms, From 5b62417760debc46bb934df3482d81b4758e1a8d Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Wed, 17 May 2023 16:57:52 -0700 Subject: [PATCH 06/11] Fix construction of ffi::Guard inner pointer --- src/win/ffi.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/win/ffi.rs b/src/win/ffi.rs index 9f0f4dd5995..c9e9b1c3cfb 100644 --- a/src/win/ffi.rs +++ b/src/win/ffi.rs @@ -43,8 +43,7 @@ impl Guard { impl Default for Guard { fn default() -> Self { - let ptr = ptr::null_mut::(); - Self(ptr) + Self(ptr::null_mut()) } } From d953f80e29bbb8f97fd574951542974c42d5e55c Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Wed, 17 May 2023 16:58:47 -0700 Subject: [PATCH 07/11] Add missing `OsString` import in windows internals --- src/win.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/win.rs b/src/win.rs index 92369fabc1a..b45d3de3ca3 100644 --- a/src/win.rs +++ b/src/win.rs @@ -10,6 +10,7 @@ use core::mem::size_of; use core::slice; +use std::ffi::OsString; use std::os::windows::ffi::OsStringExt; use std::path::PathBuf; From 1d4045eb8b0416251a8cb074a0104ad5037033c8 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Wed, 17 May 2023 17:03:19 -0700 Subject: [PATCH 08/11] Convert OsString into expected PathBuf return value --- src/win.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win.rs b/src/win.rs index b45d3de3ca3..c1e40a25fc7 100644 --- a/src/win.rs +++ b/src/win.rs @@ -119,7 +119,7 @@ pub fn get_known_folder_path(known_folder: KnownFolder) -> Option { }; let os_str = OsString::from_wide(path); - Some(os_str) + Some(os_str.into()) } E_FAIL | E_INVALIDARG => { // Expected return codes. See: From 7cdc244aad357f5f0ea3a3bc99b9c68d1210ab0b Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Wed, 17 May 2023 17:07:58 -0700 Subject: [PATCH 09/11] Silence a snake case lint on `Guard::as_out_ppszPath` This function name matches the Windows API parameter name. --- src/win/ffi.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/win/ffi.rs b/src/win/ffi.rs index c9e9b1c3cfb..fb971a9ff5b 100644 --- a/src/win/ffi.rs +++ b/src/win/ffi.rs @@ -31,6 +31,7 @@ impl Guard { /// `PWSTR` itself is a `*mut u16`: /// /// + #[allow(non_snake_case)] pub fn as_out_ppszPath(&mut self) -> &mut PWSTR { &mut self.0 } From 797cda65bba692e026580064388917f98f28e9f5 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Wed, 17 May 2023 17:14:49 -0700 Subject: [PATCH 10/11] Add must use annotations --- src/win.rs | 1 + src/win/ffi.rs | 2 ++ src/win/known_folder.rs | 1 + 3 files changed, 4 insertions(+) diff --git a/src/win.rs b/src/win.rs index c1e40a25fc7..74bf7d7e11e 100644 --- a/src/win.rs +++ b/src/win.rs @@ -50,6 +50,7 @@ pub use known_folder::KnownFolder; /// /// [`KNOWNFOLDERID`]: KnownFolder /// [`SHGetKnownFolderPath`]: https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath +#[must_use] pub fn get_known_folder_path(known_folder: KnownFolder) -> Option { // This guard ensures `CoTaskMemFree` is always called after invoking // `SHGetKnownFolderPath`, which is required regardless of the return diff --git a/src/win/ffi.rs b/src/win/ffi.rs index fb971a9ff5b..8469e060068 100644 --- a/src/win/ffi.rs +++ b/src/win/ffi.rs @@ -31,12 +31,14 @@ impl Guard { /// `PWSTR` itself is a `*mut u16`: /// /// + #[must_use] #[allow(non_snake_case)] pub fn as_out_ppszPath(&mut self) -> &mut PWSTR { &mut self.0 } /// Access the inner wide string. + #[must_use] pub fn as_pwstr(&self) -> PWSTR { self.0 } diff --git a/src/win/known_folder.rs b/src/win/known_folder.rs index 3bd6b22e724..f0876c06e75 100644 --- a/src/win/known_folder.rs +++ b/src/win/known_folder.rs @@ -1078,6 +1078,7 @@ pub enum KnownFolder { } impl KnownFolder { + #[must_use] pub(crate) const fn to_guid(self) -> &'static GUID { match self { Self::AccountPictures => &FOLDERID_AccountPictures, From 89b9d68c3e65d3f06646ad2e6ec8dee550853e35 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Wed, 17 May 2023 17:15:01 -0700 Subject: [PATCH 11/11] Silence some clippy lints --- src/win.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/win.rs b/src/win.rs index 74bf7d7e11e..31b849f10ad 100644 --- a/src/win.rs +++ b/src/win.rs @@ -51,6 +51,8 @@ pub use known_folder::KnownFolder; /// [`KNOWNFOLDERID`]: KnownFolder /// [`SHGetKnownFolderPath`]: https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath #[must_use] +#[allow(clippy::match_same_arms)] +#[allow(clippy::cast_possible_wrap)] pub fn get_known_folder_path(known_folder: KnownFolder) -> Option { // This guard ensures `CoTaskMemFree` is always called after invoking // `SHGetKnownFolderPath`, which is required regardless of the return