about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-12-14 20:47:27 +0100
committerGitHub <noreply@github.com>2021-12-14 20:47:27 +0100
commit4b37cfc50cb1a909eefe632ea92fb5a2ad8bf240 (patch)
tree3bd8925f6aab1eadd4ad3c8f72cfec8267692b01 /src
parentc0e3ddeff3596792a6d32b8aa237f2b12810c9e8 (diff)
parentf194c9b26af5d280ab2d0e01fd85e23b3c303771 (diff)
downloadrust-4b37cfc50cb1a909eefe632ea92fb5a2ad8bf240.tar.gz
rust-4b37cfc50cb1a909eefe632ea92fb5a2ad8bf240.zip
Rollup merge of #91597 - r00ster91:lessthangreaterthan, r=oli-obk
Recover on invalid operators `<>` and `<=>`

Thanks to #89871 for showing me how to do this.
Next, I think it'd be nice to recover on `<=>` too, like #89871 intended, if this even works.
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/operator-recovery/less-than-greater-than.rs4
-rw-r--r--src/test/ui/operator-recovery/less-than-greater-than.stderr8
-rw-r--r--src/test/ui/operator-recovery/spaceship.rs4
-rw-r--r--src/test/ui/operator-recovery/spaceship.stderr8
4 files changed, 24 insertions, 0 deletions
diff --git a/src/test/ui/operator-recovery/less-than-greater-than.rs b/src/test/ui/operator-recovery/less-than-greater-than.rs
new file mode 100644
index 00000000000..2beed528ff1
--- /dev/null
+++ b/src/test/ui/operator-recovery/less-than-greater-than.rs
@@ -0,0 +1,4 @@
+fn main() {
+    println!("{}", 1 <> 2);
+    //~^ERROR invalid comparison operator `<>`
+}
diff --git a/src/test/ui/operator-recovery/less-than-greater-than.stderr b/src/test/ui/operator-recovery/less-than-greater-than.stderr
new file mode 100644
index 00000000000..80c921535bd
--- /dev/null
+++ b/src/test/ui/operator-recovery/less-than-greater-than.stderr
@@ -0,0 +1,8 @@
+error: invalid comparison operator `<>`
+  --> $DIR/less-than-greater-than.rs:2:22
+   |
+LL |     println!("{}", 1 <> 2);
+   |                      ^^ help: `<>` is not a valid comparison operator, use `!=`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/operator-recovery/spaceship.rs b/src/test/ui/operator-recovery/spaceship.rs
new file mode 100644
index 00000000000..a65f9389625
--- /dev/null
+++ b/src/test/ui/operator-recovery/spaceship.rs
@@ -0,0 +1,4 @@
+fn main() {
+    println!("{}", 1 <=> 2);
+    //~^ERROR invalid comparison operator `<=>`
+}
diff --git a/src/test/ui/operator-recovery/spaceship.stderr b/src/test/ui/operator-recovery/spaceship.stderr
new file mode 100644
index 00000000000..ed6bd74c9b9
--- /dev/null
+++ b/src/test/ui/operator-recovery/spaceship.stderr
@@ -0,0 +1,8 @@
+error: invalid comparison operator `<=>`
+  --> $DIR/spaceship.rs:2:22
+   |
+LL |     println!("{}", 1 <=> 2);
+   |                      ^^^ `<=>` is not a valid comparison operator, use `std::cmp::Ordering`
+
+error: aborting due to previous error
+