about summary refs log tree commit diff
path: root/tests/ui/parser
diff options
context:
space:
mode:
author许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com>2024-12-08 22:13:07 +0800
committer许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com>2024-12-10 11:34:13 +0800
commit56efa0a7bf55aa4d1413008df672b95f09a4d8e9 (patch)
tree8370f3cd704dc95f350d634812cfeba0b42ed4dc /tests/ui/parser
parent4652b14f9bce16e5d1a5fe4babd0d356e895905f (diff)
downloadrust-56efa0a7bf55aa4d1413008df672b95f09a4d8e9.tar.gz
rust-56efa0a7bf55aa4d1413008df672b95f09a4d8e9.zip
Adjust `as-precedence.rs`
- Document `as-precedence.rs`
- Move `as-precedence.rs` under `tests/ui/parser/`
Diffstat (limited to 'tests/ui/parser')
-rw-r--r--tests/ui/parser/as-precedence.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/ui/parser/as-precedence.rs b/tests/ui/parser/as-precedence.rs
new file mode 100644
index 00000000000..ca8328adb0e
--- /dev/null
+++ b/tests/ui/parser/as-precedence.rs
@@ -0,0 +1,18 @@
+//! Parser precedence test to help with [RFC 87 "Trait Bounds with Plus"][rfc-87], to check the
+//! precedence of the `as` operator in relation to some arithmetic bin-ops and parentheses.
+//!
+//! Editor's note: this test seems quite incomplete compared to what's possible nowadays. Maybe
+//! there's another set of tests whose coverage overshadows this test?
+//!
+//! [rfc-87]: https://rust-lang.github.io/rfcs/0087-trait-bounds-with-plus.html
+
+//@ run-pass
+
+#[allow(unused_parens)]
+fn main() {
+    assert_eq!(3 as usize * 3, 9);
+    assert_eq!(3 as (usize) * 3, 9);
+    assert_eq!(3 as (usize) / 3, 1);
+    assert_eq!(3 as usize + 3, 6);
+    assert_eq!(3 as (usize) + 3, 6);
+}