Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix triggering str_to_string lint #4

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)) },
};
}