diff options
author | Melody Horn <melody@boringcactus.com> | 2021-03-28 18:17:10 -0600 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2021-03-28 18:17:10 -0600 |
commit | 98fa3e5246e83f8121922281a822a8d76f501750 (patch) | |
tree | eeb82d9f9ca14043e19244e9603342a9430a1ab9 /src/makefile/functions.rs | |
parent | 57e4222900de52da5ffe13933fbebe91fbd7bab9 (diff) | |
download | makers-98fa3e5246e83f8121922281a822a8d76f501750.tar.gz makers-98fa3e5246e83f8121922281a822a8d76f501750.zip |
fix the unbounded type recursion (thanks @Lucretiel!)
Diffstat (limited to 'src/makefile/functions.rs')
-rw-r--r-- | src/makefile/functions.rs | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/src/makefile/functions.rs b/src/makefile/functions.rs index 12da6c9..61b9828 100644 --- a/src/makefile/functions.rs +++ b/src/makefile/functions.rs @@ -1,8 +1,8 @@ use super::pattern::r#match; -use super::r#macro::MacroSetLike; +use super::r#macro::{MacroSet, MacroSource}; use super::token::TokenString; -pub(crate) fn expand_call(name: &str, args: &[TokenString], macros: &impl MacroSetLike) -> String { +pub(crate) fn expand_call(name: &str, args: &[TokenString], macros: &MacroSet) -> String { match name { "filter" => { assert_eq!(args.len(), 2); @@ -60,14 +60,10 @@ pub(crate) fn expand_call(name: &str, args: &[TokenString], macros: &impl MacroS // Text Functions mod text { use super::r#match; - use super::MacroSetLike; + use super::MacroSet; use super::TokenString; - pub(crate) fn filter( - macros: &impl MacroSetLike, - patterns: &TokenString, - text: &TokenString, - ) -> String { + pub(crate) fn filter(macros: &MacroSet, patterns: &TokenString, text: &TokenString) -> String { let patterns = macros.expand(patterns); let patterns = patterns.split_whitespace().collect::<Vec<_>>(); let text = macros.expand(text); @@ -85,7 +81,7 @@ mod text { } pub(crate) fn filter_out( - macros: &impl MacroSetLike, + macros: &MacroSet, patterns: &TokenString, text: &TokenString, ) -> String { @@ -105,7 +101,7 @@ mod text { result_pieces.join(" ") } - pub(crate) fn sort(macros: &impl MacroSetLike, words: &TokenString) -> String { + pub(crate) fn sort(macros: &MacroSet, words: &TokenString) -> String { let words = macros.expand(words); let mut words = words.split_whitespace().collect::<Vec<_>>(); words.sort_unstable(); @@ -120,10 +116,10 @@ mod file_name { use std::ffi::OsStr; use std::path::Path; - use super::MacroSetLike; + use super::MacroSet; use super::TokenString; - pub(crate) fn notdir(macros: &impl MacroSetLike, words: &TokenString) -> String { + pub(crate) fn notdir(macros: &MacroSet, words: &TokenString) -> String { let words = macros.expand(words); let words = words .split_whitespace() @@ -137,7 +133,7 @@ mod file_name { words.join(" ") } - pub(crate) fn basename(macros: &impl MacroSetLike, words: &TokenString) -> String { + pub(crate) fn basename(macros: &MacroSet, words: &TokenString) -> String { let words = macros.expand(words); let words = words .split_whitespace() @@ -152,7 +148,7 @@ mod file_name { } pub(crate) fn addprefix( - macros: &impl MacroSetLike, + macros: &MacroSet, prefix: &TokenString, targets: &TokenString, ) -> String { @@ -165,7 +161,7 @@ mod file_name { results.join(" ") } - pub(crate) fn wildcard(macros: &impl MacroSetLike, pattern: &TokenString) -> String { + pub(crate) fn wildcard(macros: &MacroSet, pattern: &TokenString) -> String { let pattern = macros.expand(pattern); let home_dir = env::var("HOME") .ok() @@ -188,11 +184,12 @@ mod file_name { // foreach mod foreach { - use super::MacroSetLike; + use super::MacroSet; + use super::MacroSource; use super::TokenString; pub(crate) fn foreach( - macros: &impl MacroSetLike, + macros: &MacroSet, var: &TokenString, list: &TokenString, text: &TokenString, @@ -204,7 +201,7 @@ mod foreach { let mut macros = macros.with_overlay(); let results = words .map(|word| { - macros.set(var.clone(), TokenString::text(word)); + macros.set(var.clone(), MacroSource::File, TokenString::text(word)); macros.expand(text) }) .collect::<Vec<_>>(); @@ -214,11 +211,12 @@ mod foreach { // call mod call { - use super::MacroSetLike; + use super::MacroSet; + use super::MacroSource; use super::TokenString; pub(crate) fn call<'a>( - macros: &impl MacroSetLike, + macros: &MacroSet, args: impl Iterator<Item = &'a TokenString>, ) -> String { let args = args.map(|arg| macros.expand(arg)).collect::<Vec<_>>(); @@ -226,7 +224,7 @@ mod call { let mut macros = macros.with_overlay(); for (i, x) in args.into_iter().enumerate() { - macros.set(i.to_string(), TokenString::text(x)); + macros.set(i.to_string(), MacroSource::File, TokenString::text(x)); } macros.expand(&TokenString::r#macro(function)) } |