Skip to content

Commit

Permalink
Fix triggering str_to_string lint (#4)
Browse files Browse the repository at this point in the history
* play nice with str_to_string lint
* add test against clippy lint
  • Loading branch information
Wumpf authored Dec 19, 2023
1 parent 9d8077f commit a1d8b5f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ exclude = ["modoc.config", "release.toml"]

[badges]
maintenance = { status = "passively-maintained" }

[lints.clippy]
str_to_string = "deny"
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ macro_rules! cfg_aliases {
"CARGO_CFG_{}",
&stringify!($cfgname).to_uppercase().replace("-", "_")
)
).unwrap_or("".to_string()).split(",").find(|x| x == &$cfgvalue).is_some()
).unwrap_or("".to_owned()).split(",").find(|x| x == &$cfgvalue).is_some()
};

// Emitting `any(clause1,clause2,...)`: convert to `$crate::cfg_aliases!(clause1) && $crate::cfg_aliases!(clause2) && ...`
Expand Down
20 changes: 20 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use cfg_aliases::cfg_aliases;

#[test]
fn basic_setup() {
// Same as in the docs.
// Note that tests build this already, but unfortunately this doesn't catch clippy lints!
// See https://github.com/rust-lang/rust/issues/56232
cfg_aliases! {
// Platforms
wasm: { target_arch = "wasm32" },
android: { target_os = "android" },
macos: { target_os = "macos" },
linux: { target_os = "linux" },
// Backends
surfman: { all(unix, feature = "surfman", not(wasm)) },
glutin: { all(feature = "glutin", not(wasm)) },
wgl: { all(windows, feature = "wgl", not(wasm)) },
dummy: { not(any(wasm, glutin, wgl, surfman)) },
};
}

0 comments on commit a1d8b5f

Please sign in to comment.