Skip to content

Commit 359c9e4

Browse files
authored
Unrolled build for #143195
Rollup merge of #143195 - Kivooeo:tf17, r=tgross35 `tests/ui`: A New Order [17/N] > [!NOTE] > > Intermediate commits are intended to help review, but will be squashed prior to merge. Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of #133895. r? `@tgross35`
2 parents ad3b725 + 1e3a2b2 commit 359c9e4

11 files changed

+111
-87
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//! Test that monomorphization correctly distinguishes types with different ABI alignment.
2+
//!
3+
//! On x86_64-linux-gnu and similar platforms, structs get 8-byte "preferred"
4+
//! alignment, but their "ABI" alignment (what actually matters for data layout)
5+
//! is the largest alignment of any field. If monomorphization incorrectly uses
6+
//! "preferred" alignment instead of "ABI" alignment, it might unify types `A`
7+
//! and `B` even though `S<A>` and `S<B>` have field `t` at different offsets,
8+
//! leading to incorrect method dispatch for `unwrap()`.
9+
10+
//@ run-pass
11+
12+
#[derive(Copy, Clone)]
13+
struct S<T> {
14+
#[allow(dead_code)]
15+
i: u8,
16+
t: T,
17+
}
18+
19+
impl<T> S<T> {
20+
fn unwrap(self) -> T {
21+
self.t
22+
}
23+
}
24+
25+
#[derive(Copy, Clone, PartialEq, Debug)]
26+
struct A((u32, u32)); // Different ABI alignment than B
27+
28+
#[derive(Copy, Clone, PartialEq, Debug)]
29+
struct B(u64); // Different ABI alignment than A
30+
31+
pub fn main() {
32+
static CA: S<A> = S { i: 0, t: A((13, 104)) };
33+
static CB: S<B> = S { i: 0, t: B(31337) };
34+
35+
assert_eq!(CA.unwrap(), A((13, 104)));
36+
assert_eq!(CB.unwrap(), B(31337));
37+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//! Test that opt-level=z produces correct code on Windows MSVC targets.
2+
//!
3+
//! A previously outdated version of LLVM caused compilation failures and
4+
//! generated invalid code on Windows specifically with optimization level `z`.
5+
//! The bug manifested as corrupted base pointers due to incorrect register
6+
//! usage in the generated assembly (e.g., `popl %esi` corrupting local variables).
7+
//! After updating to a more recent LLVM version, this test ensures that
8+
//! compilation and execution both succeed with opt-level=z.
9+
//!
10+
//! Regression test for <https://github.com/rust-lang/rust/issues/45034>.
11+
12+
//@ ignore-cross-compile
13+
// Reason: the compiled binary is executed
14+
//@ only-windows
15+
// Reason: the observed bug only occurred on Windows MSVC targets
16+
//@ run-pass
17+
//@ compile-flags: -C opt-level=z
18+
19+
#![feature(test)]
20+
extern crate test;
21+
22+
fn foo(x: i32, y: i32) -> i64 {
23+
(x + y) as i64
24+
}
25+
26+
#[inline(never)]
27+
fn bar() {
28+
let _f = Box::new(0);
29+
// This call used to trigger an LLVM bug in opt-level=z where the base
30+
// pointer gets corrupted due to incorrect register allocation
31+
let y: fn(i32, i32) -> i64 = test::black_box(foo);
32+
test::black_box(y(1, 2));
33+
}
34+
35+
fn main() {
36+
bar();
37+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//! Test that static data from external crates can be imported on MSVC targets.
2+
//!
3+
//! On Windows MSVC targets, static data from external rlibs must be imported
4+
//! through `__imp_<symbol>` stubs to ensure proper linking. Without this,
5+
//! the linker would fail with "unresolved external symbol" errors when trying
6+
//! to reference static data from another crate.
7+
//!
8+
//! Regression test for <https://github.com/rust-lang/rust/issues/26591>.
9+
//! Fixed in <https://github.com/rust-lang/rust/pull/28646>.
10+
11+
//@ run-pass
12+
//@ aux-build:msvc-static-data-import-lib.rs
13+
14+
extern crate msvc_static_data_import_lib;
15+
16+
fn main() {
17+
println!("The answer is {}!", msvc_static_data_import_lib::FOO);
18+
}

tests/ui/monomorphize-abi-alignment.rs

Lines changed: 0 additions & 35 deletions
This file was deleted.

tests/ui/msvc-data-only.rs

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/ui/msvc-opt-minsize.rs

Lines changed: 0 additions & 31 deletions
This file was deleted.

tests/ui/multibyte.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/ui/multiline-comment.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//! Test that basic multiline comments are parsed correctly.
2+
//!
3+
//! Feature implementation test for <https://github.com/rust-lang/rust/issues/66>.
4+
5+
//@ run-pass
6+
7+
/*
8+
* This is a multi-line comment.
9+
*/
10+
pub fn main() {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//! Test that multibyte Unicode characters don't crash the compiler.
2+
//!
3+
//! Regression test for <https://github.com/rust-lang/rust/issues/4780>.
4+
5+
//@ run-pass
6+
7+
pub fn main() {
8+
println!("마이너스 사인이 없으면");
9+
}

0 commit comments

Comments
 (0)