Skip to content

Commit 9326330

Browse files
committed
fix lint issues
1 parent dc0e337 commit 9326330

8 files changed

Lines changed: 100 additions & 89 deletions

File tree

Cargo.lock

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cfg_eval.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ use std::process::Command;
1010
/// obtain the active cfg set, and `cfg-expr` to parse and evaluate expressions.
1111
pub trait CfgEvaluator {
1212
/// Return whether the given cfg expression matches the provided target.
13+
///
14+
/// # Errors
15+
///
16+
/// Returns an error if the cfg expression cannot be parsed or evaluated.
1317
fn matches(&mut self, cfg_expr: &str, target: &TargetTriple) -> eyre::Result<bool>;
1418
}
1519

@@ -106,6 +110,13 @@ impl RustcCfgEvaluator {
106110
}
107111
}
108112

113+
fn endian_str(e: cfg_expr::targets::Endian) -> &'static str {
114+
match e {
115+
cfg_expr::targets::Endian::big => "big",
116+
cfg_expr::targets::Endian::little => "little",
117+
}
118+
}
119+
109120
impl CfgEvaluator for RustcCfgEvaluator {
110121
fn matches(&mut self, cfg_expr: &str, target: &TargetTriple) -> eyre::Result<bool> {
111122
let set = self.cfg_set_for(target)?;
@@ -114,13 +125,6 @@ impl CfgEvaluator for RustcCfgEvaluator {
114125
.wrap_err_with(|| format!("failed to parse cfg expression `{cfg_expr}`"))?;
115126
Self::validate_supported(&expr)?;
116127

117-
fn endian_str(e: &cfg_expr::targets::Endian) -> &'static str {
118-
match e {
119-
cfg_expr::targets::Endian::big => "big",
120-
cfg_expr::targets::Endian::little => "little",
121-
}
122-
}
123-
124128
Ok(expr.eval(|pred| match pred {
125129
Predicate::Target(tp) => {
126130
// For target_* predicates, `rustc --print cfg` provides exact
@@ -143,7 +147,7 @@ impl CfgEvaluator for RustcCfgEvaluator {
143147
}
144148
cfg_expr::expr::TargetPredicate::Abi(a) => set.has_kv("target_abi", a.as_ref()),
145149
cfg_expr::expr::TargetPredicate::Endian(e) => {
146-
set.has_kv("target_endian", endian_str(e))
150+
set.has_kv("target_endian", endian_str(*e))
147151
}
148152
cfg_expr::expr::TargetPredicate::Panic(p) => set.has_kv("panic", p.as_ref()),
149153
cfg_expr::expr::TargetPredicate::PointerWidth(w) => {

src/config.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use std::collections::{BTreeMap, HashMap, HashSet};
1515
/// `[workspace.metadata.cargo-feature-combinations]` instead.
1616
#[derive(Serialize, Deserialize, Default, Debug, Clone)]
1717
pub struct Config {
18-
#[serde(default)]
1918
/// Feature sets that must be tested in isolation.
19+
#[serde(default)]
2020
pub isolated_feature_sets: Vec<HashSet<String>>,
2121
/// Formerly named `denylist`
2222
#[serde(default)]
@@ -57,23 +57,23 @@ pub struct Config {
5757
/// Formerly named `exact_combinations`
5858
#[serde(default)]
5959
pub include_feature_sets: Vec<HashSet<String>>,
60-
#[serde(default)]
6160
/// Explicitly allowed feature sets.
62-
pub allow_feature_sets: Vec<HashSet<String>>,
6361
#[serde(default)]
62+
pub allow_feature_sets: Vec<HashSet<String>>,
6463
/// When enabled, disallow generating the empty feature set.
65-
pub no_empty_feature_set: bool,
6664
#[serde(default)]
65+
pub no_empty_feature_set: bool,
6766
/// Arbitrary user-defined matrix values forwarded to the runner.
67+
#[serde(default)]
6868
pub matrix: HashMap<String, serde_json::Value>,
6969

7070
/// Target-specific configuration overrides.
7171
///
7272
/// This is read from `[package.metadata.cargo-feature-combinations.target.'cfg(...)']`.
7373
#[serde(default)]
7474
pub target: BTreeMap<String, TargetOverride>,
75-
#[serde(flatten)]
7675
/// Deprecated configuration keys (kept for backwards compatibility).
76+
#[serde(flatten)]
7777
pub deprecated: DeprecatedConfig,
7878
}
7979

@@ -88,56 +88,56 @@ pub struct TargetOverride {
8888
#[serde(default)]
8989
pub replace: bool,
9090

91-
#[serde(default)]
9291
/// Patch operations for [`Config::isolated_feature_sets`].
93-
pub isolated_feature_sets: Option<FeatureSetVecPatch>,
9492
#[serde(default)]
93+
pub isolated_feature_sets: Option<FeatureSetVecPatch>,
9594
/// Patch operations for [`Config::exclude_features`].
96-
pub exclude_features: Option<StringSetPatch>,
9795
#[serde(default)]
96+
pub exclude_features: Option<StringSetPatch>,
9897
/// Patch operations for [`Config::include_features`].
99-
pub include_features: Option<StringSetPatch>,
10098
#[serde(default)]
99+
pub include_features: Option<StringSetPatch>,
101100
/// Patch operations for [`Config::only_features`].
102-
pub only_features: Option<StringSetPatch>,
103101
#[serde(default)]
102+
pub only_features: Option<StringSetPatch>,
104103
/// Override for [`Config::skip_optional_dependencies`].
105-
pub skip_optional_dependencies: Option<bool>,
106104
#[serde(default)]
105+
pub skip_optional_dependencies: Option<bool>,
107106
/// Patch operations for [`Config::exclude_feature_sets`].
108-
pub exclude_feature_sets: Option<FeatureSetVecPatch>,
109107
#[serde(default)]
108+
pub exclude_feature_sets: Option<FeatureSetVecPatch>,
110109
/// Patch operations for [`Config::include_feature_sets`].
111-
pub include_feature_sets: Option<FeatureSetVecPatch>,
112110
#[serde(default)]
111+
pub include_feature_sets: Option<FeatureSetVecPatch>,
113112
/// Patch operations for [`Config::allow_feature_sets`].
114-
pub allow_feature_sets: Option<FeatureSetVecPatch>,
115113
#[serde(default)]
114+
pub allow_feature_sets: Option<FeatureSetVecPatch>,
116115
/// Override for [`Config::no_empty_feature_set`].
117-
pub no_empty_feature_set: Option<bool>,
118116
#[serde(default)]
117+
pub no_empty_feature_set: Option<bool>,
119118
/// Merge override for [`Config::matrix`].
119+
#[serde(default)]
120120
pub matrix: Option<HashMap<String, serde_json::Value>>,
121121
}
122122

123-
#[derive(Serialize, Deserialize, Default, Debug, Clone)]
124123
/// Workspace-wide configuration for `cargo-feature-combinations`.
124+
#[derive(Serialize, Deserialize, Default, Debug, Clone)]
125125
pub struct WorkspaceConfig {
126126
/// List of package names to exclude from the workspace analysis.
127127
#[serde(default)]
128128
pub exclude_packages: HashSet<String>,
129129
}
130130

131-
#[derive(Serialize, Deserialize, Default, Debug, Clone)]
132131
/// Deprecated configuration keys kept for backwards compatibility.
132+
#[derive(Serialize, Deserialize, Default, Debug, Clone)]
133133
pub struct DeprecatedConfig {
134-
#[serde(default)]
135134
/// Former name of [`Config::exclude_feature_sets`].
136-
pub skip_feature_sets: Vec<HashSet<String>>,
137135
#[serde(default)]
136+
pub skip_feature_sets: Vec<HashSet<String>>,
138137
/// Former name of [`Config::exclude_features`].
139-
pub denylist: HashSet<String>,
140138
#[serde(default)]
139+
pub denylist: HashSet<String>,
141140
/// Former name of [`Config::include_feature_sets`].
141+
#[serde(default)]
142142
pub exact_combinations: Vec<HashSet<String>>,
143143
}

src/config/patch.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,30 @@ pub enum StringSetPatch {
1616
Override(HashSet<String>),
1717
/// Explicit patch syntax: `key = { override = [...], add = [...], remove = [...] }`.
1818
Patch {
19-
#[serde(default)]
2019
/// If present, replace the entire value instead of applying add/remove.
21-
r#override: Option<HashSet<String>>,
2220
#[serde(default)]
21+
r#override: Option<HashSet<String>>,
2322
/// Values to add to the base set.
24-
add: HashSet<String>,
2523
#[serde(default)]
24+
add: HashSet<String>,
2625
/// Values to remove from the base set.
26+
#[serde(default)]
2727
remove: HashSet<String>,
2828
},
2929
}
3030

3131
impl StringSetPatch {
32-
#[must_use]
3332
/// Return the override value, if the patch is an override.
33+
#[must_use]
3434
pub fn override_value(&self) -> Option<&HashSet<String>> {
3535
match self {
3636
Self::Override(v) => Some(v),
3737
Self::Patch { r#override, .. } => r#override.as_ref(),
3838
}
3939
}
4040

41-
#[must_use]
4241
/// Return the set of values to add.
42+
#[must_use]
4343
pub fn add_values(&self) -> &HashSet<String> {
4444
static EMPTY: std::sync::LazyLock<HashSet<String>> = std::sync::LazyLock::new(HashSet::new);
4545
match self {
@@ -48,8 +48,8 @@ impl StringSetPatch {
4848
}
4949
}
5050

51-
#[must_use]
5251
/// Return the set of values to remove.
52+
#[must_use]
5353
pub fn remove_values(&self) -> &HashSet<String> {
5454
static EMPTY: std::sync::LazyLock<HashSet<String>> = std::sync::LazyLock::new(HashSet::new);
5555
match self {
@@ -58,8 +58,8 @@ impl StringSetPatch {
5858
}
5959
}
6060

61-
#[must_use]
6261
/// Return `true` if the patch contains any add/remove operations.
62+
#[must_use]
6363
pub fn has_add_or_remove(&self) -> bool {
6464
!self.add_values().is_empty() || !self.remove_values().is_empty()
6565
}
@@ -73,30 +73,30 @@ pub enum FeatureSetVecPatch {
7373
Override(Vec<HashSet<String>>),
7474
/// Explicit patch syntax.
7575
Patch {
76-
#[serde(default)]
7776
/// If present, replace the entire list instead of applying add/remove.
78-
r#override: Option<Vec<HashSet<String>>>,
7977
#[serde(default)]
78+
r#override: Option<Vec<HashSet<String>>>,
8079
/// Feature sets to append.
81-
add: Vec<HashSet<String>>,
8280
#[serde(default)]
81+
add: Vec<HashSet<String>>,
8382
/// Feature sets to remove.
83+
#[serde(default)]
8484
remove: Vec<HashSet<String>>,
8585
},
8686
}
8787

8888
impl FeatureSetVecPatch {
89-
#[must_use]
9089
/// Return the override value, if the patch is an override.
90+
#[must_use]
9191
pub fn override_value(&self) -> Option<&Vec<HashSet<String>>> {
9292
match self {
9393
Self::Override(v) => Some(v),
9494
Self::Patch { r#override, .. } => r#override.as_ref(),
9595
}
9696
}
9797

98-
#[must_use]
9998
/// Return the feature sets to add.
99+
#[must_use]
100100
pub fn add_values(&self) -> &[HashSet<String>] {
101101
static EMPTY: std::sync::LazyLock<Vec<HashSet<String>>> =
102102
std::sync::LazyLock::new(Vec::new);
@@ -106,8 +106,8 @@ impl FeatureSetVecPatch {
106106
}
107107
}
108108

109-
#[must_use]
110109
/// Return the feature sets to remove.
110+
#[must_use]
111111
pub fn remove_values(&self) -> &[HashSet<String>] {
112112
static EMPTY: std::sync::LazyLock<Vec<HashSet<String>>> =
113113
std::sync::LazyLock::new(Vec::new);
@@ -117,8 +117,8 @@ impl FeatureSetVecPatch {
117117
}
118118
}
119119

120-
#[must_use]
121120
/// Return `true` if the patch contains any add/remove operations.
121+
#[must_use]
122122
pub fn has_add_or_remove(&self) -> bool {
123123
!self.add_values().is_empty() || !self.remove_values().is_empty()
124124
}

0 commit comments

Comments
 (0)