diff --git a/Cargo.lock b/Cargo.lock index d8cea76df1..38bbaec345 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -545,6 +545,7 @@ dependencies = [ "pretty_assertions", "rand", "regex", + "rustversion", "semver", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 65154c0d0c..f10743b9af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,6 +38,7 @@ once_cell = "1.19.0" percent-encoding = "2.3.1" rand = "0.8.5" regex = "1.10.4" +rustversion = "1.0.18" semver = "1.0.20" serde = { version = "1.0.130", features = ["derive", "rc"] } serde_json = "1.0.68" diff --git a/crates/generate-book/src/main.rs b/crates/generate-book/src/main.rs index e261129ecb..4c6a13c161 100644 --- a/crates/generate-book/src/main.rs +++ b/crates/generate-book/src/main.rs @@ -49,7 +49,7 @@ struct Chapter<'a> { language: Language, } -impl<'a> Chapter<'a> { +impl Chapter<'_> { fn title(&self) -> String { if self.index == 0 { return self.language.introduction().into(); diff --git a/src/alias.rs b/src/alias.rs index 286cefd064..5d95849911 100644 --- a/src/alias.rs +++ b/src/alias.rs @@ -47,7 +47,7 @@ impl<'src> Display for Alias<'src, Name<'src>> { } } -impl<'src> Display for Alias<'src> { +impl Display for Alias<'_> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { write!( f, diff --git a/src/assignment.rs b/src/assignment.rs index eb50f510c4..5822fc6a19 100644 --- a/src/assignment.rs +++ b/src/assignment.rs @@ -3,7 +3,7 @@ use super::*; /// An assignment, e.g `foo := bar` pub(crate) type Assignment<'src> = Binding<'src, Expression<'src>>; -impl<'src> Display for Assignment<'src> { +impl Display for Assignment<'_> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { if self.export { write!(f, "export ")?; diff --git a/src/ast.rs b/src/ast.rs index 1ad7a8aa22..30354f5bbb 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -11,7 +11,7 @@ pub(crate) struct Ast<'src> { pub(crate) working_directory: PathBuf, } -impl<'src> Display for Ast<'src> { +impl Display for Ast<'_> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { let mut iter = self.items.iter().peekable(); diff --git a/src/attribute.rs b/src/attribute.rs index b2710d3dbd..39a0a80060 100644 --- a/src/attribute.rs +++ b/src/attribute.rs @@ -113,7 +113,7 @@ impl<'src> Attribute<'src> { } } -impl<'src> Display for Attribute<'src> { +impl Display for Attribute<'_> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { write!(f, "{}", self.name())?; diff --git a/src/color_display.rs b/src/color_display.rs index 384a724f4a..8d1147f064 100644 --- a/src/color_display.rs +++ b/src/color_display.rs @@ -13,7 +13,7 @@ pub(crate) trait ColorDisplay { pub(crate) struct Wrapper<'a>(&'a dyn ColorDisplay, Color); -impl<'a> Display for Wrapper<'a> { +impl Display for Wrapper<'_> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { self.0.fmt(f, self.1) } diff --git a/src/condition.rs b/src/condition.rs index 8c2a8add96..8ab31f71af 100644 --- a/src/condition.rs +++ b/src/condition.rs @@ -7,13 +7,13 @@ pub(crate) struct Condition<'src> { pub(crate) operator: ConditionalOperator, } -impl<'src> Display for Condition<'src> { +impl Display for Condition<'_> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { write!(f, "{} {} {}", self.lhs, self.operator, self.rhs) } } -impl<'src> Serialize for Condition<'src> { +impl Serialize for Condition<'_> { fn serialize(&self, serializer: S) -> Result where S: Serializer, diff --git a/src/dependency.rs b/src/dependency.rs index 5f6dce589c..64ef466509 100644 --- a/src/dependency.rs +++ b/src/dependency.rs @@ -7,7 +7,7 @@ pub(crate) struct Dependency<'src> { pub(crate) recipe: Rc>, } -impl<'src> Display for Dependency<'src> { +impl Display for Dependency<'_> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { if self.arguments.is_empty() { write!(f, "{}", self.recipe.name()) diff --git a/src/error.rs b/src/error.rs index 72438048b2..b8774a2515 100644 --- a/src/error.rs +++ b/src/error.rs @@ -240,7 +240,7 @@ impl<'src> From> for Error<'src> { } } -impl<'src> From for Error<'src> { +impl From for Error<'_> { fn from(config_error: ConfigError) -> Self { Self::Config { config_error } } @@ -252,13 +252,13 @@ impl<'src> From for Error<'src> { } } -impl<'src> From for Error<'src> { +impl From for Error<'_> { fn from(search_error: SearchError) -> Self { Self::Search { search_error } } } -impl<'src> ColorDisplay for Error<'src> { +impl ColorDisplay for Error<'_> { fn fmt(&self, f: &mut Formatter, color: Color) -> fmt::Result { use Error::*; diff --git a/src/executor.rs b/src/executor.rs index 08fadf985d..b99119b697 100644 --- a/src/executor.rs +++ b/src/executor.rs @@ -5,7 +5,7 @@ pub(crate) enum Executor<'a> { Shebang(Shebang<'a>), } -impl<'a> Executor<'a> { +impl Executor<'_> { pub(crate) fn command<'src>( &self, path: &Path, diff --git a/src/expression.rs b/src/expression.rs index 3d5c339211..c7c8eada63 100644 --- a/src/expression.rs +++ b/src/expression.rs @@ -60,7 +60,7 @@ impl<'src> Expression<'src> { } } -impl<'src> Display for Expression<'src> { +impl Display for Expression<'_> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { match self { Self::And { lhs, rhs } => write!(f, "{lhs} && {rhs}"), @@ -86,7 +86,7 @@ impl<'src> Display for Expression<'src> { } } -impl<'src> Serialize for Expression<'src> { +impl Serialize for Expression<'_> { fn serialize(&self, serializer: S) -> Result where S: Serializer, diff --git a/src/fragment.rs b/src/fragment.rs index 04a6b9e30d..a6aa316a24 100644 --- a/src/fragment.rs +++ b/src/fragment.rs @@ -9,7 +9,7 @@ pub(crate) enum Fragment<'src> { Interpolation { expression: Expression<'src> }, } -impl<'src> Serialize for Fragment<'src> { +impl Serialize for Fragment<'_> { fn serialize(&self, serializer: S) -> Result where S: Serializer, diff --git a/src/interpreter.rs b/src/interpreter.rs index eaf6c2ad5f..1045d6ceb8 100644 --- a/src/interpreter.rs +++ b/src/interpreter.rs @@ -6,7 +6,7 @@ pub(crate) struct Interpreter<'src> { pub(crate) command: StringLiteral<'src>, } -impl<'src> Interpreter<'src> { +impl Interpreter<'_> { pub(crate) fn default_script_interpreter() -> &'static Interpreter<'static> { static INSTANCE: Lazy> = Lazy::new(|| Interpreter { arguments: vec![StringLiteral::from_raw("-eu")], @@ -16,7 +16,7 @@ impl<'src> Interpreter<'src> { } } -impl<'src> Display for Interpreter<'src> { +impl Display for Interpreter<'_> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { write!(f, "{}", self.command)?; diff --git a/src/item.rs b/src/item.rs index 08d723fe70..875951f098 100644 --- a/src/item.rs +++ b/src/item.rs @@ -27,7 +27,7 @@ pub(crate) enum Item<'src> { }, } -impl<'src> Display for Item<'src> { +impl Display for Item<'_> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { match self { Self::Alias(alias) => write!(f, "{alias}"), diff --git a/src/justfile.rs b/src/justfile.rs index c846900a7c..4af175c1ed 100644 --- a/src/justfile.rs +++ b/src/justfile.rs @@ -427,7 +427,7 @@ impl<'src> Justfile<'src> { } } -impl<'src> ColorDisplay for Justfile<'src> { +impl ColorDisplay for Justfile<'_> { fn fmt(&self, f: &mut Formatter, color: Color) -> fmt::Result { let mut items = self.recipes.len() + self.assignments.len() + self.aliases.len(); for (name, assignment) in &self.assignments { diff --git a/src/keyed.rs b/src/keyed.rs index e171451eb8..3a7f554bf3 100644 --- a/src/keyed.rs +++ b/src/keyed.rs @@ -18,6 +18,7 @@ where serializer.serialize_str(keyed.key()) } +#[rustversion::attr(since(1.83), allow(clippy::ref_option))] pub(crate) fn serialize_option<'src, S, K>( recipe: &Option, serializer: S, diff --git a/src/line.rs b/src/line.rs index 6218f744d4..d0446118b3 100644 --- a/src/line.rs +++ b/src/line.rs @@ -9,7 +9,7 @@ pub(crate) struct Line<'src> { pub(crate) number: usize, } -impl<'src> Line<'src> { +impl Line<'_> { pub(crate) fn is_empty(&self) -> bool { self.fragments.is_empty() } diff --git a/src/loader.rs b/src/loader.rs index 21e8f73216..ccc8a45c7a 100644 --- a/src/loader.rs +++ b/src/loader.rs @@ -17,7 +17,7 @@ impl Loader { &'src self, root: &Path, path: &Path, - ) -> RunResult<(&'src Path, &'src str)> { + ) -> RunResult<'src, (&'src Path, &'src str)> { let src = fs::read_to_string(path).map_err(|io_error| Error::Load { path: path.into(), io_error, diff --git a/src/name.rs b/src/name.rs index f86063b3e1..93e0ca05cf 100644 --- a/src/name.rs +++ b/src/name.rs @@ -28,7 +28,7 @@ impl Display for Name<'_> { } } -impl<'src> Serialize for Name<'src> { +impl Serialize for Name<'_> { fn serialize(&self, serializer: S) -> Result where S: Serializer, diff --git a/src/namepath.rs b/src/namepath.rs index c896b364a7..3f1a557d48 100644 --- a/src/namepath.rs +++ b/src/namepath.rs @@ -16,7 +16,7 @@ impl<'src> Namepath<'src> { } } -impl<'src> Display for Namepath<'src> { +impl Display for Namepath<'_> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { for (i, name) in self.0.iter().enumerate() { if i > 0 { @@ -28,7 +28,7 @@ impl<'src> Display for Namepath<'src> { } } -impl<'src> Serialize for Namepath<'src> { +impl Serialize for Namepath<'_> { fn serialize(&self, serializer: S) -> Result where S: Serializer, diff --git a/src/parameter.rs b/src/parameter.rs index 359e15d180..f5e247cb59 100644 --- a/src/parameter.rs +++ b/src/parameter.rs @@ -13,7 +13,7 @@ pub(crate) struct Parameter<'src> { pub(crate) name: Name<'src>, } -impl<'src> ColorDisplay for Parameter<'src> { +impl ColorDisplay for Parameter<'_> { fn fmt(&self, f: &mut Formatter, color: Color) -> fmt::Result { if let Some(prefix) = self.kind.prefix() { write!(f, "{}", color.annotation().paint(prefix))?; diff --git a/src/recipe.rs b/src/recipe.rs index b07de478dc..81fbc7ac2f 100644 --- a/src/recipe.rs +++ b/src/recipe.rs @@ -482,7 +482,7 @@ impl<'src, D> Recipe<'src, D> { } } -impl<'src, D: Display> ColorDisplay for Recipe<'src, D> { +impl ColorDisplay for Recipe<'_, D> { fn fmt(&self, f: &mut Formatter, color: Color) -> fmt::Result { if !self .attributes diff --git a/src/recipe_signature.rs b/src/recipe_signature.rs index d805ba65fe..3107a2fee3 100644 --- a/src/recipe_signature.rs +++ b/src/recipe_signature.rs @@ -5,7 +5,7 @@ pub(crate) struct RecipeSignature<'a> { pub(crate) recipe: &'a Recipe<'a>, } -impl<'a> ColorDisplay for RecipeSignature<'a> { +impl ColorDisplay for RecipeSignature<'_> { fn fmt(&self, f: &mut Formatter, color: Color) -> fmt::Result { write!(f, "{}", self.name)?; for parameter in &self.recipe.parameters { diff --git a/src/set.rs b/src/set.rs index 5958578652..377696206a 100644 --- a/src/set.rs +++ b/src/set.rs @@ -12,7 +12,7 @@ impl<'src> Keyed<'src> for Set<'src> { } } -impl<'src> Display for Set<'src> { +impl Display for Set<'_> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { write!(f, "set {} := {}", self.name, self.value) } diff --git a/src/setting.rs b/src/setting.rs index 2b68713580..ec45f30144 100644 --- a/src/setting.rs +++ b/src/setting.rs @@ -22,7 +22,7 @@ pub(crate) enum Setting<'src> { WorkingDirectory(StringLiteral<'src>), } -impl<'src> Display for Setting<'src> { +impl Display for Setting<'_> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { match self { Self::AllowDuplicateRecipes(value) diff --git a/src/show_whitespace.rs b/src/show_whitespace.rs index 2c618d6522..47bb7f6321 100644 --- a/src/show_whitespace.rs +++ b/src/show_whitespace.rs @@ -3,7 +3,7 @@ use super::*; /// String wrapper that uses nonblank characters to display spaces and tabs pub struct ShowWhitespace<'str>(pub &'str str); -impl<'str> Display for ShowWhitespace<'str> { +impl Display for ShowWhitespace<'_> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { for c in self.0.chars() { match c { diff --git a/src/string_literal.rs b/src/string_literal.rs index 2ca411ccdc..b3b0d020a7 100644 --- a/src/string_literal.rs +++ b/src/string_literal.rs @@ -22,7 +22,7 @@ impl<'src> StringLiteral<'src> { } } -impl<'src> Display for StringLiteral<'src> { +impl Display for StringLiteral<'_> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { if self.expand { write!(f, "x")?; @@ -38,7 +38,7 @@ impl<'src> Display for StringLiteral<'src> { } } -impl<'src> Serialize for StringLiteral<'src> { +impl Serialize for StringLiteral<'_> { fn serialize(&self, serializer: S) -> Result where S: Serializer, diff --git a/src/suggestion.rs b/src/suggestion.rs index 8bc371723d..c30c23ead0 100644 --- a/src/suggestion.rs +++ b/src/suggestion.rs @@ -6,7 +6,7 @@ pub(crate) struct Suggestion<'src> { pub(crate) target: Option<&'src str>, } -impl<'src> Display for Suggestion<'src> { +impl Display for Suggestion<'_> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { write!(f, "Did you mean `{}`", self.name)?; if let Some(target) = self.target { diff --git a/src/thunk.rs b/src/thunk.rs index 8c7ddfa8ad..0da9c85577 100644 --- a/src/thunk.rs +++ b/src/thunk.rs @@ -183,7 +183,7 @@ impl Display for Thunk<'_> { } } -impl<'src> Serialize for Thunk<'src> { +impl Serialize for Thunk<'_> { fn serialize(&self, serializer: S) -> Result where S: Serializer, diff --git a/src/token.rs b/src/token.rs index 5ff1a53ac2..2a18c424b8 100644 --- a/src/token.rs +++ b/src/token.rs @@ -21,7 +21,7 @@ impl<'src> Token<'src> { } } -impl<'src> ColorDisplay for Token<'src> { +impl ColorDisplay for Token<'_> { fn fmt(&self, f: &mut Formatter, color: Color) -> fmt::Result { let width = if self.length == 0 { 1 } else { self.length }; diff --git a/src/unresolved_dependency.rs b/src/unresolved_dependency.rs index 3ea49a7cc3..5f600ce3c4 100644 --- a/src/unresolved_dependency.rs +++ b/src/unresolved_dependency.rs @@ -6,7 +6,7 @@ pub(crate) struct UnresolvedDependency<'src> { pub(crate) arguments: Vec>, } -impl<'src> Display for UnresolvedDependency<'src> { +impl Display for UnresolvedDependency<'_> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { if self.arguments.is_empty() { write!(f, "{}", self.recipe) diff --git a/src/variables.rs b/src/variables.rs index 9de1c98ce8..2e4e1ee3c8 100644 --- a/src/variables.rs +++ b/src/variables.rs @@ -10,7 +10,7 @@ impl<'expression, 'src> Variables<'expression, 'src> { } } -impl<'expression, 'src> Iterator for Variables<'expression, 'src> { +impl<'src> Iterator for Variables<'_, 'src> { type Item = Token<'src>; fn next(&mut self) -> Option> {