Skip to content

Commit ed66fc8

Browse files
authored
Increase MSRV to 1.88 (#840)
This enables the use of let chains.
1 parent 979ce39 commit ed66fc8

File tree

10 files changed

+41
-52
lines changed

10 files changed

+41
-52
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
steps:
4545
- uses: actions/checkout@v4
4646
- name: Install rust
47-
uses: dtolnay/rust-toolchain@1.85.0
47+
uses: dtolnay/rust-toolchain@1.88.0
4848
- name: Build
4949
run: cargo build --verbose -p gimli
5050
- name: Test

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ keywords = ["DWARF", "debug", "ELF", "eh_frame"]
1717
license = "MIT OR Apache-2.0"
1818
readme = "./README.md"
1919
repository = "https://github.com/gimli-rs/gimli"
20-
rust-version = "1.85"
20+
rust-version = "1.88"
2121

2222
[dependencies]
2323
fallible-iterator = { version = "0.3.0", default-features = false, optional = true }

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ To add a `gimli` dependency to your `Cargo.toml`, run:
3131
$ cargo add gimli
3232
```
3333

34-
The minimum supported Rust version is 1.85.
34+
The minimum supported Rust version is 1.88.
3535

3636
## Documentation
3737

clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
msrv = "1.85.0"
1+
msrv = "1.88.0"

src/read/dwarf.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,10 +1295,10 @@ impl<R: Reader> Unit<R> {
12951295
}
12961296
}
12971297
constants::DW_AT_GNU_dwo_id => {
1298-
if unit.dwo_id.is_none() {
1299-
if let AttributeValue::DwoId(dwo_id) = attr.value() {
1300-
unit.dwo_id = Some(dwo_id);
1301-
}
1298+
if unit.dwo_id.is_none()
1299+
&& let AttributeValue::DwoId(dwo_id) = attr.value()
1300+
{
1301+
unit.dwo_id = Some(dwo_id);
13021302
}
13031303
}
13041304
_ => {}
@@ -1323,10 +1323,10 @@ impl<R: Reader> Unit<R> {
13231323
)?),
13241324
None => None,
13251325
};
1326-
if let Some(low_pc_attr) = low_pc_attr {
1327-
if let Some(addr) = dwarf.attr_address(&unit, low_pc_attr)? {
1328-
unit.low_pc = addr;
1329-
}
1326+
if let Some(low_pc_attr) = low_pc_attr
1327+
&& let Some(addr) = dwarf.attr_address(&unit, low_pc_attr)?
1328+
{
1329+
unit.low_pc = addr;
13301330
}
13311331
Ok(unit)
13321332
}

src/read/line.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,10 +1706,10 @@ fn parse_file_v5<R: Reader>(
17061706
}
17071707
}
17081708
constants::DW_LNCT_MD5 => {
1709-
if let AttributeValue::Block(mut value) = value {
1710-
if value.len().into_u64() == 16 {
1711-
md5 = value.read_u8_array()?;
1712-
}
1709+
if let AttributeValue::Block(mut value) = value
1710+
&& value.len().into_u64() == 16
1711+
{
1712+
md5 = value.read_u8_array()?;
17131713
}
17141714
}
17151715
constants::DW_LNCT_LLVM_source => {

src/read/lookup.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,16 @@ where
9494
/// Can be [used with `FallibleIterator`](./index.html#using-with-fallibleiterator).
9595
pub fn next(&mut self) -> Result<Option<Parser::Entry>> {
9696
loop {
97-
if let Some((ref mut input, ref header)) = self.current_set {
98-
if !input.is_empty() {
99-
match Parser::parse_entry(input, header) {
100-
Ok(Some(entry)) => return Ok(Some(entry)),
101-
Ok(None) => {}
102-
Err(e) => {
103-
input.empty();
104-
self.remaining_input.empty();
105-
return Err(e);
106-
}
97+
if let Some((ref mut input, ref header)) = self.current_set
98+
&& !input.is_empty()
99+
{
100+
match Parser::parse_entry(input, header) {
101+
Ok(Some(entry)) => return Ok(Some(entry)),
102+
Ok(None) => {}
103+
Err(e) => {
104+
input.empty();
105+
self.remaining_input.empty();
106+
return Err(e);
107107
}
108108
}
109109
}

src/read/op.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,10 +1955,10 @@ impl<R: Reader, S: EvaluationStorage<R>> Evaluation<R, S> {
19551955
fn evaluate_internal(&mut self) -> Result<EvaluationResult<R>> {
19561956
while !self.end_of_expression() {
19571957
self.iteration += 1;
1958-
if let Some(max_iterations) = self.max_iterations {
1959-
if self.iteration > max_iterations {
1960-
return Err(Error::TooManyIterations);
1961-
}
1958+
if let Some(max_iterations) = self.max_iterations
1959+
&& self.iteration > max_iterations
1960+
{
1961+
return Err(Error::TooManyIterations);
19621962
}
19631963

19641964
let op_result = self.evaluate_one_operation()?;

src/read/unit.rs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,12 +1006,11 @@ where
10061006
/// next sibling. Returns `None` if the attribute is missing or invalid.
10071007
fn sibling(&self) -> Option<R> {
10081008
let attr = self.attr_value(constants::DW_AT_sibling);
1009-
if let Ok(Some(AttributeValue::UnitRef(offset))) = attr {
1010-
if offset.0 > self.offset.0 {
1011-
if let Ok(input) = self.unit.range_from(offset..) {
1012-
return Some(input);
1013-
}
1014-
}
1009+
if let Ok(Some(AttributeValue::UnitRef(offset))) = attr
1010+
&& offset.0 > self.offset.0
1011+
&& let Ok(input) = self.unit.range_from(offset..)
1012+
{
1013+
return Some(input);
10151014
}
10161015
None
10171016
}
@@ -1935,22 +1934,12 @@ where
19351934
{
19361935
/// Try to convert this attribute's value to a u8.
19371936
pub fn u8_value(&self) -> Option<u8> {
1938-
if let Some(value) = self.udata_value() {
1939-
if value <= u64::from(u8::MAX) {
1940-
return Some(value as u8);
1941-
}
1942-
}
1943-
None
1937+
self.udata_value().and_then(|val| u8::try_from(val).ok())
19441938
}
19451939

19461940
/// Try to convert this attribute's value to a u16.
19471941
pub fn u16_value(&self) -> Option<u16> {
1948-
if let Some(value) = self.udata_value() {
1949-
if value <= u64::from(u16::MAX) {
1950-
return Some(value as u16);
1951-
}
1952-
}
1953-
None
1942+
self.udata_value().and_then(|val| u16::try_from(val).ok())
19541943
}
19551944

19561945
/// Try to convert this attribute's value to an unsigned integer.

src/write/unit.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,10 +2577,10 @@ pub(crate) mod convert {
25772577
self.parents.pop();
25782578
}
25792579

2580-
if let Some(id) = id {
2581-
if abbrev.has_children() {
2582-
self.parents.push((depth, id));
2583-
}
2580+
if let Some(id) = id
2581+
&& abbrev.has_children()
2582+
{
2583+
self.parents.push((depth, id));
25842584
}
25852585

25862586
let mut entry = ConvertUnitEntry {

0 commit comments

Comments
 (0)