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
This commit is contained in:
Matthias Krüger 2025-04-17 00:16:23 +02:00 committed by GitHub
commit afb60d3097
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 50 additions and 12 deletions

View file

@ -1,6 +0,0 @@
//@ run-pass
pub fn main() { let _x: isize = 10; }

View file

@ -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
}

View file

@ -1,6 +0,0 @@
//@ run-pass
pub fn main() { let _x: usize = 10 as usize; }

View file

@ -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
}