Skip to content

Commit 3e6b1ac

Browse files
authored
Rollup merge of #70187 - matthiaskrgr:cl2ppy, r=Mark-Simulacrum
more clippy fixes * remove redundant returns (clippy::needless_return) * remove redundant import (clippy::single_component_path_imports) * remove redundant format!() call (clippy::useless_format) * don't use ok() before calling expect() (clippy::ok_expect)
2 parents 621f2b7 + ad00e91 commit 3e6b1ac

File tree

87 files changed

+142
-172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+142
-172
lines changed

src/libcore/hint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,6 @@ pub fn black_box<T>(dummy: T) -> T {
114114
// more than we want, but it's so far good enough.
115115
unsafe {
116116
asm!("" : : "r"(&dummy));
117-
return dummy;
117+
dummy
118118
}
119119
}

src/librustc/lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl LintLevelSets {
8585
level = cmp::min(*driver_level, level);
8686
}
8787

88-
return (level, src);
88+
(level, src)
8989
}
9090

9191
pub fn get_lint_id_level(

src/librustc/middle/region.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ impl<'tcx> ScopeTree {
467467
}
468468

469469
debug!("temporary_scope({:?}) = None", expr_id);
470-
return None;
470+
None
471471
}
472472

473473
/// Returns the lifetime of the variable `id`.
@@ -498,7 +498,7 @@ impl<'tcx> ScopeTree {
498498

499499
debug!("is_subscope_of({:?}, {:?})=true", subscope, superscope);
500500

501-
return true;
501+
true
502502
}
503503

504504
/// Returns the ID of the innermost containing body.

src/librustc/ty/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,11 +1447,11 @@ impl<'tcx> TyCtxt<'tcx> {
14471447
_ => return None,
14481448
};
14491449

1450-
return Some(FreeRegionInfo {
1450+
Some(FreeRegionInfo {
14511451
def_id: suitable_region_binding_scope,
14521452
boundregion: bound_region,
14531453
is_impl_item,
1454-
});
1454+
})
14551455
}
14561456

14571457
pub fn return_type_impl_trait(&self, scope_def_id: DefId) -> Option<(Ty<'tcx>, Span)> {

src/librustc/ty/relate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ pub fn super_relate_tys<R: TypeRelation<'tcx>>(
440440
(Some(sz_a_val), Some(sz_b_val)) => Err(TypeError::FixedArraySize(
441441
expected_found(relation, &sz_a_val, &sz_b_val),
442442
)),
443-
_ => return Err(err),
443+
_ => Err(err),
444444
}
445445
}
446446
}

src/librustc/ty/sty.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,7 +1612,7 @@ impl<'tcx> PolyExistentialProjection<'tcx> {
16121612
}
16131613

16141614
pub fn item_def_id(&self) -> DefId {
1615-
return self.skip_binder().item_def_id;
1615+
self.skip_binder().item_def_id
16161616
}
16171617
}
16181618

@@ -2000,8 +2000,8 @@ impl<'tcx> TyS<'tcx> {
20002000
#[inline]
20012001
pub fn is_unsafe_ptr(&self) -> bool {
20022002
match self.kind {
2003-
RawPtr(_) => return true,
2004-
_ => return false,
2003+
RawPtr(_) => true,
2004+
_ => false,
20052005
}
20062006
}
20072007

src/librustc/ty/subst.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
524524
self.root_ty = None;
525525
}
526526

527-
return t1;
527+
t1
528528
}
529529

530530
fn fold_const(&mut self, c: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {

src/librustc_builtin_macros/deriving/decodable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ fn decodable_substructure(
8787
let blkarg = cx.ident_of("_d", trait_span);
8888
let blkdecoder = cx.expr_ident(trait_span, blkarg);
8989

90-
return match *substr.fields {
90+
match *substr.fields {
9191
StaticStruct(_, ref summary) => {
9292
let nfields = match *summary {
9393
Unnamed(ref fields, _) => fields.len(),
@@ -178,7 +178,7 @@ fn decodable_substructure(
178178
)
179179
}
180180
_ => cx.bug("expected StaticEnum or StaticStruct in derive(Decodable)"),
181-
};
181+
}
182182
}
183183

184184
/// Creates a decoder for a single enum variant/struct:

src/librustc_builtin_macros/deriving/default.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn default_substructure(
5353
let default_ident = cx.std_path(&[kw::Default, sym::Default, kw::Default]);
5454
let default_call = |span| cx.expr_call_global(span, default_ident.clone(), Vec::new());
5555

56-
return match *substr.fields {
56+
match *substr.fields {
5757
StaticStruct(_, ref summary) => match *summary {
5858
Unnamed(ref fields, is_tuple) => {
5959
if !is_tuple {
@@ -83,5 +83,5 @@ fn default_substructure(
8383
DummyResult::raw_expr(trait_span, true)
8484
}
8585
_ => cx.span_bug(trait_span, "method in `derive(Default)`"),
86-
};
86+
}
8787
}

src/librustc_builtin_macros/deriving/encodable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ fn encodable_substructure(
173173
],
174174
));
175175

176-
return match *substr.fields {
176+
match *substr.fields {
177177
Struct(_, ref fields) => {
178178
let emit_struct_field = cx.ident_of("emit_struct_field", trait_span);
179179
let mut stmts = Vec::new();
@@ -283,5 +283,5 @@ fn encodable_substructure(
283283
}
284284

285285
_ => cx.bug("expected Struct or EnumMatching in derive(Encodable)"),
286-
};
286+
}
287287
}

0 commit comments

Comments
 (0)