diff --git a/tests/ui/crate_level_checks/no_std_swap.rs b/tests/ui/crate_level_checks/no_std_swap.rs new file mode 100644 index 00000000000..f5ff9eed7a1 --- /dev/null +++ b/tests/ui/crate_level_checks/no_std_swap.rs @@ -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; +} diff --git a/tests/ui/crate_level_checks/no_std_swap.stderr b/tests/ui/crate_level_checks/no_std_swap.stderr new file mode 100644 index 00000000000..079f1828cf9 --- /dev/null +++ b/tests/ui/crate_level_checks/no_std_swap.stderr @@ -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 +