Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f00184e
Add a timeout to the `remote-test-client` connection
pvdrz Nov 19, 2025
444f1c5
Test the `remote-test-client` timeout
pvdrz Nov 19, 2025
6bd5de7
Document the new env variable in the rustc-dev-guide
pvdrz Nov 6, 2025
b27bb83
add regression test for align attribute on struct fields
Aditya-PS-05 Nov 27, 2025
3ceea47
add issue link in test
Aditya-PS-05 Nov 27, 2025
3f943fb
Fix ICE when include_str! reads absolute path binary files
reddevilmidzy Nov 25, 2025
bfc0c02
Relocate macro_backtrace to macro and remove macro_backtrace
reddevilmidzy Nov 27, 2025
57f9269
add test for borrow checker ICE with nested generic closures
Aditya-PS-05 Nov 28, 2025
6bbd737
Remove test-float-parse from workspace list in tidy
bjorn3 Nov 28, 2025
58a802e
Relocate modules_ans_files_visibity/mod_file_correct_spans.rs to
reddevilmidzy Nov 28, 2025
8e74c6b
Relocate modules_and_files_visibility/mod_file_disambig.rs to
reddevilmidzy Nov 28, 2025
aa97acc
Relocate qualified/qualified-path-params to
reddevilmidzy Nov 28, 2025
cd618a9
Merge missing_non_modrs with modules
reddevilmidzy Nov 28, 2025
ace4aeb
Merge `while` with `for-loop-while`
reddevilmidzy Nov 28, 2025
2b4b02e
change test location
Aditya-PS-05 Nov 28, 2025
d7a36c1
Rollup merge of #147952 - ferrocene:pvdrz/remote-test-client-timeout,…
matthiaskrgr Nov 28, 2025
6d4e3f8
Rollup merge of #149321 - reddevilmidzy:ice, r=petrochenkov
matthiaskrgr Nov 28, 2025
3f1e4f8
Rollup merge of #149398 - Aditya-PS-05:test-issue-143987-align-struct…
matthiaskrgr Nov 28, 2025
8d6e68b
Rollup merge of #149411 - reddevilmidzy:t5, r=Kivooeo
matthiaskrgr Nov 28, 2025
60e46fb
Rollup merge of #149413 - Aditya-PS-05:test-issue-143821-nested-closu…
matthiaskrgr Nov 28, 2025
3730b40
Rollup merge of #149415 - bjorn3:tidy_update, r=clubby789
matthiaskrgr Nov 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions compiler/rustc_parse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ pub fn utf8_error<E: EmissionGuarantee>(
};
let contents = String::from_utf8_lossy(contents).to_string();
let source = sm.new_source_file(PathBuf::from(path).into(), contents);

// Avoid out-of-bounds span from lossy UTF-8 conversion.
if start as u32 > source.normalized_source_len.0 {
err.note(note);
return;
}

let span = Span::with_root_ctxt(
source.normalized_byte_pos(start as u32),
source.normalized_byte_pos(start as u32),
Expand Down
4 changes: 4 additions & 0 deletions src/doc/rustc-dev-guide/src/tests/running.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,10 @@ Tests are built on the machine running `x` not on the remote machine.
Tests which fail to build unexpectedly (or `ui` tests producing incorrect build
output) may fail without ever running on the remote machine.

There is a default timeout of 30 minutes in case the `remote-test-server`
cannot be reached by the `x` command. This timeout can be modified by using the
`TEST_DEVICE_CONNECT_TIMEOUT_SECONDS` environment variable.

## Testing on emulators

Some platforms are tested via an emulator for architectures that aren't readily available.
Expand Down
27 changes: 25 additions & 2 deletions src/tools/remote-test-client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ use std::io::{self, BufWriter};
use std::net::TcpStream;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::time::Duration;
use std::time::{Duration, Instant};
use std::{env, thread};

const REMOTE_ADDR_ENV: &str = "TEST_DEVICE_ADDR";
const DEFAULT_ADDR: &str = "127.0.0.1:12345";

const CONNECT_TIMEOUT_ENV: &str = "TEST_DEVICE_CONNECT_TIMEOUT_SECONDS";
/// The default timeout is high to not break slow CI or slow device starts.
const DEFAULT_CONNECT_TIMEOUT: Duration = Duration::from_mins(30);

macro_rules! t {
($e:expr) => {
match $e {
Expand Down Expand Up @@ -56,6 +60,17 @@ fn main() {
}
}

fn connect_timeout() -> Duration {
match env::var(CONNECT_TIMEOUT_ENV).ok() {
Some(timeout) => timeout.parse().map(Duration::from_secs).unwrap_or_else(|e| {
panic!(
"error: parsing `{CONNECT_TIMEOUT_ENV}` value \"{timeout}\" as seconds failed: {e}"
)
}),
None => DEFAULT_CONNECT_TIMEOUT,
}
}

fn spawn_emulator(target: &str, server: &Path, tmpdir: &Path, rootfs: Option<PathBuf>) {
let device_address = env::var(REMOTE_ADDR_ENV).unwrap_or(DEFAULT_ADDR.to_string());

Expand All @@ -69,20 +84,28 @@ fn spawn_emulator(target: &str, server: &Path, tmpdir: &Path, rootfs: Option<Pat
}

// Wait for the emulator to come online
loop {
let timeout = connect_timeout();
let mut successful_read = false;
let start_time = Instant::now();
while start_time.elapsed() < timeout {
let dur = Duration::from_millis(2000);
if let Ok(mut client) = TcpStream::connect(&device_address) {
t!(client.set_read_timeout(Some(dur)));
t!(client.set_write_timeout(Some(dur)));
if client.write_all(b"ping").is_ok() {
let mut b = [0; 4];
if client.read_exact(&mut b).is_ok() {
successful_read = true;
break;
}
}
}
thread::sleep(dur);
}

if !successful_read {
panic!("Gave up trying to connect to test device at {device_address} after {timeout:?}");
}
}

fn start_android_emulator(server: &Path) {
Expand Down
15 changes: 15 additions & 0 deletions src/tools/remote-test-client/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,18 @@ fn test_help() {
let stdout = String::from_utf8(output.stdout.clone()).unwrap();
assert!(stdout.trim().starts_with("Usage:"));
}

#[test]
fn test_timeout() {
let mut cmd = assert_cmd::cargo::cargo_bin_cmd!();
cmd.env("TEST_DEVICE_CONNECT_TIMEOUT_SECONDS", "1");
cmd.env("TEST_DEVICE_ADDR", "127.69.69.69:6969");
cmd.args(["spawn-emulator", "dummy-target", "dummy-server", "dummy-tmpdir"]);

let assert = cmd.assert().failure();
let output = assert.get_output();

let stderr = String::from_utf8(output.stderr.clone()).unwrap();
let pass_msg = "Gave up trying to connect to test device";
assert!(stderr.contains(pass_msg), "Could not find `{pass_msg}` in `{stderr}`");
}
6 changes: 0 additions & 6 deletions src/tools/tidy/src/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,6 @@ pub(crate) const WORKSPACES: &[WorkspaceInfo<'static>] = &[
crates_and_deps: None,
submodules: &["src/tools/rustc-perf"],
},
WorkspaceInfo {
path: "src/tools/test-float-parse",
exceptions: EXCEPTIONS,
crates_and_deps: None,
submodules: &[],
},
WorkspaceInfo {
path: "tests/run-make-cargo/uefi-qemu/uefi_qemu_test",
exceptions: EXCEPTIONS_UEFI_QEMU_TEST,
Expand Down
1 change: 1 addition & 0 deletions src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ fn check_unexpected_extension(check: &mut RunningCheck, file_path: &Path, ext: &
"tests/ui/crate-loading/auxiliary/libfoo.rlib", // testing loading a manually created rlib
"tests/ui/include-macros/data.bin", // testing including data with the include macros
"tests/ui/include-macros/file.txt", // testing including data with the include macros
"tests/ui/include-macros/invalid-utf8-binary-file.bin", // testing including data with the include macros
"tests/ui/macros/macro-expanded-include/file.txt", // testing including data with the include macros
"tests/ui/macros/not-utf8.bin", // testing including data with the include macros
"tests/ui/macros/syntax-extension-source-utils-files/includeme.fragment", // more include
Expand Down
28 changes: 0 additions & 28 deletions tests/ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -891,12 +891,6 @@ Exercise *Link-Time Optimization* (LTO), involving the flags `-C lto` or `-Z thi

Tests on changes to inference variable lattice LUB/GLB, see <https://github.com/rust-lang/rust/pull/45853>.

## `tests/ui/macro_backtrace/`: `-Zmacro-backtrace`

Contains a single test, checking the unstable command-line flag to enable detailed macro backtraces.

**FIXME**: This could be merged with `ui/macros`, which already contains other macro backtrace tests.

## `tests/ui/macros/`

Broad category of tests on macros.
Expand Down Expand Up @@ -945,12 +939,6 @@ Something is missing which could be added to fix (e.g. suggestions).

**FIXME**: this is way too vague, tests should be rehomed.

## `tests/ui/missing_non_modrs_mod/`

This directory is a small tree of `mod` dependencies, but the root, `foo.rs`, is looking for a file which does not exist. The test checks that the error is reported at the top-level module.

**FIXME**: Merge with `tests/ui/modules/`.

## `tests/ui/missing-trait-bounds/`

Tests for checking missing trait bounds, and their diagnostics.
Expand All @@ -963,10 +951,6 @@ Tests on the module system.

**FIXME**: `tests/ui/imports/` should probably be merged with this.

## `tests/ui/modules_and_files_visibility/`

**FIXME**: Merge with `tests/ui/modules/`.

## `tests/ui/moves`

Tests on moves (destructive moves).
Expand Down Expand Up @@ -1135,12 +1119,6 @@ A large category about function and type public/private visibility, and its impa

**FIXME**: merge with `tests/ui/privacy/`.

## `tests/ui/qualified/`

Contains few tests on qualified paths where a type parameter is provided at the end: `type A = <S as Tr>::A::f<u8>;`. The tests check if this fails during type checking, not parsing.

**FIXME**: Should be rehomed to `ui/typeck`.

## `tests/ui/query-system/`

Tests on Rust methods and functions which use the query system, such as `std::mem::size_of`. These compute information about the current runtime and return it. See [Query system | rustc-dev-guide](https://rustc-dev-guide.rust-lang.org/query.html).
Expand Down Expand Up @@ -1583,12 +1561,6 @@ Tests on various well-formedness checks, e.g. [Type-checking normal functions](h

Tests on `where` clauses. See [Where clauses | Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses).

## `tests/ui/while/`

Tests on the `while` keyword and the `while` construct.

**FIXME**: merge with `ui/for-loop-while`.

## `tests/ui/windows-subsystem/`: `#![windows_subsystem = ""]`

See [the `windows_subsystem` attribute](https://doc.rust-lang.org/reference/runtime.html#the-windows_subsystem-attribute).
Expand Down
30 changes: 30 additions & 0 deletions tests/ui/attributes/align-on-fields-143987.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Regression test for issue https://github.com/rust-lang/rust/issues/143987
// Ensure that using `#[align]` on struct fields produces an error
// instead of causing an ICE (Internal Compiler Error)

// FIXME(#82232, #143834): temporarily renamed to mitigate `#[align]` nameres ambiguity
#![feature(rustc_attrs)]
#![feature(fn_align)]

struct Data {
#[rustc_align(8)] //~ ERROR `#[rustc_align]` attribute cannot be used on struct fields
x: usize,
}

// Test with invalid type to match the original issue more closely
struct DataInvalid {
#[rustc_align(8)] //~ ERROR `#[rustc_align]` attribute cannot be used on struct fields
x: usize8, //~ ERROR cannot find type `usize8` in this scope
}

// Test with tuple struct
struct TupleData(
#[rustc_align(32)] //~ ERROR `#[rustc_align]` attribute cannot be used on struct fields
u32
);

// Test that it works correctly on functions (no error)
#[rustc_align(16)]
fn aligned_function() {}

fn main() {}
33 changes: 33 additions & 0 deletions tests/ui/attributes/align-on-fields-143987.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
error[E0412]: cannot find type `usize8` in this scope
--> $DIR/align-on-fields-143987.rs:17:8
|
LL | x: usize8,
| ^^^^^^ help: a builtin type with a similar name exists: `usize`

error: `#[rustc_align]` attribute cannot be used on struct fields
--> $DIR/align-on-fields-143987.rs:10:5
|
LL | #[rustc_align(8)]
| ^^^^^^^^^^^^^^^^^
|
= help: `#[rustc_align]` can only be applied to functions

error: `#[rustc_align]` attribute cannot be used on struct fields
--> $DIR/align-on-fields-143987.rs:16:5
|
LL | #[rustc_align(8)]
| ^^^^^^^^^^^^^^^^^
|
= help: `#[rustc_align]` can only be applied to functions

error: `#[rustc_align]` attribute cannot be used on struct fields
--> $DIR/align-on-fields-143987.rs:22:5
|
LL | #[rustc_align(32)]
| ^^^^^^^^^^^^^^^^^^
|
= help: `#[rustc_align]` can only be applied to functions

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0412`.
39 changes: 39 additions & 0 deletions tests/ui/borrowck/nested-closure-with-generic-ice.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//@ check-pass
// Regression test for issue https://github.com/rust-lang/rust/issues/143821
// Tests that we don't ICE when borrow-checking nested closures with generic type parameters
// and late-bound lifetime parameters.

fn data_<T: 'static>(_: &()) -> &T {
loop {}
}

fn register<T, F>(f: F) -> IfaceToken<T>
where
T: 'static,
F: FnOnce(&()),
{
loop {}
}

fn method_with_cr_async<CB>(cb: CB)
where
CB: Fn(),
{
loop {}
}

struct IfaceToken<T: 'static>(T);

fn foo<T>() -> IfaceToken<T> {
register::<T, _>(|b: &()| {
method_with_cr_async(|| {
data_::<T>(&());
});
})
}

struct A();

fn main() {
foo::<A>();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ check-pass
// regression test for #40235
#![allow(unused_variables)]
fn foo() {}

Expand Down
Binary file not shown.
10 changes: 10 additions & 0 deletions tests/ui/include-macros/invalid-utf8-binary-file.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//@ normalize-stderr: "at byte `\d+`" -> "at byte `$$BYTE`"
//@ normalize-stderr: "`[^`\n]*invalid-utf8-binary-file\.bin`" -> "`$DIR/invalid-utf8-binary-file.bin`"
//@ rustc-env:INVALID_UTF8_BIN={{src-base}}/include-macros/invalid-utf8-binary-file.bin

//! Ensure that ICE does not occur when reading an invalid UTF8 file with an absolute path.
//! regression test for issue <https://github.com/rust-lang/rust/issues/149304>

#![doc = include_str!(concat!(env!("INVALID_UTF8_BIN")))] //~ ERROR: wasn't a utf-8 file

fn main() {}
10 changes: 10 additions & 0 deletions tests/ui/include-macros/invalid-utf8-binary-file.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: `/invalid-utf8-binary-file.bin` wasn't a utf-8 file
--> $DIR/invalid-utf8-binary-file.rs:8:10
|
LL | #![doc = include_str!(concat!(env!("INVALID_UTF8_BIN")))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: invalid utf-8 at byte `$BYTE`

error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
// Test that the macro backtrace facility works (supporting file)
// Test that the macro backtrace facility works (supporting macro-backtrace-complex.rs)

// a non-local macro
#[macro_export]
macro_rules! ping {
() => {
pong!();
}
};
}

#[macro_export]
macro_rules! deep {
() => {
foo!();
}
};
}

#[macro_export]
macro_rules! foo {
() => {
bar!();
}
};
}

#[macro_export]
macro_rules! bar {
() => {
ping!();
}
};
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `error`
--> $DIR/main.rs:10:20
--> $DIR/macro-backtrace-complex.rs:12:20
|
LL | / macro_rules! pong {
LL | | () => { syntax error };
Expand All @@ -11,7 +11,7 @@ LL | pong!();
| ------- in this macro invocation

error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `error`
--> $DIR/main.rs:10:20
--> $DIR/macro-backtrace-complex.rs:12:20
|
LL | / macro_rules! pong {
LL | | () => { syntax error };
Expand All @@ -31,7 +31,7 @@ LL | pong!();
| ------- in this macro invocation (#2)

error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `error`
--> $DIR/main.rs:10:20
--> $DIR/macro-backtrace-complex.rs:12:20
|
LL | / macro_rules! pong {
LL | | () => { syntax error };
Expand Down
Loading
Loading