Skip to content

Commit f355495

Browse files
authored
Fix some nightly warnings (#54)
This commit can be replicated by running `cargo fix` with rustc +nightly-2025-09-07. An example warning that this fixes: ``` warning: hiding a lifetime that's elided elsewhere is confusing --> src/instrumentation_profile/text_profile.rs:120:39 | 120 | fn read_value_profile_data(mut input: &[u8]) -> ParseResult<Option<Box<ValueProfDataRecord>>> { | ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the same lifetime is hidden here | | | the lifetime is elided here | = help: the same lifetime is referred to in inconsistent ways, making the signature confusing help: use `'_` for type paths | 120 | fn read_value_profile_data(mut input: &[u8]) -> ParseResult<'_, Option<Box<ValueProfDataRecord>>> { | +++ ```
1 parent 8e63407 commit f355495

5 files changed

Lines changed: 23 additions & 23 deletions

File tree

src/hash_table.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ struct KeyDataLen {
1616
#[derive(Clone, Debug)]
1717
pub(crate) struct HashTable(pub IndexMap<(u64, String), InstrProfRecord>);
1818

19-
fn read_key_data_len(input: &[u8]) -> ParseResult<KeyDataLen> {
19+
fn read_key_data_len(input: &[u8]) -> ParseResult<'_, KeyDataLen> {
2020
let (bytes, key_len) = le_u64(input)?;
2121
let (bytes, data_len) = le_u64(bytes)?;
2222
let res = KeyDataLen { key_len, data_len };
2323
Ok((bytes, res))
2424
}
2525

26-
fn read_key(input: &[u8], key_len: usize) -> ParseResult<Cow<'_, str>> {
26+
fn read_key(input: &[u8], key_len: usize) -> ParseResult<'_, Cow<'_, str>> {
2727
if key_len > input.len() {
2828
Err(nom::Err::Failure(VerboseError::from_error_kind(
2929
&input[input.len()..],
@@ -39,7 +39,7 @@ fn read_value(
3939
version: u64,
4040
mut input: &[u8],
4141
data_len: usize,
42-
) -> ParseResult<(u64, InstrProfRecord)> {
42+
) -> ParseResult<'_, (u64, InstrProfRecord)> {
4343
if data_len % 8 != 0 {
4444
// Element is corrupted, it should be aligned
4545
let errors = vec![(

src/instrumentation_profile/indexed_profile.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ fn parse_summary<'a>(
164164
impl InstrProfReader for IndexedInstrProf {
165165
type Header = Header;
166166

167-
fn parse_bytes(mut input: &[u8]) -> ParseResult<InstrumentationProfile> {
167+
fn parse_bytes(mut input: &[u8]) -> ParseResult<'_, InstrumentationProfile> {
168168
let (bytes, header) = Self::parse_header(input)?;
169169
debug!("Parsed header: {:?}", header);
170170
let (bytes, summary) = parse_summary(bytes, &header, false)?;
@@ -210,7 +210,7 @@ impl InstrProfReader for IndexedInstrProf {
210210
Ok((input, profile))
211211
}
212212

213-
fn parse_header(input: &[u8]) -> ParseResult<Self::Header> {
213+
fn parse_header(input: &[u8]) -> ParseResult<'_, Self::Header> {
214214
if Self::has_format(input) {
215215
let (bytes, version) = le_u64(&input[8..])?;
216216
let (bytes, _) = le_u64(bytes)?;

src/instrumentation_profile/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ pub fn parse_bytes(data: &[u8]) -> io::Result<InstrumentationProfile> {
5252
pub trait InstrProfReader {
5353
type Header;
5454
/// Parse the profile no lazy parsing here!
55-
fn parse_bytes(input: &[u8]) -> ParseResult<InstrumentationProfile>;
55+
fn parse_bytes(input: &[u8]) -> ParseResult<'_, InstrumentationProfile>;
5656
/// Parses a header
57-
fn parse_header(input: &[u8]) -> ParseResult<Self::Header>;
57+
fn parse_header(input: &[u8]) -> ParseResult<'_, Self::Header>;
5858
/// Detects that the bytes match the current reader format if it can't read the format it will
5959
/// return false
6060
fn has_format(input: impl Read) -> bool;

src/instrumentation_profile/raw_profile.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ where
292292
{
293293
type Header = Header;
294294

295-
fn parse_bytes(mut input: &[u8]) -> ParseResult<InstrumentationProfile> {
295+
fn parse_bytes(mut input: &[u8]) -> ParseResult<'_, InstrumentationProfile> {
296296
if !input.is_empty() {
297297
let mut result = InstrumentationProfile::default();
298298
let (bytes, header) = Self::parse_header(input)?;
@@ -417,7 +417,7 @@ where
417417
}
418418
}
419419

420-
fn parse_header(input: &[u8]) -> ParseResult<Self::Header> {
420+
fn parse_header(input: &[u8]) -> ParseResult<'_, Self::Header> {
421421
if Self::has_format(input) {
422422
let endianness = file_endianness::<T>(&input[..8].try_into().unwrap());
423423
let (bytes, version) = nom_u64(endianness)(&input[8..])?;

src/instrumentation_profile/text_profile.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn str_to_digit(bytes: &[u8]) -> u64 {
4747
.unwrap_or_default()
4848
}
4949

50-
fn read_hexadecimal(input: &[u8]) -> ParseResult<u64> {
50+
fn read_hexadecimal(input: &[u8]) -> ParseResult<'_, u64> {
5151
preceded(alt((tag(b"0x"), tag(b"0X"))), take_while1(is_hex_digit))(input).map(|(b, v)| unsafe {
5252
// We know this is okay because it's just the bytes that pass `is_hex_digit`
5353
(
@@ -63,11 +63,11 @@ fn valid_name_char(character: u8) -> bool {
6363
c.is_ascii() && c != '\n' && c != '\r'
6464
}
6565

66-
fn strip_whitespace(s: &[u8]) -> ParseResult<()> {
66+
fn strip_whitespace(s: &[u8]) -> ParseResult<'_, ()> {
6767
one_of(&b" \n\r\t"[..])(s).map(|(b, _)| (b, ()))
6868
}
6969

70-
fn strip_comments(s: &[u8]) -> ParseResult<()> {
70+
fn strip_comments(s: &[u8]) -> ParseResult<'_, ()> {
7171
delimited(
7272
tag(b"#"),
7373
alt((take_until("\r"), take_until("\n"))),
@@ -76,11 +76,11 @@ fn strip_comments(s: &[u8]) -> ParseResult<()> {
7676
.map(|(b, _)| (b, ()))
7777
}
7878

79-
fn skip_to_content(s: &[u8]) -> ParseResult<()> {
79+
fn skip_to_content(s: &[u8]) -> ParseResult<'_, ()> {
8080
many0(alt((strip_whitespace, strip_comments)))(s).map(|(b, _)| (b, ()))
8181
}
8282

83-
fn match_header_tags(s: &[u8]) -> ParseResult<&[u8]> {
83+
fn match_header_tags(s: &[u8]) -> ParseResult<'_, &[u8]> {
8484
alt((
8585
tag_no_case(IR_TAG),
8686
tag_no_case(FE_TAG),
@@ -91,33 +91,33 @@ fn match_header_tags(s: &[u8]) -> ParseResult<&[u8]> {
9191
))(s)
9292
}
9393

94-
fn parse_header_tags(s: &[u8]) -> ParseResult<Vec<&[u8]>> {
94+
fn parse_header_tags(s: &[u8]) -> ParseResult<'_, Vec<&[u8]>> {
9595
many0(delimited(tag(b":"), match_header_tags, line_ending))(s)
9696
}
9797

98-
fn read_line(s: &[u8]) -> ParseResult<&[u8]> {
98+
fn read_line(s: &[u8]) -> ParseResult<'_, &[u8]> {
9999
tuple((take_while1(valid_name_char), line_ending))(s).map(|(b, (v, _))| (b, v))
100100
}
101101

102-
fn read_decimal(s: &[u8]) -> ParseResult<u64> {
102+
fn read_decimal(s: &[u8]) -> ParseResult<'_, u64> {
103103
tuple((take_while1(is_digit), alt((line_ending, eof))))(s).map(|(b, v)| (b, str_to_digit(v.0)))
104104
}
105105

106-
fn read_digit(s: &[u8]) -> ParseResult<u64> {
106+
fn read_digit(s: &[u8]) -> ParseResult<'_, u64> {
107107
alt((read_decimal, read_hexadecimal))(s)
108108
}
109109

110-
fn indirect_value_site(s: &[u8]) -> ParseResult<(&[u8], u64)> {
110+
fn indirect_value_site(s: &[u8]) -> ParseResult<'_, (&[u8], u64)> {
111111
tuple((take_until(":"), tag(":"), take_while1(is_digit)))(s)
112112
.map(|(b, v)| (b, (v.0, str_to_digit(v.2))))
113113
}
114114

115-
fn memop_value_site(s: &[u8]) -> ParseResult<(u64, u64)> {
115+
fn memop_value_site(s: &[u8]) -> ParseResult<'_, (u64, u64)> {
116116
tuple((take_while1(is_digit), tag(":"), take_while1(is_digit)))(s)
117117
.map(|(b, v)| (b, (str_to_digit(v.0), str_to_digit(v.2))))
118118
}
119119

120-
fn read_value_profile_data(mut input: &[u8]) -> ParseResult<Option<Box<ValueProfDataRecord>>> {
120+
fn read_value_profile_data(mut input: &[u8]) -> ParseResult<'_, Option<Box<ValueProfDataRecord>>> {
121121
if let Ok((bytes, n_kinds)) = read_digit(input) {
122122
let mut record = Box::<ValueProfDataRecord>::default();
123123
// We have value profiling data!
@@ -190,7 +190,7 @@ fn read_value_profile_data(mut input: &[u8]) -> ParseResult<Option<Box<ValueProf
190190

191191
impl InstrProfReader for TextInstrProf {
192192
type Header = Header;
193-
fn parse_bytes(mut input: &[u8]) -> ParseResult<InstrumentationProfile> {
193+
fn parse_bytes(mut input: &[u8]) -> ParseResult<'_, InstrumentationProfile> {
194194
let (bytes, header) = Self::parse_header(input)?;
195195
let (bytes, _) = skip_to_content(bytes)?;
196196
input = bytes;
@@ -252,7 +252,7 @@ impl InstrProfReader for TextInstrProf {
252252
Ok((bytes, result))
253253
}
254254

255-
fn parse_header(input: &[u8]) -> ParseResult<Self::Header> {
255+
fn parse_header(input: &[u8]) -> ParseResult<'_, Self::Header> {
256256
let (input, _) = skip_to_content(input)?;
257257
let (bytes, names) = parse_header_tags(input)?;
258258
let mut is_ir_level = false;

0 commit comments

Comments
 (0)