Skip to content

Commit fb93b52

Browse files
committed
format code
1 parent 2bd76f6 commit fb93b52

File tree

5 files changed

+25
-27
lines changed

5 files changed

+25
-27
lines changed

clippy_lints/src/casts/cast_lossless.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ fn should_lint(cx: &LateContext<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>, msrv: M
9191
matches!(utils::int_ty_to_nbits(cx.tcx, cast_from), Some(n) if n <= 16)
9292
},
9393
// No `f16` to `f32`: https://github.com/rust-lang/rust/issues/123831
94-
(ty::Float(FloatTy::F16), ty::Float(FloatTy::F32)) | (ty::Uint(UintTy::Usize) | ty::Int(IntTy::Isize), _) | (_, ty::Uint(UintTy::Usize) | ty::Int(IntTy::Isize)) => {
95-
false
96-
},
94+
(ty::Float(FloatTy::F16), ty::Float(FloatTy::F32))
95+
| (ty::Uint(UintTy::Usize) | ty::Int(IntTy::Isize), _)
96+
| (_, ty::Uint(UintTy::Usize) | ty::Int(IntTy::Isize)) => false,
9797
(ty::Uint(_) | ty::Int(_), ty::Int(_)) | (ty::Uint(_), ty::Uint(_)) => {
9898
matches!(
9999
(utils::int_ty_to_nbits(cx.tcx, cast_from), utils::int_ty_to_nbits(cx.tcx, cast_to)),

clippy_lints/src/literal_string_with_formatting_args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl<'tcx> LateLintPass<'tcx> for LiteralStringWithFormattingArg {
8989
LitKind::Str(symbol, style) => {
9090
let add = match style {
9191
StrStyle::Cooked => 1,
92-
StrStyle::Raw(nb) => usize::from(nb) + 2,
92+
StrStyle::Raw(nb) => usize::from(nb) + 2,
9393
};
9494
(add, symbol)
9595
},

clippy_utils/src/source.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ pub fn str_literal_to_char_literal(
779779
{
780780
let snip = snippet_with_applicability(sess, expr.span, string, applicability);
781781
let ch = if let StrStyle::Raw(nhash) = style {
782-
let nhash = usize::from(nhash);
782+
let nhash = usize::from(nhash);
783783
// for raw string: r##"a"##
784784
&snip[(nhash + 2)..(snip.len() - 1 - nhash)]
785785
} else {

tests/ui/cast_lossless_char.rs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
#![allow(clippy::char_lit_as_u8)]
22
#![warn(clippy::cast_lossless)]
33

4-
54
type I32 = i32;
65
type U32 = u32;
76

87
fn main() {
9-
let _ = '|' as u32;
10-
//~^ cast_lossless
11-
let _ = '|' as i32;
12-
13-
let _ = '|' as u64;
14-
//~^ cast_lossless
15-
let _ = '|' as i64;
8+
let _ = '|' as u32;
9+
//~^ cast_lossless
10+
let _ = '|' as i32;
11+
12+
let _ = '|' as u64;
13+
//~^ cast_lossless
14+
let _ = '|' as i64;
15+
16+
let _ = '|' as u128;
17+
//~^ cast_lossless
18+
let _ = '|' as i128;
1619

17-
let _ = '|' as u128;
18-
//~^ cast_lossless
19-
let _ = '|' as i128;
20-
21-
let _ = '|' as U32;
22-
//~^ cast_lossless
23-
let _ = '|' as I32;
20+
let _ = '|' as U32;
21+
//~^ cast_lossless
22+
let _ = '|' as I32;
2423

25-
let _ = '|' as usize;
26-
let _ = '|' as isize;
27-
let _ = '|' as i8;
28-
let _ = '|' as u8;
29-
let _ = '|' as i16;
30-
let _ = '|' as u16;
24+
let _ = '|' as usize;
25+
let _ = '|' as isize;
26+
let _ = '|' as i8;
27+
let _ = '|' as u8;
28+
let _ = '|' as i16;
29+
let _ = '|' as u16;
3130
}

tests/ui/cast_lossless_integer.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,3 @@ fn cast_using_macro() {
201201
let _ = mac!(0u8 => u32);
202202
let _ = mac!(0u8, as, u32);
203203
}
204-

0 commit comments

Comments
 (0)