Skip to content

Commit b7db23b

Browse files
coolreader18youknowone
authored andcommitted
Fix warnings for Rust 1.84
1 parent 389b20d commit b7db23b

File tree

24 files changed

+52
-65
lines changed

24 files changed

+52
-65
lines changed

Cargo.lock

Lines changed: 10 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/src/int.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ pub fn bytes_to_int(lit: &[u8], mut base: u32) -> Option<BigInt> {
6060
return Some(BigInt::zero());
6161
}
6262
}
63-
16 => lit.get(1).map_or(false, |&b| matches!(b, b'x' | b'X')),
64-
2 => lit.get(1).map_or(false, |&b| matches!(b, b'b' | b'B')),
65-
8 => lit.get(1).map_or(false, |&b| matches!(b, b'o' | b'O')),
63+
16 => lit.get(1).is_some_and(|&b| matches!(b, b'x' | b'X')),
64+
2 => lit.get(1).is_some_and(|&b| matches!(b, b'b' | b'B')),
65+
8 => lit.get(1).is_some_and(|&b| matches!(b, b'o' | b'O')),
6666
_ => false,
6767
}
6868
} else {

compiler/codegen/src/compile.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3102,19 +3102,18 @@ impl Compiler {
31023102
Expr::Tuple(ExprTuple { elts, .. }) => elts.iter().any(Self::contains_await),
31033103
Expr::Set(ExprSet { elts, .. }) => elts.iter().any(Self::contains_await),
31043104
Expr::Dict(ExprDict { keys, values, .. }) => {
3105-
keys.iter()
3106-
.any(|key| key.as_ref().map_or(false, Self::contains_await))
3105+
keys.iter().flatten().any(Self::contains_await)
31073106
|| values.iter().any(Self::contains_await)
31083107
}
31093108
Expr::Slice(ExprSlice {
31103109
lower, upper, step, ..
31113110
}) => {
3112-
lower.as_ref().map_or(false, |l| Self::contains_await(l))
3113-
|| upper.as_ref().map_or(false, |u| Self::contains_await(u))
3114-
|| step.as_ref().map_or(false, |s| Self::contains_await(s))
3111+
lower.as_deref().is_some_and(Self::contains_await)
3112+
|| upper.as_deref().is_some_and(Self::contains_await)
3113+
|| step.as_deref().is_some_and(Self::contains_await)
31153114
}
31163115
Expr::Yield(ExprYield { value, .. }) => {
3117-
value.as_ref().map_or(false, |v| Self::contains_await(v))
3116+
value.as_deref().is_some_and(Self::contains_await)
31183117
}
31193118
Expr::Await(ExprAwait { .. }) => true,
31203119
Expr::YieldFrom(ExprYieldFrom { value, .. }) => Self::contains_await(value),
@@ -3128,9 +3127,7 @@ impl Compiler {
31283127
..
31293128
}) => {
31303129
Self::contains_await(value)
3131-
|| format_spec
3132-
.as_ref()
3133-
.map_or(false, |fs| Self::contains_await(fs))
3130+
|| format_spec.as_deref().is_some_and(Self::contains_await)
31343131
}
31353132
Expr::Name(located_ast::ExprName { .. }) => false,
31363133
Expr::Lambda(located_ast::ExprLambda { body, .. }) => Self::contains_await(body),

derive-impl/src/pyclass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ fn generate_class_def(
348348
&& if let Ok(Meta::List(l)) = attr.parse_meta() {
349349
l.nested
350350
.into_iter()
351-
.any(|n| n.get_ident().map_or(false, |p| p == "PyStructSequence"))
351+
.any(|n| n.get_ident().is_some_and(|p| p == "PyStructSequence"))
352352
} else {
353353
false
354354
}

derive-impl/src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ impl AttributeExt for Attribute {
558558
let has_name = list
559559
.nested
560560
.iter()
561-
.any(|nested_meta| nested_meta.get_path().map_or(false, |p| p.is_ident(name)));
561+
.any(|nested_meta| nested_meta.get_path().is_some_and(|p| p.is_ident(name)));
562562
if !has_name {
563563
list.nested.push(new_item())
564564
}

src/shell/helper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn split_idents_on_dot(line: &str) -> Option<(usize, Vec<String>)> {
2222
match c {
2323
'.' => {
2424
// check for a double dot
25-
if i != 0 && words.last().map_or(false, |s| s.is_empty()) {
25+
if i != 0 && words.last().is_some_and(|s| s.is_empty()) {
2626
return None;
2727
}
2828
reverse_string(words.last_mut().unwrap());

stdlib/src/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ mod array {
12381238

12391239
let res = match array_a.cmp(&array_b) {
12401240
// fast path for same ArrayContentType type
1241-
Ok(partial_ord) => partial_ord.map_or(false, |ord| op.eval_ord(ord)),
1241+
Ok(partial_ord) => partial_ord.is_some_and(|ord| op.eval_ord(ord)),
12421242
Err(()) => {
12431243
let iter = Iterator::zip(array_a.iter(vm), array_b.iter(vm));
12441244

stdlib/src/contextvars.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,16 @@ mod _contextvars {
129129

130130
super::CONTEXTS.with(|ctxs| {
131131
let mut ctxs = ctxs.borrow_mut();
132-
if !ctxs
133-
.last()
134-
.map_or(false, |ctx| ctx.get_id() == zelf.get_id())
135-
{
132+
// TODO: use Vec::pop_if once stabilized
133+
if ctxs.last().is_some_and(|ctx| ctx.get_id() == zelf.get_id()) {
134+
let _ = ctxs.pop();
135+
Ok(())
136+
} else {
136137
let msg =
137138
"cannot exit context: thread state references a different context object"
138139
.to_owned();
139-
return Err(vm.new_runtime_error(msg));
140+
Err(vm.new_runtime_error(msg))
140141
}
141-
142-
let _ = ctxs.pop();
143-
Ok(())
144142
})?;
145143
zelf.inner.entered.set(false);
146144

stdlib/src/unicodedata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ mod unicodedata {
8585
}
8686

8787
fn check_age(&self, c: char) -> bool {
88-
Age::of(c).map_or(false, |age| age.actual() <= self.unic_version)
88+
Age::of(c).is_some_and(|age| age.actual() <= self.unic_version)
8989
}
9090

9191
fn extract_char(&self, character: PyStrRef, vm: &VirtualMachine) -> PyResult<Option<char>> {

vm/src/anystr.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -385,17 +385,14 @@ pub trait AnyStr {
385385
let (end_len, i_diff) = match *ch {
386386
b'\n' => (keep, 1),
387387
b'\r' => {
388-
let is_rn = enumerated.peek().map_or(false, |(_, ch)| **ch == b'\n');
388+
let is_rn = enumerated.next_if(|(_, ch)| **ch == b'\n').is_some();
389389
if is_rn {
390-
let _ = enumerated.next();
391390
(keep + keep, 2)
392391
} else {
393392
(keep, 1)
394393
}
395394
}
396-
_ => {
397-
continue;
398-
}
395+
_ => continue,
399396
};
400397
let range = last_i..i + end_len;
401398
last_i = i + i_diff;

0 commit comments

Comments
 (0)