1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 12:50:04 -04:00

Run special clippy for wasm, forbidding some types/methods

This commit is contained in:
Emil Ernerfeldt
2023-04-20 10:15:54 +02:00
parent 6bac3d702f
commit 0b0b8df1c8
4 changed files with 54 additions and 1 deletions

View File

@@ -156,6 +156,8 @@ jobs:
- run: ./scripts/wasm_bindgen_check.sh --skip-setup
- run: ./scripts/clippy_wasm.sh
- name: Cranky wasm32
uses: actions-rs/cargo@v1
with:

View File

@@ -1 +1,10 @@
doc-valid-idents = ["AccessKit", ".."]
# There is also a scripts/clippy_wasm/clippy.toml which forbids some mthods that are not available in wasm.
msrv = "1.65"
# Allow-list of words for markdown in dosctrings https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
doc-valid-idents = [
# You must also update the same list in the root `clippy.toml`!
"AccessKit",
"..",
]

13
scripts/clippy_wasm.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
# This scripts run clippy on the wasm32-unknown-unknown target,
# using a special clippy.toml config file which forbids a few more things.
set -eu
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$script_path/.."
set -x
# Use scripts/clippy_wasm/clippy.toml
export CLIPPY_CONF_DIR="scripts/clippy_wasm"
cargo cranky --all-features --target wasm32-unknown-unknown --target-dir target_wasm -p egui_demo_app --lib -- --deny warnings

View File

@@ -0,0 +1,29 @@
# This is used by `scripts/clippy_wasm.sh` so we can forbid some methods that are not available in wasm.
#
# We cannot forbid all these methods in the main `clippy.toml` because of
# https://github.com/rust-lang/rust-clippy/issues/10406
msrv = "1.65"
# https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods
disallowed-methods = [
"std::time::Instant::now", # use `instant` crate instead for wasm/web compatibility
"std::time::Duration::elapsed", # use `instant` crate instead for wasm/web compatibility
"std::time::SystemTime::now", # use `instant` or `time` crates instead for wasm/web compatibility
# Cannot spawn threads on wasm:
"std::thread::spawn",
]
# https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types
disallowed-types = [
# Cannot spawn threads on wasm:
"std::thread::Builder",
]
# Allow-list of words for markdown in dosctrings https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
doc-valid-idents = [
# You must also update the same list in the root `clippy.toml`!
"AccessKit",
"..",
]