Skip to content

Commit 600a490

Browse files
committed
fix: auto-fixes for lint concealed_obvious_default
1 parent 9e7782b commit 600a490

File tree

9 files changed

+15
-15
lines changed

9 files changed

+15
-15
lines changed

clippy_config/src/conf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ impl serde::de::Error for FieldError {
10971097
writeln!(msg).unwrap();
10981098
for (column, column_width) in column_widths.iter().copied().enumerate() {
10991099
let index = column * rows + row;
1100-
let field = expected.get(index).copied().unwrap_or_default();
1100+
let field = expected.get(index).copied().unwrap_or("");
11011101
write!(msg, "{:SEPARATOR_WIDTH$}{field:column_width$}", " ").unwrap();
11021102
}
11031103
}
@@ -1128,7 +1128,7 @@ fn calculate_dimensions(fields: &[&str]) -> (usize, Vec<usize>) {
11281128
(0..rows)
11291129
.map(|row| {
11301130
let index = column * rows + row;
1131-
let field = fields.get(index).copied().unwrap_or_default();
1131+
let field = fields.get(index).copied().unwrap_or("");
11321132
field.len()
11331133
})
11341134
.max()

clippy_lints/src/arbitrary_source_item_ordering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
414414
let module_level_order = self
415415
.module_item_order_groupings
416416
.module_level_order_of(&item_kind)
417-
.unwrap_or_default();
417+
.unwrap_or(0);
418418

419419
if let Some(cur_t) = cur_t.as_ref() {
420420
use std::cmp::Ordering; // Better legibility.

clippy_lints/src/casts/cast_possible_truncation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fn apply_reductions(cx: &LateContext<'_>, nbits: u64, expr: &Expr<'_>, signed: b
4949
.min(apply_reductions(cx, nbits, right, signed))
5050
.min(apply_reductions(cx, nbits, left, signed)),
5151
BinOpKind::Shr => apply_reductions(cx, nbits, left, signed)
52-
.saturating_sub(constant_int(cx, right).map_or(0, |s| u64::try_from(s).unwrap_or_default())),
52+
.saturating_sub(constant_int(cx, right).map_or(0, |s| u64::try_from(s).unwrap_or(0))),
5353
_ => nbits,
5454
},
5555
ExprKind::MethodCall(method, left, [right], _) => {

clippy_lints/src/manual_strip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ fn find_stripping<'tcx>(
269269

270270
fn visit_pat(&mut self, pat: &'tcx rustc_hir::Pat<'tcx>) -> Self::Result {
271271
if let PatKind::Binding(_, _, ident, _) = pat.kind {
272-
*self.bindings.entry(ident.name).or_default() += 1;
272+
*self.bindings.entry(ident.name).or_insert(0) += 1;
273273
}
274274
walk_pat(self, pat);
275275
}

clippy_lints/src/operators/arithmetic_side_effects.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ impl ArithmeticSideEffects {
6464
/// "multiplication" are present in the inner set of allowed types.
6565
fn has_allowed_binary(&self, lhs_ty: Ty<'_>, rhs_ty: Ty<'_>) -> bool {
6666
let lhs_ty_string = lhs_ty.to_string();
67-
let lhs_ty_string_elem = lhs_ty_string.split('<').next().unwrap_or_default();
67+
let lhs_ty_string_elem = lhs_ty_string.split('<').next().unwrap_or("");
6868
let rhs_ty_string = rhs_ty.to_string();
69-
let rhs_ty_string_elem = rhs_ty_string.split('<').next().unwrap_or_default();
69+
let rhs_ty_string_elem = rhs_ty_string.split('<').next().unwrap_or("");
7070
if let Some(rhs_from_specific) = self.allowed_binary.get(lhs_ty_string_elem)
7171
&& {
7272
let rhs_has_allowed_ty = rhs_from_specific.contains(rhs_ty_string_elem);
@@ -85,7 +85,7 @@ impl ArithmeticSideEffects {
8585
/// allowed types.
8686
fn has_allowed_unary(&self, ty: Ty<'_>) -> bool {
8787
let ty_string = ty.to_string();
88-
let ty_string_elem = ty_string.split('<').next().unwrap_or_default();
88+
let ty_string_elem = ty_string.split('<').next().unwrap_or("");
8989
self.allowed_unary.contains(ty_string_elem)
9090
}
9191

clippy_lints/src/utils/author.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
216216

217217
fn next(&self, s: &'static str) -> String {
218218
let mut ids = self.ids.take();
219-
let out = match *ids.entry(s).and_modify(|n| *n += 1).or_default() {
219+
let out = match *ids.entry(s).and_modify(|n| *n += 1).or_insert(0) {
220220
// first usage of the name, use it as is
221221
0 => s.to_string(),
222222
// append a number starting with 1

clippy_utils/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2770,7 +2770,7 @@ pub fn tokenize_with_text(s: &str) -> impl Iterator<Item = (TokenKind, &str, Inn
27702770
let range = pos as usize..end as usize;
27712771
let inner = InnerSpan::new(range.start, range.end);
27722772
pos = end;
2773-
(t.kind, s.get(range).unwrap_or_default(), inner)
2773+
(t.kind, s.get(range).unwrap_or(""), inner)
27742774
})
27752775
}
27762776

clippy_utils/src/ty/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ pub fn approx_ty_size<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> u64 {
934934
match (cx.layout_of(ty).map(|layout| layout.size.bytes()), ty.kind()) {
935935
(Ok(size), _) => size,
936936
(Err(_), ty::Tuple(list)) => list.iter().map(|t| approx_ty_size(cx, t)).sum(),
937-
(Err(_), ty::Array(t, n)) => n.try_to_target_usize(cx.tcx).unwrap_or_default() * approx_ty_size(cx, *t),
937+
(Err(_), ty::Array(t, n)) => n.try_to_target_usize(cx.tcx).unwrap_or(0) * approx_ty_size(cx, *t),
938938
(Err(_), ty::Adt(def, subst)) if def.is_struct() => def
939939
.variants()
940940
.iter()
@@ -955,7 +955,7 @@ pub fn approx_ty_size<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> u64 {
955955
.sum::<u64>()
956956
})
957957
.max()
958-
.unwrap_or_default(),
958+
.unwrap_or(0),
959959
(Err(_), ty::Adt(def, subst)) if def.is_union() => def
960960
.variants()
961961
.iter()
@@ -964,10 +964,10 @@ pub fn approx_ty_size<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> u64 {
964964
.iter()
965965
.map(|field| approx_ty_size(cx, field.ty(cx.tcx, subst)))
966966
.max()
967-
.unwrap_or_default()
967+
.unwrap_or(0)
968968
})
969969
.max()
970-
.unwrap_or_default(),
970+
.unwrap_or(0),
971971
(Err(_), _) => 0,
972972
}
973973
}

src/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ pub fn main() {
267267
let clippy_args_var = env::var("CLIPPY_ARGS").ok();
268268
let clippy_args = clippy_args_var
269269
.as_deref()
270-
.unwrap_or_default()
270+
.unwrap_or("")
271271
.split("__CLIPPY_HACKERY__")
272272
.filter_map(|s| match s {
273273
"" => None,

0 commit comments

Comments
 (0)