Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Rust 1.83 warnings #2487

Merged
merged 2 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion crates/generate-book/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/assignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ")?;
Expand Down
2 changes: 1 addition & 1 deletion src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())?;

Expand Down
2 changes: 1 addition & 1 deletion src/color_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions src/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
2 changes: 1 addition & 1 deletion src/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub(crate) struct Dependency<'src> {
pub(crate) recipe: Rc<Recipe<'src>>,
}

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())
Expand Down
6 changes: 3 additions & 3 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ impl<'src> From<CompileError<'src>> for Error<'src> {
}
}

impl<'src> From<ConfigError> for Error<'src> {
impl From<ConfigError> for Error<'_> {
fn from(config_error: ConfigError) -> Self {
Self::Config { config_error }
}
Expand All @@ -252,13 +252,13 @@ impl<'src> From<dotenvy::Error> for Error<'src> {
}
}

impl<'src> From<SearchError> for Error<'src> {
impl From<SearchError> 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::*;

Expand Down
2 changes: 1 addition & 1 deletion src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"),
Expand All @@ -86,7 +86,7 @@ impl<'src> Display for Expression<'src> {
}
}

impl<'src> Serialize for Expression<'src> {
impl Serialize for Expression<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
2 changes: 1 addition & 1 deletion src/fragment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
4 changes: 2 additions & 2 deletions src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Interpreter<'static>> = Lazy::new(|| Interpreter {
arguments: vec![StringLiteral::from_raw("-eu")],
Expand All @@ -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)?;

Expand Down
2 changes: 1 addition & 1 deletion src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"),
Expand Down
2 changes: 1 addition & 1 deletion src/justfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/keyed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<K>,
serializer: S,
Expand Down
2 changes: 1 addition & 1 deletion src/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Display for Name<'_> {
}
}

impl<'src> Serialize for Name<'src> {
impl Serialize for Name<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
4 changes: 2 additions & 2 deletions src/namepath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -28,7 +28,7 @@ impl<'src> Display for Namepath<'src> {
}
}

impl<'src> Serialize for Namepath<'src> {
impl Serialize for Namepath<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
2 changes: 1 addition & 1 deletion src/parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))?;
Expand Down
2 changes: 1 addition & 1 deletion src/recipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ impl<'src, D> Recipe<'src, D> {
}
}

impl<'src, D: Display> ColorDisplay for Recipe<'src, D> {
impl<D: Display> ColorDisplay for Recipe<'_, D> {
fn fmt(&self, f: &mut Formatter, color: Color) -> fmt::Result {
if !self
.attributes
Expand Down
2 changes: 1 addition & 1 deletion src/recipe_signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion src/setting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/show_whitespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/string_literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")?;
Expand All @@ -38,7 +38,7 @@ impl<'src> Display for StringLiteral<'src> {
}
}

impl<'src> Serialize for StringLiteral<'src> {
impl Serialize for StringLiteral<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
2 changes: 1 addition & 1 deletion src/suggestion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/thunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl Display for Thunk<'_> {
}
}

impl<'src> Serialize for Thunk<'src> {
impl Serialize for Thunk<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
2 changes: 1 addition & 1 deletion src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

Expand Down
2 changes: 1 addition & 1 deletion src/unresolved_dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(crate) struct UnresolvedDependency<'src> {
pub(crate) arguments: Vec<Expression<'src>>,
}

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)
Expand Down
2 changes: 1 addition & 1 deletion src/variables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Token<'src>> {
Expand Down