Skip to content

Commit

Permalink
remove unnecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
CPunisher committed Dec 23, 2024
1 parent 2edb453 commit 954be0c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
16 changes: 8 additions & 8 deletions crates/rspack_core/src/options/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ impl RuleSetCondition {
}

#[async_recursion]
pub async fn match_when_empty(&self) -> Result<bool> {
async fn match_when_empty(&self) -> Result<bool> {
let res = match self {
RuleSetCondition::String(s) => s.len() == 0,

Check failure on line 644 in crates/rspack_core/src/options/module.rs

View workflow job for this annotation

GitHub Actions / Rust check

length comparison to zero
RuleSetCondition::Regexp(rspack_regex) => rspack_regex.test(""),
Expand All @@ -655,7 +655,7 @@ impl RuleSetCondition {

#[derive(Debug)]
pub struct RuleSetConditionMatch {
pub condition: RuleSetCondition,
condition: RuleSetCondition,
match_when_empty: RwLock<Option<bool>>,
}

Expand Down Expand Up @@ -759,17 +759,17 @@ pub struct ModuleRule {
/// Note:
/// This is a custom matching rule not initially designed by webpack.
/// Only for single-threaded environment interoperation purpose.
pub rspack_resource: Option<RuleSetConditionMatch>,
pub rspack_resource: Option<RuleSetCondition>,
/// A condition matcher matching an absolute path.
pub test: Option<RuleSetConditionMatch>,
pub include: Option<RuleSetConditionMatch>,
pub exclude: Option<RuleSetConditionMatch>,
pub test: Option<RuleSetCondition>,
pub include: Option<RuleSetCondition>,
pub exclude: Option<RuleSetCondition>,
/// A condition matcher matching an absolute path.
pub resource: Option<RuleSetConditionMatch>,
pub resource: Option<RuleSetCondition>,
/// A condition matcher against the resource query.
pub resource_query: Option<RuleSetConditionMatch>,
pub resource_fragment: Option<RuleSetConditionMatch>,
pub dependency: Option<RuleSetConditionMatch>,
pub dependency: Option<RuleSetCondition>,
pub issuer: Option<RuleSetConditionMatch>,
pub issuer_layer: Option<RuleSetConditionMatch>,
pub scheme: Option<RuleSetConditionMatch>,
Expand Down
16 changes: 6 additions & 10 deletions crates/rspack_core/src/utils/module_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub async fn module_rule_matcher<'a>(
return Ok(false);
}
} else {

Check failure on line 89 in crates/rspack_core/src/utils/module_rules.rs

View workflow job for this annotation

GitHub Actions / Rust check

this `else { if .. }` block can be collapsed
if !resource_query_rule.condition.match_when_empty().await? {
if !resource_query_rule.match_when_empty().await? {
return Ok(false);
}
}
Expand All @@ -102,11 +102,7 @@ pub async fn module_rule_matcher<'a>(
return Ok(false);
}
} else {

Check failure on line 104 in crates/rspack_core/src/utils/module_rules.rs

View workflow job for this annotation

GitHub Actions / Rust check

this `else { if .. }` block can be collapsed
if !resource_fragment_condition
.condition
.match_when_empty()
.await?
{
if !resource_fragment_condition.match_when_empty().await? {
return Ok(false);
}
}
Expand All @@ -121,7 +117,7 @@ pub async fn module_rule_matcher<'a>(
return Ok(false);
}
} else {

Check failure on line 119 in crates/rspack_core/src/utils/module_rules.rs

View workflow job for this annotation

GitHub Actions / Rust check

this `else { if .. }` block can be collapsed
if !mimetype_condition.condition.match_when_empty().await? {
if !mimetype_condition.match_when_empty().await? {
return Ok(false);
}
}
Expand All @@ -130,7 +126,7 @@ pub async fn module_rule_matcher<'a>(
if let Some(scheme_condition) = &module_rule.scheme {
let scheme = resource_data.get_scheme();
if scheme.is_none() {

Check failure on line 128 in crates/rspack_core/src/utils/module_rules.rs

View workflow job for this annotation

GitHub Actions / Rust check

this `if` statement can be collapsed
if !scheme_condition.condition.match_when_empty().await? {
if !scheme_condition.match_when_empty().await? {
return Ok(false);
}
}
Expand All @@ -147,7 +143,7 @@ pub async fn module_rule_matcher<'a>(
}
}
None => {
if !issuer_rule.condition.match_when_empty().await? {
if !issuer_rule.match_when_empty().await? {
return Ok(false);
}
}
Expand All @@ -162,7 +158,7 @@ pub async fn module_rule_matcher<'a>(
}
}
None => {
if !issuer_layer_rule.condition.match_when_empty().await? {
if !issuer_layer_rule.match_when_empty().await? {
return Ok(false);
}
}
Expand Down

0 comments on commit 954be0c

Please sign in to comment.