Skip to content

Commit dcd1a16

Browse files
committed
Add test for swap lint when no_std is present
Adds additional test to check for `swap` suggestion when `no_std` is present
1 parent 2d037aa commit dcd1a16

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#![no_std]
2+
#![feature(lang_items, start, libc)]
3+
#![crate_type = "lib"]
4+
5+
use core::panic::PanicInfo;
6+
7+
#[warn(clippy::all)]
8+
fn main() {
9+
// TODO: do somethjing with swap
10+
let mut a = 42;
11+
let mut b = 1337;
12+
13+
a = b;
14+
b = a;
15+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error: this looks like you are trying to swap `a` and `b`
2+
--> $DIR/no_std_swap.rs:13:5
3+
|
4+
LL | / a = b;
5+
LL | | b = a;
6+
| |_________^ help: try: `core::mem::swap(&mut a, &mut b)`
7+
|
8+
= note: `-D clippy::almost-swapped` implied by `-D warnings`
9+
= note: or maybe you should use `core::mem::replace`?
10+
11+
error: aborting due to previous error
12+

0 commit comments

Comments
 (0)