diff options
author | Melody Horn <melody@boringcactus.com> | 2024-11-10 22:05:44 -0700 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2024-11-10 22:05:44 -0700 |
commit | 87ce694f4d15d84e5737615b2768deaf866a796d (patch) | |
tree | 4332030d2417e7563170ebf6d06efb8a6bd97d86 /src | |
parent | 07b4b35c44d488fea2916e7d985f60f923ed0e4c (diff) | |
download | makers-87ce694f4d15d84e5737615b2768deaf866a796d.tar.gz makers-87ce694f4d15d84e5737615b2768deaf866a796d.zip |
clean up random rustrover lints
Diffstat (limited to 'src')
-rw-r--r-- | src/makefile/command_line.rs | 63 | ||||
-rw-r--r-- | src/makefile/functions.rs | 2 | ||||
-rw-r--r-- | src/makefile/inference_rules.rs | 2 | ||||
-rw-r--r-- | src/makefile/input.rs | 18 | ||||
-rw-r--r-- | src/makefile/mod.rs | 2 |
5 files changed, 19 insertions, 68 deletions
diff --git a/src/makefile/command_line.rs b/src/makefile/command_line.rs index c993a10..52693e0 100644 --- a/src/makefile/command_line.rs +++ b/src/makefile/command_line.rs @@ -42,44 +42,12 @@ fn execute_command_line( #[derive(PartialEq, Eq, Clone, Debug)] pub struct CommandLine { - /// If the command prefix contains a <hyphen-minus>, or the -i option is present, or - /// the special target .IGNORE has either the current target as a prerequisite or has - /// no prerequisites, any error found while executing the command shall be ignored. - ignore_errors: bool, - /// If the command prefix contains an at-sign and the make utility command line -n - /// option is not specified, or the -s option is present, or the special target - /// .SILENT has either the current target as a prerequisite or has no prerequisites, - /// the command shall not be written to standard output before it is executed. - silent: bool, - /// If the command prefix contains a <plus-sign>, this indicates a makefile command - /// line that shall be executed even if -n, -q, or -t is specified. - always_execute: bool, execution_line: TokenString, } impl CommandLine { - pub fn from(mut line: TokenString) -> Self { - let mut ignore_errors = false; - let mut silent = false; - let mut always_execute = false; - - if let Token::Text(text) = line.first_token_mut() { - let mut text_chars = text.chars().peekable(); - while let Some(x) = text_chars.next_if(|x| matches!(x, '-' | '@' | '+')) { - match x { - '-' => ignore_errors = true, - '@' => silent = true, - '+' => always_execute = true, - _ => unreachable!(), - } - } - *text = text_chars.collect(); - } - + pub fn from(line: TokenString) -> Self { Self { - ignore_errors, - silent, - always_execute, execution_line: line, } } @@ -113,28 +81,28 @@ impl CommandLine { } } log::trace!("executing {}", &execution_line); - let mut self_ignore_errors = self.ignore_errors; - let mut self_silent = self.silent; - let mut self_always_execute = self.always_execute; + let mut ignore_errors = false; + let mut silent = false; + let mut always_execute = false; - // apparently some makefiles will just throw this shit in in macros? bruh moment tbh + // sometimes this is defined in macros rather than statically let execution_line: String = { let mut line_chars = execution_line.chars().peekable(); while let Some(x) = line_chars.next_if(|x| matches!(x, '-' | '@' | '+')) { match x { - '-' => self_ignore_errors = true, - '@' => self_silent = true, - '+' => self_always_execute = true, + '-' => ignore_errors = true, + '@' => silent = true, + '+' => always_execute = true, _ => unreachable!(), } } line_chars.collect() }; - let ignore_error = self_ignore_errors + let ignore_error = ignore_errors || file.args.ignore_errors || file.special_target_has_prereq(".IGNORE", &target.name); - let silent = (self_silent && !file.args.dry_run) + let silent = (silent && !file.args.dry_run) || file.args.silent || file.special_target_has_prereq(".SILENT", &target.name); @@ -142,7 +110,7 @@ impl CommandLine { println!("{}", execution_line); } - let should_execute = self_always_execute + let should_execute = always_execute || is_recursive || !(file.args.dry_run || file.args.question || file.args.touch); if !should_execute { @@ -169,15 +137,6 @@ impl CommandLine { impl fmt::Display for CommandLine { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - if self.ignore_errors { - write!(f, "-")?; - } - if self.silent { - write!(f, "@")?; - } - if self.always_execute { - write!(f, "+")?; - } let execution_line = format!("{}", &self.execution_line); let execution_line = execution_line.replace("\n", "↵\n"); write!(f, "{}", execution_line)?; diff --git a/src/makefile/functions.rs b/src/makefile/functions.rs index e76a0d2..1f3c897 100644 --- a/src/makefile/functions.rs +++ b/src/makefile/functions.rs @@ -641,7 +641,7 @@ mod test { type R = Result<()>; fn call(name: &str, args: &[TokenString], macros: &MacroSet) -> Result<String> { - super::expand_call(name, args, macros, NO_EVAL) + expand_call(name, args, macros, NO_EVAL) } macro_rules! call { diff --git a/src/makefile/inference_rules.rs b/src/makefile/inference_rules.rs index f8bdd65..8d4f3b6 100644 --- a/src/makefile/inference_rules.rs +++ b/src/makefile/inference_rules.rs @@ -79,7 +79,7 @@ impl fmt::Display for InferenceRule { mod test { use super::*; - type R = eyre::Result<()>; + type R = Result<()>; #[test] fn suffix_match() -> R { diff --git a/src/makefile/input.rs b/src/makefile/input.rs index fccea3b..25d33e4 100644 --- a/src/makefile/input.rs +++ b/src/makefile/input.rs @@ -24,7 +24,7 @@ use super::r#macro::ExportConfig; use super::r#macro::{Macro, Set as MacroSet}; use super::target::{StaticTargetSet, Target}; use super::token::{Token, TokenString}; -use super::ItemSource; +use super::{builtin_targets, ItemSource}; enum LineType { Rule, @@ -262,18 +262,10 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> { }; // TODO be smart about this instead, please if !args.no_builtin_rules { - reader.built_in_targets.insert( - ".SUFFIXES".to_owned(), - Target { - name: ".SUFFIXES".into(), - prerequisites: vec![".o", ".c", ".y", ".l", ".a", ".sh", ".f"] - .into_iter() - .map(String::from) - .collect(), - commands: vec![], - stem: None, - already_updated: Cell::new(false), - }, + reader.built_in_targets.extend( + builtin_targets() + .into_iter() + .map(|target| (target.name.clone(), target)), ); } reader diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs index d1e9729..8fd7113 100644 --- a/src/makefile/mod.rs +++ b/src/makefile/mod.rs @@ -68,7 +68,7 @@ impl<'a> Makefile<'a> { "MAKE".to_owned(), Macro { source: ItemSource::Builtin, - text: std::env::current_exe().map_or_else( + text: env::current_exe().map_or_else( |_| TokenString::text("makers"), |x| TokenString::text(x.to_string_lossy()), ), |