Skip to content

Upgrade to Rust 1.85 / Edition 2024 #513

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

Merged
merged 2 commits into from
Mar 30, 2025
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
15 changes: 3 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[workspace]
# TODO: Switch to MSRV-aware resolver version "3" (Rust 1.84)
resolver = "2"
resolver = "3"

members = [
"lofty",
Expand All @@ -11,8 +10,8 @@ members = [
]

[workspace.package]
edition = "2021"
rust-version = "1.82"
edition = "2024"
rust-version = "1.85"
repository = "https://github.com/Serial-ATA/lofty-rs"
license = "MIT OR Apache-2.0"

Expand All @@ -34,14 +33,6 @@ unused_import_braces = "deny"
explicit_outlives_requirements = "deny"
unknown_lints = "allow"

# Opt-in to new drop order of Edition 2024.
# TODO: Remove if no longer needed.
tail_expr_drop_order = "allow"
if_let_rescope = "allow"

# TODO: Remove after switching to Edition 2024.
edition_2024_expr_fragment_specifier = "allow"

[workspace.lints.clippy]
dbg_macro = "forbid"
string_to_string = "forbid"
Expand Down
2 changes: 1 addition & 1 deletion benches/create_tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ bench_tag_write!([
);
}),
(id3v2, Id3v2Tag, |tag| {
use lofty::id3::v2::{Frame, TextInformationFrame};
use lofty::TextEncoding;
use lofty::id3::v2::{Frame, TextInformationFrame};

let picture = Picture::new_unchecked(
PictureType::CoverFront,
Expand Down
8 changes: 4 additions & 4 deletions lofty/src/aac/read.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use super::header::{ADTSHeader, HEADER_MASK};
use super::AacFile;
use super::header::{ADTSHeader, HEADER_MASK};
use crate::config::{ParseOptions, ParsingMode};
use crate::error::Result;
use crate::id3::v2::header::Id3v2Header;
use crate::id3::v2::read::parse_id3v2;
use crate::id3::{find_id3v1, ID3FindResults};
use crate::id3::{ID3FindResults, find_id3v1};
use crate::macros::{decode_err, err, parse_mode_choice};
use crate::mpeg::header::{cmp_header, search_for_frame_sync, HeaderCmpResult};
use crate::mpeg::header::{HeaderCmpResult, cmp_header, search_for_frame_sync};

use std::io::{Read, Seek, SeekFrom};

Expand Down Expand Up @@ -180,7 +180,7 @@ where
return Ok(Some((
first_header,
first_adts_frame_start_absolute + u64::from(header_len),
)))
)));
},
HeaderCmpResult::Undetermined => return Ok(None),
HeaderCmpResult::NotEqual => {},
Expand Down
2 changes: 1 addition & 1 deletion lofty/src/ape/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use lofty_attr::LoftyFile;

pub use crate::picture::APE_PICTURE_TYPES;
pub use properties::ApeProperties;
pub use tag::item::ApeItem;
pub use tag::ApeTag;
pub use tag::item::ApeItem;

/// An APE file
#[derive(LoftyFile)]
Expand Down
2 changes: 1 addition & 1 deletion lofty/src/ape/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::error::Result;
use crate::id3::v1::tag::Id3v1Tag;
use crate::id3::v2::read::parse_id3v2;
use crate::id3::v2::tag::Id3v2Tag;
use crate::id3::{find_id3v1, find_id3v2, find_lyrics3v2, FindId3v2Config, ID3FindResults};
use crate::id3::{FindId3v2Config, ID3FindResults, find_id3v1, find_id3v2, find_lyrics3v2};
use crate::macros::{decode_err, err};

use std::io::{Read, Seek, SeekFrom};
Expand Down
4 changes: 2 additions & 2 deletions lofty/src/ape/tag/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ mod write;
use crate::ape::tag::item::{ApeItem, ApeItemRef};
use crate::config::WriteOptions;
use crate::error::{LoftyError, Result};
use crate::id3::v2::util::pairs::{format_number_pair, set_number, NUMBER_PAIR_KEYS};
use crate::id3::v2::util::pairs::{NUMBER_PAIR_KEYS, format_number_pair, set_number};
use crate::tag::item::ItemValueRef;
use crate::tag::{
try_parse_year, Accessor, ItemKey, ItemValue, MergeTag, SplitTag, Tag, TagExt, TagItem, TagType,
Accessor, ItemKey, ItemValue, MergeTag, SplitTag, Tag, TagExt, TagItem, TagType, try_parse_year,
};
use crate::util::flag_item;
use crate::util::io::{FileLike, Truncate};
Expand Down
4 changes: 2 additions & 2 deletions lofty/src/ape/tag/read.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::item::ApeItem;
use super::ApeTag;
use super::item::ApeItem;
use crate::ape::APE_PICTURE_TYPES;
use crate::ape::constants::{APE_PREAMBLE, INVALID_KEYS};
use crate::ape::header::{self, ApeHeader};
use crate::ape::APE_PICTURE_TYPES;
use crate::config::ParseOptions;
use crate::error::Result;
use crate::macros::{decode_err, err, try_vec};
Expand Down
6 changes: 3 additions & 3 deletions lofty/src/ape/tag/write.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use super::item::ApeItemRef;
use super::ApeTagRef;
use super::item::ApeItemRef;
use crate::ape::constants::APE_PREAMBLE;
use crate::ape::tag::read;
use crate::config::{ParseOptions, WriteOptions};
use crate::error::{LoftyError, Result};
use crate::id3::{find_id3v1, find_id3v2, find_lyrics3v2, FindId3v2Config};
use crate::id3::{FindId3v2Config, find_id3v1, find_id3v2, find_lyrics3v2};
use crate::macros::{decode_err, err};
use crate::probe::Probe;
use crate::tag::item::ItemValueRef;
Expand Down Expand Up @@ -134,7 +134,7 @@ where

// Now, if there was a tag at the beginning, remove it
if header_ape_tag.0 {
file_bytes.drain(header_ape_tag.1 .0 as usize..header_ape_tag.1 .1 as usize);
file_bytes.drain(header_ape_tag.1.0 as usize..header_ape_tag.1.1 as usize);
}

file.rewind()?;
Expand Down
10 changes: 5 additions & 5 deletions lofty/src/config/global_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub(crate) unsafe fn global_options() -> &'static GlobalOptions {
/// # Examples
///
/// ```rust
/// use lofty::config::{apply_global_options, GlobalOptions};
/// use lofty::config::{GlobalOptions, apply_global_options};
///
/// // I have a custom resolver that I need checked
/// let global_options = GlobalOptions::new().use_custom_resolvers(true);
Expand Down Expand Up @@ -58,7 +58,7 @@ impl GlobalOptions {
/// # Examples
///
/// ```rust
/// use lofty::config::{apply_global_options, GlobalOptions};
/// use lofty::config::{GlobalOptions, apply_global_options};
///
/// // By default, `use_custom_resolvers` is enabled. Here, we don't want to use them.
/// let global_options = GlobalOptions::new().use_custom_resolvers(false);
Expand All @@ -77,7 +77,7 @@ impl GlobalOptions {
/// # Examples
///
/// ```rust
/// use lofty::config::{apply_global_options, GlobalOptions};
/// use lofty::config::{GlobalOptions, apply_global_options};
///
/// // I have files with gigantic images, I'll double the allocation limit!
/// let global_options = GlobalOptions::new().allocation_limit(32 * 1024 * 1024);
Expand All @@ -100,7 +100,7 @@ impl GlobalOptions {
/// # Examples
///
/// ```rust
/// use lofty::config::{apply_global_options, GlobalOptions};
/// use lofty::config::{GlobalOptions, apply_global_options};
///
/// // I'm just reading tags, I don't need to preserve format-specific items
/// let global_options = GlobalOptions::new().preserve_format_specific_items(false);
Expand Down Expand Up @@ -136,7 +136,7 @@ impl Default for GlobalOptions {
/// # Examples
///
/// ```rust
/// use lofty::config::{apply_global_options, GlobalOptions};
/// use lofty::config::{GlobalOptions, apply_global_options};
///
/// // I have a custom resolver that I need checked
/// let global_options = GlobalOptions::new().use_custom_resolvers(true);
Expand Down
2 changes: 1 addition & 1 deletion lofty/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod global_options;
mod parse_options;
mod write_options;

pub use global_options::{apply_global_options, GlobalOptions};
pub use global_options::{GlobalOptions, apply_global_options};
pub use parse_options::{ParseOptions, ParsingMode};
pub use write_options::WriteOptions;

Expand Down
4 changes: 2 additions & 2 deletions lofty/src/flac/read.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use super::FlacFile;
use super::block::Block;
use super::properties::FlacProperties;
use super::FlacFile;
use crate::config::{ParseOptions, ParsingMode};
use crate::error::Result;
use crate::flac::block::{BLOCK_ID_PICTURE, BLOCK_ID_STREAMINFO, BLOCK_ID_VORBIS_COMMENTS};
use crate::id3::v2::read::parse_id3v2;
use crate::id3::{find_id3v2, FindId3v2Config, ID3FindResults};
use crate::id3::{FindId3v2Config, ID3FindResults, find_id3v2};
use crate::macros::{decode_err, err};
use crate::ogg::read::read_comments;
use crate::picture::Picture;
Expand Down
2 changes: 1 addition & 1 deletion lofty/src/flac/write.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::block::{Block, BLOCK_ID_PADDING, BLOCK_ID_PICTURE, BLOCK_ID_VORBIS_COMMENTS};
use super::block::{BLOCK_ID_PADDING, BLOCK_ID_PICTURE, BLOCK_ID_VORBIS_COMMENTS, Block};
use super::read::verify_flac;
use crate::config::WriteOptions;
use crate::error::{LoftyError, Result};
Expand Down
6 changes: 1 addition & 5 deletions lofty/src/id3/v1/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,5 @@ fn decode_text(data: &[u8]) -> Option<String> {
.map(|c| *c as char)
.collect::<String>();

if read.is_empty() {
None
} else {
Some(read)
}
if read.is_empty() { None } else { Some(read) }
}
2 changes: 1 addition & 1 deletion lofty/src/id3/v1/write.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::tag::Id3v1TagRef;
use crate::config::WriteOptions;
use crate::error::{LoftyError, Result};
use crate::id3::{find_id3v1, ID3FindResults};
use crate::id3::{ID3FindResults, find_id3v1};
use crate::macros::err;
use crate::probe::Probe;
use crate::util::io::{FileLike, Length, Truncate};
Expand Down
6 changes: 3 additions & 3 deletions lofty/src/id3/v2/frame/conversion.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::TextEncoding;
use crate::error::{Id3v2Error, Id3v2ErrorKind, LoftyError, Result};
use crate::id3::v2::frame::{FrameRef, EMPTY_CONTENT_DESCRIPTOR, MUSICBRAINZ_UFID_OWNER};
use crate::id3::v2::frame::{EMPTY_CONTENT_DESCRIPTOR, FrameRef, MUSICBRAINZ_UFID_OWNER};
use crate::id3::v2::tag::{
new_binary_frame, new_comment_frame, new_text_frame, new_unsync_text_frame, new_url_frame,
new_user_text_frame, new_user_url_frame,
Expand All @@ -10,7 +11,6 @@ use crate::id3::v2::{
};
use crate::macros::err;
use crate::tag::{ItemKey, ItemValue, TagItem, TagType};
use crate::TextEncoding;

use std::borrow::Cow;

Expand Down Expand Up @@ -132,7 +132,7 @@ impl<'a> TryFrom<&'a TagItem> for FrameRef<'a> {
return Err(Id3v2Error::new(Id3v2ErrorKind::UnsupportedFrameId(
item_key.clone(),
))
.into())
.into());
},
}
},
Expand Down
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/frame/header/parse.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::FrameFlags;
use crate::error::{Id3v2Error, Id3v2ErrorKind, Result};
use crate::id3::v2::FrameId;
use crate::id3::v2::util::synchsafe::SynchsafeInteger;
use crate::id3::v2::util::upgrade::{upgrade_v2, upgrade_v3};
use crate::id3::v2::FrameId;
use crate::util::text::utf8_decode_str;

use crate::config::ParseOptions;
Expand Down
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/frame/read.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::header::parse::{parse_header, parse_v2_header};
use super::Frame;
use super::header::parse::{parse_header, parse_v2_header};
use crate::config::{ParseOptions, ParsingMode};
use crate::error::{Id3v2Error, Id3v2ErrorKind, Result};
use crate::id3::v2::frame::content::parse_content;
Expand Down
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl Id3v2Header {
major => {
return Err(
Id3v2Error::new(Id3v2ErrorKind::BadId3v2Version(major, header[4])).into(),
)
);
},
};

Expand Down
4 changes: 2 additions & 2 deletions lofty/src/id3/v2/items/attached_picture_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::id3::v2::header::Id3v2Version;
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::macros::err;
use crate::picture::{MimeType, Picture, PictureType};
use crate::util::text::{encode_text, TextDecodeOptions, TextEncoding};
use crate::util::text::{TextDecodeOptions, TextEncoding, encode_text};

use std::borrow::Cow;
use std::io::{Read, Write as _};
Expand Down Expand Up @@ -82,7 +82,7 @@ impl AttachedPictureFrame<'_> {
return Err(Id3v2Error::new(Id3v2ErrorKind::BadPictureFormat(
String::from_utf8_lossy(&format).into_owned(),
))
.into())
.into());
},
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions lofty/src/id3/v2/items/audio_text_frame.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::error::{ErrorKind, Id3v2Error, Id3v2ErrorKind, LoftyError, Result};
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::util::text::{decode_text, encode_text, TextDecodeOptions, TextEncoding};
use crate::util::text::{TextDecodeOptions, TextEncoding, decode_text, encode_text};

use std::borrow::Cow;
use std::hash::{Hash, Hasher};
Expand Down Expand Up @@ -234,8 +234,8 @@ pub fn scramble(audio_data: &mut [u8]) {

#[cfg(test)]
mod tests {
use crate::id3::v2::{AudioTextFrame, AudioTextFrameFlags, FrameFlags};
use crate::TextEncoding;
use crate::id3::v2::{AudioTextFrame, AudioTextFrameFlags, FrameFlags};

fn expected() -> AudioTextFrame<'static> {
AudioTextFrame {
Expand Down
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/items/encapsulated_object.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::error::{ErrorKind, Id3v2Error, Id3v2ErrorKind, LoftyError, Result};
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::util::text::{decode_text, encode_text, TextDecodeOptions, TextEncoding};
use crate::util::text::{TextDecodeOptions, TextEncoding, decode_text, encode_text};

use std::io::{Cursor, Read};

Expand Down
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/items/extended_text_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::id3::v2::header::Id3v2Version;
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::macros::err;
use crate::util::text::{
decode_text, encode_text, utf16_decode_bytes, TextDecodeOptions, TextEncoding,
TextDecodeOptions, TextEncoding, decode_text, encode_text, utf16_decode_bytes,
};

use std::borrow::Cow;
Expand Down
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/items/extended_url_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::error::Result;
use crate::id3::v2::frame::content::verify_encoding;
use crate::id3::v2::header::Id3v2Version;
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::util::text::{decode_text, encode_text, TextDecodeOptions, TextEncoding};
use crate::util::text::{TextDecodeOptions, TextEncoding, decode_text, encode_text};

use std::borrow::Cow;
use std::hash::{Hash, Hasher};
Expand Down
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/items/key_value_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::error::Result;
use crate::id3::v2::frame::content::verify_encoding;
use crate::id3::v2::header::Id3v2Version;
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::util::text::{decode_text, encode_text, TextDecodeOptions, TextEncoding};
use crate::util::text::{TextDecodeOptions, TextEncoding, decode_text, encode_text};

use byteorder::ReadBytesExt;

Expand Down
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/items/language_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::id3::v2::frame::content::verify_encoding;
use crate::id3::v2::header::Id3v2Version;
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::tag::items::Lang;
use crate::util::text::{decode_text, encode_text, TextDecodeOptions, TextEncoding};
use crate::util::text::{TextDecodeOptions, TextEncoding, decode_text, encode_text};

use std::borrow::Cow;
use std::hash::{Hash, Hasher};
Expand Down
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/items/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mod unique_file_identifier;
mod url_link_frame;

pub use attached_picture_frame::AttachedPictureFrame;
pub use audio_text_frame::{scramble, AudioTextFrame, AudioTextFrameFlags};
pub use audio_text_frame::{AudioTextFrame, AudioTextFrameFlags, scramble};
pub use binary_frame::BinaryFrame;
pub use encapsulated_object::GeneralEncapsulatedObject;
pub use event_timing_codes_frame::{Event, EventTimingCodesFrame, EventType};
Expand Down
4 changes: 2 additions & 2 deletions lofty/src/id3/v2/items/ownership_frame.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::error::{ErrorKind, Id3v2Error, Id3v2ErrorKind, LoftyError, Result};
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::util::text::{
decode_text, encode_text, utf8_decode_str, TextDecodeOptions, TextEncoding,
TextDecodeOptions, TextEncoding, decode_text, encode_text, utf8_decode_str,
};

use std::borrow::Cow;
Expand Down Expand Up @@ -138,8 +138,8 @@ impl OwnershipFrame<'_> {

#[cfg(test)]
mod tests {
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId, OwnershipFrame};
use crate::TextEncoding;
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId, OwnershipFrame};

use std::borrow::Cow;

Expand Down
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/items/popularimeter.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::error::Result;
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::util::alloc::VecFallibleCapacity;
use crate::util::text::{decode_text, encode_text, TextDecodeOptions, TextEncoding};
use crate::util::text::{TextDecodeOptions, TextEncoding, decode_text, encode_text};

use std::borrow::Cow;
use std::hash::{Hash, Hasher};
Expand Down
Loading