diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-12-14 20:47:27 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-14 20:47:27 +0100 |
| commit | 4b37cfc50cb1a909eefe632ea92fb5a2ad8bf240 (patch) | |
| tree | 3bd8925f6aab1eadd4ad3c8f72cfec8267692b01 /src | |
| parent | c0e3ddeff3596792a6d32b8aa237f2b12810c9e8 (diff) | |
| parent | f194c9b26af5d280ab2d0e01fd85e23b3c303771 (diff) | |
| download | rust-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')
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 + |
