Skip to content

Commit 81c320e

Browse files
committed
Fix some clippy::complexity
1 parent 6fceb0f commit 81c320e

File tree

28 files changed

+62
-63
lines changed

28 files changed

+62
-63
lines changed

compiler/rustc_abi/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ impl FieldsShape {
11761176

11771177
/// Gets source indices of the fields by increasing offsets.
11781178
#[inline]
1179-
pub fn index_by_increasing_offset<'a>(&'a self) -> impl Iterator<Item = usize> + 'a {
1179+
pub fn index_by_increasing_offset(&self) -> impl Iterator<Item = usize> + '_ {
11801180
let mut inverse_small = [0u8; 64];
11811181
let mut inverse_big = IndexVec::new();
11821182
let use_small = self.count() <= inverse_small.len();

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ fn validate_generic_param_order(
691691
GenericParamKind::Lifetime => (),
692692
GenericParamKind::Const { ty: _, kw_span: _, default: Some(default) } => {
693693
ordered_params += " = ";
694-
ordered_params += &pprust::expr_to_string(&*default.value);
694+
ordered_params += &pprust::expr_to_string(&default.value);
695695
}
696696
GenericParamKind::Const { ty: _, kw_span: _, default: None } => (),
697697
}

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,11 +404,14 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
404404
);
405405
} else {
406406
// And if it isn't, cancel the early-pass warning.
407-
self.sess
407+
if let Some(err) = self
408+
.sess
408409
.parse_sess
409410
.span_diagnostic
410411
.steal_diagnostic(e.span, StashKey::EarlySyntaxWarning)
411-
.map(|err| err.cancel());
412+
{
413+
err.cancel()
414+
}
412415
}
413416
}
414417
ast::ExprKind::TryBlock(_) => {

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,9 @@ impl<'a> State<'a> {
988988

989989
pub fn print_assoc_constraint(&mut self, constraint: &ast::AssocConstraint) {
990990
self.print_ident(constraint.ident);
991-
constraint.gen_args.as_ref().map(|args| self.print_generic_args(args, false));
991+
if let Some(args) = constraint.gen_args.as_ref() {
992+
self.print_generic_args(args, false)
993+
}
992994
self.space();
993995
match &constraint.kind {
994996
ast::AssocConstraintKind::Equality { term } => {

compiler/rustc_data_structures/src/graph/implementation/mod.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,17 +206,11 @@ impl<N: Debug, E: Debug> Graph<N, E> {
206206
AdjacentEdges { graph: self, direction, next: first_edge }
207207
}
208208

209-
pub fn successor_nodes<'a>(
210-
&'a self,
211-
source: NodeIndex,
212-
) -> impl Iterator<Item = NodeIndex> + 'a {
209+
pub fn successor_nodes(&self, source: NodeIndex) -> impl Iterator<Item = NodeIndex> + '_ {
213210
self.outgoing_edges(source).targets()
214211
}
215212

216-
pub fn predecessor_nodes<'a>(
217-
&'a self,
218-
target: NodeIndex,
219-
) -> impl Iterator<Item = NodeIndex> + 'a {
213+
pub fn predecessor_nodes(&self, target: NodeIndex) -> impl Iterator<Item = NodeIndex> + '_ {
220214
self.incoming_edges(target).sources()
221215
}
222216

compiler/rustc_data_structures/src/memmap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl Deref for Mmap {
4040

4141
impl AsRef<[u8]> for Mmap {
4242
fn as_ref(&self) -> &[u8] {
43-
&*self.0
43+
&self.0
4444
}
4545
}
4646

compiler/rustc_data_structures/src/stable_hasher.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,14 +312,14 @@ impl<CTX> HashStable<CTX> for ::std::num::NonZeroUsize {
312312

313313
impl<CTX> HashStable<CTX> for f32 {
314314
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
315-
let val: u32 = unsafe { ::std::mem::transmute(*self) };
315+
let val: u32 = self.to_bits();
316316
val.hash_stable(ctx, hasher);
317317
}
318318
}
319319

320320
impl<CTX> HashStable<CTX> for f64 {
321321
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
322-
let val: u64 = unsafe { ::std::mem::transmute(*self) };
322+
let val: u64 = self.to_bits();
323323
val.hash_stable(ctx, hasher);
324324
}
325325
}

compiler/rustc_data_structures/src/stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const RED_ZONE: usize = 100 * 1024; // 100k
55

66
// Only the first stack that is pushed, grows exponentially (2^n * STACK_PER_RECURSION) from then
77
// on. This flag has performance relevant characteristics. Don't set it too high.
8-
const STACK_PER_RECURSION: usize = 1 * 1024 * 1024; // 1MB
8+
const STACK_PER_RECURSION: usize = 1024 * 1024; // 1MB
99

1010
/// Grows the stack on demand to prevent stack overflow. Call this in strategic locations
1111
/// to "break up" recursive calls. E.g. almost any call to `visit_expr` or equivalent can benefit

compiler/rustc_data_structures/src/sync/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl<T: Copy> AppendOnlyVec<T> {
8484
}
8585

8686
pub fn iter(&self) -> impl Iterator<Item = T> + '_ {
87-
(0..).map(|i| self.get(i)).take_while(|o| o.is_some()).filter_map(|o| o)
87+
(0..).map(|i| self.get(i)).take_while(|o| o.is_some()).flatten()
8888
}
8989
}
9090

compiler/rustc_data_structures/src/unord.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ impl<V: Eq + Hash> UnordSet<V> {
224224
}
225225

226226
#[inline]
227-
pub fn items<'a>(&'a self) -> UnordItems<&'a V, impl Iterator<Item = &'a V>> {
227+
pub fn items(&self) -> UnordItems<&V, impl Iterator<Item = &V>> {
228228
UnordItems(self.inner.iter())
229229
}
230230

@@ -415,7 +415,7 @@ impl<K: Eq + Hash, V> UnordMap<K, V> {
415415
}
416416

417417
#[inline]
418-
pub fn items<'a>(&'a self) -> UnordItems<(&'a K, &'a V), impl Iterator<Item = (&'a K, &'a V)>> {
418+
pub fn items(&self) -> UnordItems<(&K, &V), impl Iterator<Item = (&K, &V)>> {
419419
UnordItems(self.inner.iter())
420420
}
421421

0 commit comments

Comments
 (0)