Add test for swap lint when no_std is present

Adds additional test to check for `swap` suggestion when `no_std` is present
This commit is contained in:
dswij 2021-10-25 12:32:53 +08:00
parent 2d037aa4a6
commit dcd1a16dd0
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,15 @@
#![no_std]
#![feature(lang_items, start, libc)]
#![crate_type = "lib"]
use core::panic::PanicInfo;
#[warn(clippy::all)]
fn main() {
// TODO: do somethjing with swap
let mut a = 42;
let mut b = 1337;
a = b;
b = a;
}

View File

@ -0,0 +1,12 @@
error: this looks like you are trying to swap `a` and `b`
--> $DIR/no_std_swap.rs:13:5
|
LL | / a = b;
LL | | b = a;
| |_________^ help: try: `core::mem::swap(&mut a, &mut b)`
|
= note: `-D clippy::almost-swapped` implied by `-D warnings`
= note: or maybe you should use `core::mem::replace`?
error: aborting due to previous error