We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
swap
no_std
1 parent 2d037aa commit dcd1a16Copy full SHA for dcd1a16
tests/ui/crate_level_checks/no_std_swap.rs
@@ -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
+}
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
0 commit comments