From 5e385e6f2c5cd11752055bfa8d2539d6e1062e3f Mon Sep 17 00:00:00 2001 From: Serial <69764315+Serial-ATA@users.noreply.github.com> Date: Tue, 23 Apr 2024 21:55:10 -0400 Subject: [PATCH] misc: Use workspace lints table closes: #311 --- Cargo.toml | 48 ++++++++++++++++++++++++++++++++++++ lofty/Cargo.toml | 3 +++ lofty/src/lib.rs | 45 --------------------------------- lofty/src/mp4/ilst/write.rs | 14 +++++------ lofty_attr/Cargo.toml | 3 +++ lofty_attr/src/lofty_file.rs | 2 +- lofty_attr/src/lofty_tag.rs | 2 +- ogg_pager/Cargo.toml | 3 +++ ogg_pager/src/header.rs | 1 + ogg_pager/src/paginate.rs | 9 ++----- 10 files changed, 68 insertions(+), 62 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0d06e74ea..c204ec369 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,5 +9,53 @@ members = [ [workspace.dependencies] byteorder = "1.5.0" +[workspace.lints.rust] +missing_docs = "deny" +rust_2018_idioms = "deny" +trivial_casts = "deny" +trivial_numeric_casts = "deny" +unused_import_braces = "deny" +explicit_outlives_requirements = "deny" +unknown_lints = "allow" + +[workspace.lints.clippy] +dbg_macro = "forbid" +string_to_string = "forbid" +pedantic = { level = "deny", priority = -1 } +all = { level = "deny", priority = -1 } +too_many_lines = "allow" +cast_precision_loss = "allow" +cast_sign_loss = "allow" +cast_possible_wrap = "allow" +cast_possible_truncation = "allow" +module_name_repetitions = "allow" +must_use_candidate = "allow" +doc_markdown = "allow" +match_wildcard_for_single_variants = "allow" +semicolon_if_nothing_returned = "allow" +from_over_into = "allow" +upper_case_acronyms = "allow" +single_match_else = "allow" +similar_names = "allow" +tabs_in_doc_comments = "allow" +len_without_is_empty = "allow" +needless_late_init = "allow" +type_complexity = "allow" +return_self_not_must_use = "allow" +bool_to_int_with_if = "allow" +uninlined_format_args = "allow" # This should be changed for any normal "{}", but I'm not a fan of it for any debug or width specific formatting +let_underscore_untyped = "allow" +field_reassign_with_default = "allow" +manual_range_patterns = "allow" # This is not at all clearer as it suggests +no_effect_underscore_binding = "allow" +used_underscore_binding = "allow" +ignored_unit_patterns = "allow" # Not a fan of this lint, doesn't make anything clearer as it claims +needless_return = "allow" # Explicit returns are needed from time to time for clarity +redundant_guards = "allow" # Currently broken for some cases, might enable later +into_iter_without_iter = "allow" # This is only going to fire on some internal types, doesn't matter much + +[workspace.lints.rustdoc] +broken_intra_doc_links = "deny" + [profile.bench] debug = true diff --git a/lofty/Cargo.toml b/lofty/Cargo.toml index 6eab5ef5f..04540aef5 100644 --- a/lofty/Cargo.toml +++ b/lofty/Cargo.toml @@ -38,6 +38,9 @@ structopt = { version = "0.3.26", default-features = false } tempfile = "3.10.1" iai-callgrind = "0.10.2" +[lints] +workspace = true + [lib] bench = false diff --git a/lofty/src/lib.rs b/lofty/src/lib.rs index d2a6a634a..652691457 100644 --- a/lofty/src/lib.rs +++ b/lofty/src/lib.rs @@ -99,51 +99,6 @@ //! //! All formats have their own quirks that may produce unexpected results between conversions. //! Be sure to read the module documentation of each format to see important notes and warnings. -#![forbid(clippy::dbg_macro, clippy::string_to_string)] -#![deny( - clippy::pedantic, - clippy::all, - missing_docs, - rustdoc::broken_intra_doc_links, - rust_2018_idioms, - trivial_casts, - trivial_numeric_casts, - unused_import_braces, - explicit_outlives_requirements -)] -#![allow( - unknown_lints, - clippy::too_many_lines, - clippy::cast_precision_loss, - clippy::cast_sign_loss, - clippy::cast_possible_wrap, - clippy::cast_possible_truncation, - clippy::module_name_repetitions, - clippy::must_use_candidate, - clippy::doc_markdown, - clippy::match_wildcard_for_single_variants, - clippy::semicolon_if_nothing_returned, - clippy::from_over_into, - clippy::upper_case_acronyms, - clippy::single_match_else, - clippy::similar_names, - clippy::tabs_in_doc_comments, - clippy::len_without_is_empty, - clippy::needless_late_init, - clippy::type_complexity, - clippy::return_self_not_must_use, - clippy::bool_to_int_with_if, - clippy::uninlined_format_args, /* This should be changed for any normal "{}", but I'm not a fan of it for any debug or width specific formatting */ - clippy::let_underscore_untyped, - clippy::field_reassign_with_default, - clippy::manual_range_patterns, /* This is not at all clearer as it suggests */ - clippy::no_effect_underscore_binding, - clippy::used_underscore_binding, - clippy::ignored_unit_patterns, /* Not a fan of this lint, doesn't make anything clearer as it claims */ - clippy::needless_return, /* Explicit returns are needed from time to time for clarity */ - clippy::redundant_guards, /* Currently broken for some cases, might enable later*/ - clippy::into_iter_without_iter, /* This is only going to fire on some internal types, doesn't matter much */ -)] #![cfg_attr(docsrs, feature(doc_auto_cfg))] #![doc(html_logo_url = "https://raw.githubusercontent.com/Serial-ATA/lofty-rs/main/doc/lofty.svg")] diff --git a/lofty/src/mp4/ilst/write.rs b/lofty/src/mp4/ilst/write.rs index df5aeab1a..a4a40554e 100644 --- a/lofty/src/mp4/ilst/write.rs +++ b/lofty/src/mp4/ilst/write.rs @@ -20,7 +20,7 @@ const FULL_ATOM_SIZE: u64 = ATOM_HEADER_LEN + 4; const HDLR_SIZE: u64 = ATOM_HEADER_LEN + 25; // TODO: We are forcing the use of ParseOptions::DEFAULT_PARSING_MODE. This is not good. It should be caller-specified. -pub(crate) fn write_to<'a, F, I: 'a>( +pub(crate) fn write_to<'a, F, I>( file: &mut F, tag: &mut IlstRef<'a, I>, write_options: WriteOptions, @@ -29,7 +29,7 @@ where F: FileLike, LoftyError: From<::Error>, LoftyError: From<::Error>, - I: IntoIterator, + I: IntoIterator + 'a, { log::debug!("Attempting to write `ilst` tag to file"); @@ -577,11 +577,9 @@ fn create_meta(writer: &AtomWriter, ilst: &[u8]) -> Result<()> { Ok(()) } -pub(super) fn build_ilst<'a, I: 'a>( - atoms: &mut dyn Iterator>, -) -> Result> +pub(super) fn build_ilst<'a, I>(atoms: &mut dyn Iterator>) -> Result> where - I: IntoIterator, + I: IntoIterator + 'a, { log::debug!("Building `ilst` atom"); @@ -656,9 +654,9 @@ where Ok(()) } -fn write_atom_data<'a, I: 'a>(data: I, writer: &mut AtomWriterCompanion<'_>) -> Result<()> +fn write_atom_data<'a, I>(data: I, writer: &mut AtomWriterCompanion<'_>) -> Result<()> where - I: IntoIterator, + I: IntoIterator + 'a, { for value in data { match value { diff --git a/lofty_attr/Cargo.toml b/lofty_attr/Cargo.toml index d88c5150d..2c707ea57 100644 --- a/lofty_attr/Cargo.toml +++ b/lofty_attr/Cargo.toml @@ -14,5 +14,8 @@ syn = { version = "2.0.25", features = ["full", "parsing"] } quote = "1.0.29" proc-macro2 = "1.0.64" +[lints] +workspace = true + [lib] proc-macro = true diff --git a/lofty_attr/src/lofty_file.rs b/lofty_attr/src/lofty_file.rs index 72637e83a..02cea32c9 100644 --- a/lofty_attr/src/lofty_file.rs +++ b/lofty_attr/src/lofty_file.rs @@ -52,7 +52,7 @@ pub struct LoftyFile { } impl Parse for LoftyFile { - fn parse(input: syn::parse::ParseStream) -> syn::Result { + fn parse(input: syn::parse::ParseStream<'_>) -> syn::Result { let input: DeriveInput = input.parse()?; let data_struct = match input.data { diff --git a/lofty_attr/src/lofty_tag.rs b/lofty_attr/src/lofty_tag.rs index 3e88d45c2..7cedd3b4c 100644 --- a/lofty_attr/src/lofty_tag.rs +++ b/lofty_attr/src/lofty_tag.rs @@ -101,7 +101,7 @@ pub(crate) struct LoftyTagAttribute { } impl Parse for LoftyTagAttribute { - fn parse(input: ParseStream) -> Result { + fn parse(input: ParseStream<'_>) -> Result { let mut description = None; let mut supported_formats = Vec::new(); diff --git a/ogg_pager/Cargo.toml b/ogg_pager/Cargo.toml index 40d38bb3a..af6fa22db 100644 --- a/ogg_pager/Cargo.toml +++ b/ogg_pager/Cargo.toml @@ -12,3 +12,6 @@ include = ["src", "Cargo.toml", "../LICENSE-*"] [dependencies] byteorder = "1.5.0" + +[lints] +workspace = true diff --git a/ogg_pager/src/header.rs b/ogg_pager/src/header.rs index c5fc7bc1c..076a57493 100644 --- a/ogg_pager/src/header.rs +++ b/ogg_pager/src/header.rs @@ -4,6 +4,7 @@ use std::io::{Read, Seek}; use byteorder::{LittleEndian, ReadBytesExt}; +/// The size of an OGG page header pub const PAGE_HEADER_SIZE: usize = 27; /// An OGG page header diff --git a/ogg_pager/src/paginate.rs b/ogg_pager/src/paginate.rs index 7471f73ed..5664e44d9 100644 --- a/ogg_pager/src/paginate.rs +++ b/ogg_pager/src/paginate.rs @@ -138,14 +138,9 @@ struct PaginateContextFlags { /// /// let pages = paginate(&comment_header_packet, stream_serial_number, 0, 0); /// ``` -pub fn paginate<'a, I: 'a>( - packets: I, - stream_serial: u32, - abgp: u64, - flags: u8, -) -> Result> +pub fn paginate<'a, I>(packets: I, stream_serial: u32, abgp: u64, flags: u8) -> Result> where - I: IntoIterator, + I: IntoIterator + 'a, { let mut ctx = PaginateContext::new(abgp, stream_serial, flags);