diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-04-17 00:16:23 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-17 00:16:23 +0200 |
| commit | afb60d3097726045ea14472afa76a16db0c3aca6 (patch) | |
| tree | e7da2d50be728564959dafa98fc420b0d76562c0 | |
| parent | 7ab385e2e1ab9f6cb45cfc8ee4fbe754e2f52486 (diff) | |
| parent | 7ce21e4fb39e9d288f3fe96ad48f8bc8ec973588 (diff) | |
| download | rust-afb60d3097726045ea14472afa76a16db0c3aca6.tar.gz rust-afb60d3097726045ea14472afa76a16db0c3aca6.zip | |
Rollup merge of #139889 - spencer3035:clean-ui-tests-3-of-n, r=jieyouxu
Clean UI tests 3 of n Cleaned up 2 tests in `tests/ui/numbers-arithemetic` to be more useful. One for each commit. I can squash these into one commit when approved. Related Issues: #73494 #133895 r? jieyouxu
| -rw-r--r-- | tests/ui/numbers-arithmetic/int.rs | 6 | ||||
| -rw-r--r-- | tests/ui/numbers-arithmetic/isize-base.rs | 25 | ||||
| -rw-r--r-- | tests/ui/numbers-arithmetic/uint.rs | 6 | ||||
| -rw-r--r-- | tests/ui/numbers-arithmetic/usize-base.rs | 25 |
4 files changed, 50 insertions, 12 deletions
diff --git a/tests/ui/numbers-arithmetic/int.rs b/tests/ui/numbers-arithmetic/int.rs deleted file mode 100644 index 42f8e50d6ef..00000000000 --- a/tests/ui/numbers-arithmetic/int.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ run-pass - - - - -pub fn main() { let _x: isize = 10; } diff --git a/tests/ui/numbers-arithmetic/isize-base.rs b/tests/ui/numbers-arithmetic/isize-base.rs new file mode 100644 index 00000000000..412e7ac7a2e --- /dev/null +++ b/tests/ui/numbers-arithmetic/isize-base.rs @@ -0,0 +1,25 @@ +//! Tests basic `isize` functionality + +//@ run-pass + +pub fn main() { + // Literal matches assignment type + let a: isize = 42isize; + // Literal cast + let b: isize = 42 as isize; + // Literal type inference from assignment type + let c: isize = 42; + // Assignment type inference from literal (and later comparison) + let d = 42isize; + // Function return value type inference + let e = return_val(); + + assert_eq!(a, b); + assert_eq!(a, c); + assert_eq!(a, d); + assert_eq!(a, e); +} + +fn return_val() -> isize { + 42 +} diff --git a/tests/ui/numbers-arithmetic/uint.rs b/tests/ui/numbers-arithmetic/uint.rs deleted file mode 100644 index c2087b5a06c..00000000000 --- a/tests/ui/numbers-arithmetic/uint.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ run-pass - - - - -pub fn main() { let _x: usize = 10 as usize; } diff --git a/tests/ui/numbers-arithmetic/usize-base.rs b/tests/ui/numbers-arithmetic/usize-base.rs new file mode 100644 index 00000000000..833fc049798 --- /dev/null +++ b/tests/ui/numbers-arithmetic/usize-base.rs @@ -0,0 +1,25 @@ +//! Tests basic `usize` functionality + +//@ run-pass + +pub fn main() { + // Literal matches assignment type + let a: usize = 42usize; + // Literal cast + let b: usize = 42 as usize; + // Literal type inference from assignment type + let c: usize = 42; + // Assignment type inference from literal (and later comparison) + let d = 42usize; + // Function return value type inference + let e = return_val(); + + assert_eq!(a, b); + assert_eq!(a, c); + assert_eq!(a, d); + assert_eq!(a, e); +} + +fn return_val() -> usize { + 42 +} |
