io: Prevent unstable_name_collisions

This commit is contained in:
Serial 2024-04-14 12:52:18 -04:00 committed by Alex
parent bfae8baf7a
commit c2f711a81f
4 changed files with 5 additions and 8 deletions

View file

@ -44,8 +44,7 @@ where
size = size.saturating_add(32);
}
#[allow(unstable_name_collisions)]
if u64::from(size) > data.stream_len()? {
if u64::from(size) > data.stream_len_hack()? {
decode_err!(@BAIL Ape, "APE tag has an invalid size (> file size)");
}

View file

@ -28,8 +28,7 @@ where
R: Read + Seek,
{
pub(super) fn new(mut reader: R, parse_mode: ParsingMode) -> Result<Self> {
#[allow(unstable_name_collisions)]
let len = reader.stream_len()?;
let len = reader.stream_len_hack()?;
Ok(Self {
reader,
start: 0,
@ -185,7 +184,7 @@ where
R: Read + Seek,
{
let mut reader = AtomReader::new(data, parse_options.parsing_mode)?;
let file_length = reader.stream_len()?;
let file_length = reader.stream_len_hack()?;
let ftyp = verify_mp4(&mut reader)?;

View file

@ -20,8 +20,7 @@ where
let mut version = MpcStreamVersion::Sv4to6;
let mut file = MpcFile::default();
#[allow(unstable_name_collisions)]
let mut stream_length = reader.stream_len()?;
let mut stream_length = reader.stream_len_hack()?;
// ID3v2 tags are unsupported in MPC files, but still possible
#[allow(unused_variables)]

View file

@ -1,6 +1,6 @@
// TODO: https://github.com/rust-lang/rust/issues/59359
pub(crate) trait SeekStreamLen: std::io::Seek {
fn stream_len(&mut self) -> crate::error::Result<u64> {
fn stream_len_hack(&mut self) -> crate::error::Result<u64> {
use std::io::SeekFrom;
let current_pos = self.stream_position()?;