aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/input.rs
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2024-11-10 16:02:48 -0700
committerMelody Horn <melody@boringcactus.com>2024-11-10 16:02:48 -0700
commit7029372c9fada6316852915765cc0d763be3c63c (patch)
treed649d79de0b83b84637d85595fd6de2cfa38f17c /src/makefile/input.rs
parente9080b515d86b9f39e97d4c8e1a157dfa4ba86f3 (diff)
downloadmakers-7029372c9fada6316852915765cc0d763be3c63c.tar.gz
makers-7029372c9fada6316852915765cc0d763be3c63c.zip
clippy moment
Diffstat (limited to 'src/makefile/input.rs')
-rw-r--r--src/makefile/input.rs29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/makefile/input.rs b/src/makefile/input.rs
index 318493b..ed1140e 100644
--- a/src/makefile/input.rs
+++ b/src/makefile/input.rs
@@ -96,9 +96,11 @@ fn inference_match<'a>(
prerequisites: &[String],
) -> Option<InferenceMatch<'a>> {
lazy_static! {
- static ref INFERENCE_RULE: Regex =
- Regex::new(r"^(?P<s2>(\.[^/.]+)?)(?P<s1>\.[^/.]+)$").unwrap();
- static ref SPECIAL_TARGET: Regex = Regex::new(r"^\.[A-Z]+$").unwrap();
+ static ref INFERENCE_RULE: Regex = #[allow(clippy::unwrap_used)]
+ Regex::new(r"^(?P<s2>(\.[^/.]+)?)(?P<s1>\.[^/.]+)$")
+ .unwrap();
+ static ref SPECIAL_TARGET: Regex = #[allow(clippy::unwrap_used)]
+ Regex::new(r"^\.[A-Z]+$").unwrap();
}
let inference_match = INFERENCE_RULE.captures(targets[0]);
@@ -109,6 +111,7 @@ fn inference_match<'a>(
&& inference_match.is_some()
&& special_target_match.is_none();
if inference_rule {
+ #[allow(clippy::unwrap_used)]
inference_match.map(|x| InferenceMatch {
s1: x.name("s1").unwrap().as_str(),
s2: x.name("s2").unwrap().as_str(),
@@ -128,7 +131,7 @@ where
E: StdError + Send + Sync + 'static,
Inner: Iterator<Item = Result<T, E>>,
{
- fn new(inner: Inner) -> Self {
+ const fn new(inner: Inner) -> Self {
Self(inner, 0)
}
}
@@ -302,7 +305,7 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {
let line_type = LineType::of(&line_tokens);
// before we actually test it, see if it's only visible after expanding macros
- let (line_tokens, line_type) = if let LineType::Unknown = line_type {
+ let (line_tokens, line_type) = if matches!(line_type, LineType::Unknown) {
let line_tokens = TokenString::text(
self.expand_macros(&line_tokens)
.wrap_err_with(|| format!("while parsing line {}", line_number))?
@@ -365,8 +368,7 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {
} else {
let exported = if line_tokens.contains_text("=") {
// that's an assignment!
- let new_macro = self.read_macro(line_tokens, line_number)?;
- new_macro
+ self.read_macro(line_tokens, line_number)?
} else {
self.expand_macros(&line_tokens)?
};
@@ -401,7 +403,8 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {
fn next_line(&mut self, settings: NextLineSettings) -> Option<(usize, Result<String>)> {
lazy_static! {
- static ref COMMENT: Regex = Regex::new(r"(^|[^\\])#.*$").unwrap();
+ static ref COMMENT: Regex = #[allow(clippy::unwrap_used)]
+ Regex::new(r"(^|[^\\])#.*$").unwrap();
}
let escaped_newline_replacement = settings.escaped_newline_replacement;
if let Some((line_number, line)) = self.pending_line.take() {
@@ -522,17 +525,13 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {
}
fn special_target_has_prereq(&self, target: &str, name: &str, empty_counts: bool) -> bool {
- match self
- .targets
+ self.targets
.get(target)
.or_else(|| self.built_in_targets.get(target))
- {
- Some(target) => {
+ .map_or(false, |target| {
(empty_counts && target.prerequisites.is_empty())
|| target.prerequisites.iter().any(|e| e == name)
- }
- None => false,
- }
+ })
}
fn read_include(&mut self, mut line_tokens: TokenString, line_number: usize) -> Result<()> {