Skip to content

Commit 9df66ce

Browse files
authored
Fix clippy warnings for Rust 1.84.0 (#6877)
## Description Fix clippy warnings for Rust 1.84.0
1 parent 8c5afa3 commit 9df66ce

File tree

24 files changed

+48
-67
lines changed

24 files changed

+48
-67
lines changed

forc-plugins/forc-debug/src/server/handlers/handle_set_breakpoints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl DapServer {
6161
});
6262
if let Some(existing_bp) = existing_breakpoints
6363
.iter()
64-
.find(|bp| bp.line.map_or(false, |line| line == source_bp.line))
64+
.find(|bp| (bp.line == Some(source_bp.line)))
6565
{
6666
Breakpoint {
6767
verified,

forc-plugins/forc-migrate/src/migrations/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub(crate) struct MutProgramInfo<'a> {
4343
pub engines: &'a Engines,
4444
}
4545

46-
impl<'a> ProgramInfo<'a> {
46+
impl ProgramInfo<'_> {
4747
pub(crate) fn as_mut(&mut self) -> MutProgramInfo {
4848
MutProgramInfo {
4949
lexed_program: &mut self.lexed_program,

forc-plugins/forc-migrate/src/modifying/storage_field.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl ToInKey for Expr {
3434
}
3535
}
3636

37-
impl<'a> Modifier<'a, StorageField> {
37+
impl Modifier<'_, StorageField> {
3838
pub(crate) fn with_in_key<K: ToInKey>(&mut self, key: K) -> &mut Self {
3939
// If the `in` token already exists, just replace the key and leave the `in`
4040
// token as is. Place the key after the `in` token.

sway-core/src/asm_generation/fuel/fuel_asm_builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,7 +1868,7 @@ impl<'ir, 'eng> FuelAsmBuilder<'ir, 'eng> {
18681868
if !val
18691869
.get_type(self.context)
18701870
.and_then(|val_ty| key.get_type(self.context).map(|key_ty| (val_ty, key_ty)))
1871-
.map_or(false, |(val_ty, key_ty)| {
1871+
.is_some_and(|(val_ty, key_ty)| {
18721872
val_ty.is_ptr(self.context) && key_ty.is_ptr(self.context)
18731873
})
18741874
{
@@ -1958,7 +1958,7 @@ impl<'ir, 'eng> FuelAsmBuilder<'ir, 'eng> {
19581958
if !store_val
19591959
.get_type(self.context)
19601960
.and_then(|val_ty| key.get_type(self.context).map(|key_ty| (val_ty, key_ty)))
1961-
.map_or(false, |(val_ty, key_ty)| {
1961+
.is_some_and(|(val_ty, key_ty)| {
19621962
val_ty.is_uint64(self.context) && key_ty.is_ptr(self.context)
19631963
})
19641964
{

sway-core/src/asm_generation/fuel/functions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ impl FuelAsmBuilder<'_, '_> {
474474
// XXX val.get_type() should be a pointer if it's not meant to be loaded.
475475
if val
476476
.get_type(self.context)
477-
.map_or(false, |t| self.is_copy_type(&t))
477+
.is_some_and(|t| self.is_copy_type(&t))
478478
{
479479
self.cur_bytecode.push(Op {
480480
opcode: either::Either::Left(VirtualOp::LW(

sway-core/src/control_flow_analysis/dead_code_analysis.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl<'cfg> ControlFlowGraph<'cfg> {
174174
connections_count
175175
.get(n)
176176
.cloned()
177-
.map_or(false, |count| count > 1)
177+
.is_some_and(|count| count > 1)
178178
}
179179
}
180180
ControlFlowGraphNode::FunctionParameter {
@@ -216,7 +216,7 @@ impl<'cfg> ControlFlowGraph<'cfg> {
216216
connections_count
217217
.get(n)
218218
.cloned()
219-
.map_or(false, |count| count > 0)
219+
.is_some_and(|count| count > 0)
220220
}
221221
_ => false,
222222
}

sway-core/src/ir_generation/function.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ impl<'eng> FnCompiler<'eng> {
329329
if val
330330
.value
331331
.get_type(context)
332-
.map_or(false, |ty| ty.is_ptr(context))
332+
.is_some_and(|ty| ty.is_ptr(context))
333333
{
334334
let load_val = self.current_block.append(context).load(val.value);
335335
TerminatorValue::new(load_val, context)
@@ -2540,7 +2540,7 @@ impl<'eng> FnCompiler<'eng> {
25402540

25412541
let ptr_as_int = if ref_value
25422542
.get_type(context)
2543-
.map_or(false, |ref_value_type| ref_value_type.is_ptr(context))
2543+
.is_some_and(|ref_value_type| ref_value_type.is_ptr(context))
25442544
{
25452545
// We are dereferencing a reference variable and we got a pointer to it.
25462546
// To get the address the reference is pointing to we need to load the value.
@@ -4262,7 +4262,7 @@ impl<'eng> FnCompiler<'eng> {
42624262
let init_type = self.engines.te().get_unaliased(init_expr.return_type);
42634263
if initializer_val
42644264
.get_type(context)
4265-
.map_or(false, |ty| ty.is_ptr(context))
4265+
.is_some_and(|ty| ty.is_ptr(context))
42664266
&& (init_type.is_copy_type() || init_type.is_reference())
42674267
{
42684268
// It's a pointer to a copy type, or a reference behind a pointer. We need to dereference it.

sway-core/src/lib.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -441,14 +441,14 @@ pub(crate) fn is_ty_module_cache_up_to_date(
441441
) -> bool {
442442
let cache = engines.qe().module_cache.read();
443443
let key = ModuleCacheKey::new(path.clone(), include_tests);
444-
cache.get(&key).map_or(false, |entry| {
445-
entry.typed.as_ref().map_or(false, |typed| {
444+
cache.get(&key).is_some_and(|entry| {
445+
entry.typed.as_ref().is_some_and(|typed| {
446446
// Check if the cache is up to date based on file versions
447447
let cache_up_to_date = build_config
448448
.and_then(|x| x.lsp_mode.as_ref())
449449
.and_then(|lsp| lsp.file_versions.get(path.as_ref()))
450450
.map_or(true, |version| {
451-
version.map_or(true, |v| typed.version.map_or(false, |tv| v <= tv))
451+
version.map_or(true, |v| typed.version.is_some_and(|tv| v <= tv))
452452
});
453453

454454
// If the cache is up to date, recursively check all dependencies
@@ -472,7 +472,7 @@ pub(crate) fn is_parse_module_cache_up_to_date(
472472
) -> bool {
473473
let cache = engines.qe().module_cache.read();
474474
let key = ModuleCacheKey::new(path.clone(), include_tests);
475-
cache.get(&key).map_or(false, |entry| {
475+
cache.get(&key).is_some_and(|entry| {
476476
// Determine if the cached dependency information is still valid
477477
let cache_up_to_date = build_config
478478
.and_then(|x| x.lsp_mode.as_ref())
@@ -498,7 +498,7 @@ pub(crate) fn is_parse_module_cache_up_to_date(
498498
// - If there's no cached version (entry.parsed.version is None), the cache is outdated.
499499
// - If there's a cached version, compare them: cache is up-to-date if the LSP file version
500500
// is not greater than the cached version.
501-
version.map_or(true, |v| entry.parsed.version.map_or(false, |ev| v <= ev))
501+
version.map_or(true, |v| entry.parsed.version.is_some_and(|ev| v <= ev))
502502
},
503503
);
504504

@@ -601,10 +601,7 @@ pub fn parsed_to_ast(
601601
experimental,
602602
);
603603

604-
let mut typed_program = match typed_program_opt {
605-
Ok(typed_program) => typed_program,
606-
Err(e) => return Err(e),
607-
};
604+
let mut typed_program = typed_program_opt?;
608605

609606
check_should_abort(handler, retrigger_compilation.clone()).map_err(|error| {
610607
TypeCheckFailed {

sway-core/src/query_engine/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl QueryEngine {
211211
pub fn clear_module(&mut self, source_id: &SourceId) {
212212
self.function_cache
213213
.write()
214-
.retain(|(ident, _), _| ident.span().source_id().map_or(true, |id| id != source_id));
214+
.retain(|(ident, _), _| (ident.span().source_id() != Some(source_id)));
215215
}
216216

217217
/// Removes all data associated with the `program_id` from the function cache.

sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/range.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,7 @@ where
493493
}
494494

495495
fn encompasses_all(&self, others: &[Range<T>]) -> bool {
496-
others
497-
.iter()
498-
.map(|other| self.encompasses(other))
499-
.all(|x| x)
496+
others.iter().all(|other| self.encompasses(other))
500497
}
501498

502499
/// Checks to see if two ranges are within ± 1 of one another. There are 2

0 commit comments

Comments
 (0)