Skip to content

Commit 97ef6a8

Browse files
committed
Auto merge of rust-lang#125624 - matthiaskrgr:rollup-560jx21, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#125339 (The number of tests does not depend on the architecture's pointer width) - rust-lang#125539 (crashes: increment the number of tracked ones) - rust-lang#125542 (Migrate rustdoc verify output files) - rust-lang#125613 (Use `rmake` for `windows-` run-make tests) - rust-lang#125616 (MIR validation: ensure that downcast projection is followed by field projection) Failed merges: - rust-lang#125573 (Migrate `run-make/allow-warnings-cmdline-stability` to `rmake.rs`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents b0f8618 + a3d4b5f commit 97ef6a8

File tree

42 files changed

+539
-107
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+539
-107
lines changed

compiler/rustc_middle/src/mir/syntax.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1008,8 +1008,8 @@ pub type AssertMessage<'tcx> = AssertKind<Operand<'tcx>>;
10081008
/// element:
10091009
///
10101010
/// - [`Downcast`](ProjectionElem::Downcast): This projection sets the place's variant index to the
1011-
/// given one, and makes no other changes. A `Downcast` projection on a place with its variant
1012-
/// index already set is not well-formed.
1011+
/// given one, and makes no other changes. A `Downcast` projection must always be followed
1012+
/// immediately by a `Field` projection.
10131013
/// - [`Field`](ProjectionElem::Field): `Field` projections take their parent place and create a
10141014
/// place referring to one of the fields of the type. The resulting address is the parent
10151015
/// address, plus the offset of the field. The type becomes the type of the field. If the parent

compiler/rustc_mir_transform/src/validate.rs

+23-3
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,10 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
689689
if Some(adt_def.did()) == self.tcx.lang_items().dyn_metadata() {
690690
self.fail(
691691
location,
692-
format!("You can't project to field {f:?} of `DynMetadata` because \
693-
layout is weird and thinks it doesn't have fields."),
692+
format!(
693+
"You can't project to field {f:?} of `DynMetadata` because \
694+
layout is weird and thinks it doesn't have fields."
695+
),
694696
);
695697
}
696698

@@ -839,7 +841,25 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
839841
&& cntxt != PlaceContext::NonUse(NonUseContext::VarDebugInfo)
840842
&& place.projection[1..].contains(&ProjectionElem::Deref)
841843
{
842-
self.fail(location, format!("{place:?}, has deref at the wrong place"));
844+
self.fail(
845+
location,
846+
format!("place {place:?} has deref as a later projection (it is only permitted as the first projection)"),
847+
);
848+
}
849+
850+
// Ensure all downcast projections are followed by field projections.
851+
let mut projections_iter = place.projection.iter();
852+
while let Some(proj) = projections_iter.next() {
853+
if matches!(proj, ProjectionElem::Downcast(..)) {
854+
if !matches!(projections_iter.next(), Some(ProjectionElem::Field(..))) {
855+
self.fail(
856+
location,
857+
format!(
858+
"place {place:?} has `Downcast` projection not followed by `Field`"
859+
),
860+
);
861+
}
862+
}
843863
}
844864

845865
self.super_place(place, cntxt, location);

src/tools/miri/tests/panic/mir-validation.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
thread 'rustc' panicked at compiler/rustc_mir_transform/src/validate.rs:LL:CC:
22
broken MIR in Item(DefId) (after phase change to runtime-optimized) at bb0[1]:
3-
(*(_2.0: *mut i32)), has deref at the wrong place
3+
place (*(_2.0: *mut i32)) has deref as a later projection (it is only permitted as the first projection)
44
stack backtrace:
55

66
error: the compiler unexpectedly panicked. this is a bug.

src/tools/run-make-support/src/diff/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ impl Diff {
5151
/// Specify the actual output for the diff from a file.
5252
pub fn actual_file<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
5353
let path = path.as_ref();
54-
let content = std::fs::read_to_string(path).expect("failed to read file");
54+
let content = match std::fs::read_to_string(path) {
55+
Ok(c) => c,
56+
Err(e) => panic!("failed to read `{}`: {:?}", path.display(), e),
57+
};
5558
let name = path.to_string_lossy().to_string();
5659

5760
self.actual = Some(content);

src/tools/run-make-support/src/lib.rs

+67
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ pub mod rustc;
1212
pub mod rustdoc;
1313

1414
use std::env;
15+
use std::fs;
16+
use std::io;
1517
use std::path::{Path, PathBuf};
1618
use std::process::{Command, Output};
1719

@@ -201,6 +203,71 @@ pub fn set_host_rpath(cmd: &mut Command) {
201203
});
202204
}
203205

206+
/// Copy a directory into another.
207+
pub fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) {
208+
fn copy_dir_all_inner(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()> {
209+
let dst = dst.as_ref();
210+
if !dst.is_dir() {
211+
fs::create_dir_all(&dst)?;
212+
}
213+
for entry in fs::read_dir(src)? {
214+
let entry = entry?;
215+
let ty = entry.file_type()?;
216+
if ty.is_dir() {
217+
copy_dir_all_inner(entry.path(), dst.join(entry.file_name()))?;
218+
} else {
219+
fs::copy(entry.path(), dst.join(entry.file_name()))?;
220+
}
221+
}
222+
Ok(())
223+
}
224+
225+
if let Err(e) = copy_dir_all_inner(&src, &dst) {
226+
// Trying to give more context about what exactly caused the failure
227+
panic!(
228+
"failed to copy `{}` to `{}`: {:?}",
229+
src.as_ref().display(),
230+
dst.as_ref().display(),
231+
e
232+
);
233+
}
234+
}
235+
236+
/// Check that all files in `dir1` exist and have the same content in `dir2`. Panic otherwise.
237+
pub fn recursive_diff(dir1: impl AsRef<Path>, dir2: impl AsRef<Path>) {
238+
fn read_file(path: &Path) -> Vec<u8> {
239+
match fs::read(path) {
240+
Ok(c) => c,
241+
Err(e) => panic!("Failed to read `{}`: {:?}", path.display(), e),
242+
}
243+
}
244+
245+
let dir2 = dir2.as_ref();
246+
for entry in fs::read_dir(dir1).unwrap() {
247+
let entry = entry.unwrap();
248+
let entry_name = entry.file_name();
249+
let path = entry.path();
250+
251+
if path.is_dir() {
252+
recursive_diff(&path, &dir2.join(entry_name));
253+
} else {
254+
let path2 = dir2.join(entry_name);
255+
let file1 = read_file(&path);
256+
let file2 = read_file(&path2);
257+
258+
// We don't use `assert_eq!` because they are `Vec<u8>`, so not great for display.
259+
// Why not using String? Because there might be minified files or even potentially
260+
// binary ones, so that would display useless output.
261+
assert!(
262+
file1 == file2,
263+
"`{}` and `{}` have different content",
264+
path.display(),
265+
path2.display(),
266+
);
267+
}
268+
}
269+
}
270+
204271
/// Implement common helpers for command wrappers. This assumes that the command wrapper is a struct
205272
/// containing a `cmd: Command` field and a `output` function. The provided helpers are:
206273
///

src/tools/run-make-support/src/llvm_readobj.rs

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ impl LlvmReadobj {
4242
self
4343
}
4444

45+
/// Pass `--coff-imports` to display the Windows DLL imports
46+
pub fn coff_imports(&mut self) -> &mut Self {
47+
self.cmd.arg("--coff-imports");
48+
self
49+
}
50+
4551
/// Get the [`Output`][::std::process::Output] of the finished process.
4652
#[track_caller]
4753
pub fn command_output(&mut self) -> ::std::process::Output {

src/tools/run-make-support/src/rustc.rs

+6
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ impl Rustc {
203203
self
204204
}
205205

206+
/// Specify the linker
207+
pub fn linker(&mut self, linker: &str) -> &mut Self {
208+
self.cmd.arg(format!("-Clinker={linker}"));
209+
self
210+
}
211+
206212
/// Get the [`Output`][::std::process::Output] of the finished process.
207213
#[track_caller]
208214
pub fn command_output(&mut self) -> ::std::process::Output {

src/tools/run-make-support/src/rustdoc.rs

+7
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ impl Rustdoc {
151151
self
152152
}
153153

154+
/// Specify the output format.
155+
pub fn output_format(&mut self, format: &str) -> &mut Self {
156+
self.cmd.arg("--output-format");
157+
self.cmd.arg(format);
158+
self
159+
}
160+
154161
#[track_caller]
155162
pub fn run_fail_assert_exit_code(&mut self, code: i32) -> Output {
156163
let caller_location = std::panic::Location::caller();

src/tools/tidy/src/allowed_run_make_makefiles.txt

-6
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ run-make/issue-83112-incr-test-moved-file/Makefile
117117
run-make/issue-84395-lto-embed-bitcode/Makefile
118118
run-make/issue-85019-moved-src-dir/Makefile
119119
run-make/issue-85401-static-mir/Makefile
120-
run-make/issue-85441/Makefile
121120
run-make/issue-88756-default-output/Makefile
122121
run-make/issue-97463-abi-param-passing/Makefile
123122
run-make/jobserver-error/Makefile
@@ -226,7 +225,6 @@ run-make/rlib-format-packed-bundled-libs/Makefile
226225
run-make/rmeta-preferred/Makefile
227226
run-make/rustc-macro-dep-files/Makefile
228227
run-make/rustdoc-io-error/Makefile
229-
run-make/rustdoc-verify-output-files/Makefile
230228
run-make/sanitizer-cdylib-link/Makefile
231229
run-make/sanitizer-dylib-link/Makefile
232230
run-make/sanitizer-staticlib-link/Makefile
@@ -277,8 +275,4 @@ run-make/volatile-intrinsics/Makefile
277275
run-make/wasm-exceptions-nostd/Makefile
278276
run-make/wasm-override-linker/Makefile
279277
run-make/weird-output-filenames/Makefile
280-
run-make/windows-binary-no-external-deps/Makefile
281-
run-make/windows-safeseh/Makefile
282-
run-make/windows-spawn/Makefile
283-
run-make/windows-subsystem/Makefile
284278
run-make/x86_64-fortanix-unknown-sgx-lvi/Makefile

src/tools/tidy/src/ui_tests.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ use std::path::{Path, PathBuf};
1212
// should all be 1000 or lower. Limits significantly smaller than 1000 are also
1313
// desirable, because large numbers of files are unwieldy in general. See issue
1414
// #73494.
15-
const ENTRY_LIMIT: usize = 900;
15+
const ENTRY_LIMIT: u32 = 900;
1616
// FIXME: The following limits should be reduced eventually.
1717

18-
const ISSUES_ENTRY_LIMIT: usize = 1676;
18+
const ISSUES_ENTRY_LIMIT: u32 = 1676;
1919

2020
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
2121
"rs", // test source files
@@ -53,7 +53,7 @@ const EXTENSION_EXCEPTION_PATHS: &[&str] = &[
5353
];
5454

5555
fn check_entries(tests_path: &Path, bad: &mut bool) {
56-
let mut directories: HashMap<PathBuf, usize> = HashMap::new();
56+
let mut directories: HashMap<PathBuf, u32> = HashMap::new();
5757

5858
for dir in Walk::new(&tests_path.join("ui")) {
5959
if let Ok(entry) = dir {
@@ -62,7 +62,7 @@ fn check_entries(tests_path: &Path, bad: &mut bool) {
6262
}
6363
}
6464

65-
let (mut max, mut max_issues) = (0usize, 0usize);
65+
let (mut max, mut max_issues) = (0, 0);
6666
for (dir_path, count) in directories {
6767
let is_issues_dir = tests_path.join("ui/issues") == dir_path;
6868
let (limit, maxcnt) = if is_issues_dir {

tests/crashes/123255.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ known-bug: rust-lang/rust#123255
2+
//@ edition:2021
3+
#![crate_type = "lib"]
4+
5+
pub fn a() {}
6+
7+
mod handlers {
8+
pub struct C(&());
9+
pub fn c() -> impl Fn() -> C {
10+
let a1 = ();
11+
|| C((crate::a(), a1).into())
12+
}
13+
}

tests/crashes/123276.rs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//@ known-bug: rust-lang/rust#123276
2+
//@ edition:2021
3+
4+
async fn create_task() {
5+
_ = Some(async { bind(documentation_filter()) });
6+
}
7+
8+
async fn bind<Fut, F: Filter<Future = Fut>>(_: F) {}
9+
10+
fn documentation_filter() -> impl Filter {
11+
AndThen
12+
}
13+
14+
trait Filter {
15+
type Future;
16+
}
17+
18+
struct AndThen;
19+
20+
impl Filter for AndThen
21+
where
22+
Foo: Filter,
23+
{
24+
type Future = ();
25+
}

tests/crashes/123887.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ known-bug: rust-lang/rust#123887
2+
//@ compile-flags: -Clink-dead-code
3+
4+
#![feature(extern_types)]
5+
#![feature(unsized_fn_params)]
6+
7+
extern "C" {
8+
pub type ExternType;
9+
}
10+
11+
impl ExternType {
12+
pub fn f(self) {}
13+
}
14+
15+
pub fn main() {}

tests/crashes/125013-1.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//@ known-bug: rust-lang/rust#125013
2+
//@ edition:2021
3+
use io::{self as std};
4+
use std::ops::Deref::{self as io};
5+
pub fn main() {}

tests/crashes/125013-2.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@ known-bug: rust-lang/rust#125013
2+
//@ edition:2021
3+
mod a {
4+
pub mod b {
5+
pub mod c {
6+
pub trait D {}
7+
}
8+
}
9+
}
10+
11+
use a::*;
12+
13+
use e as b;
14+
use b::c::D as e;
15+
16+
fn main() { }

tests/crashes/125014.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@ known-bug: rust-lang/rust#125014
2+
//@ compile-flags: -Znext-solver=coherence
3+
#![feature(specialization)]
4+
5+
trait Foo {}
6+
7+
impl Foo for <u16 as Assoc>::Output {}
8+
9+
impl Foo for u32 {}
10+
11+
trait Assoc {
12+
type Output;
13+
}
14+
impl Output for u32 {}
15+
impl Assoc for <u16 as Assoc>::Output {
16+
default type Output = bool;
17+
}

tests/crashes/125059.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ known-bug: rust-lang/rust#125059
2+
#![feature(deref_patterns)]
3+
#![allow(incomplete_features)]
4+
5+
fn simple_vec(vec: Vec<u32>) -> u32 {
6+
(|| match Vec::<u32>::new() {
7+
deref!([]) => 100,
8+
_ => 2000,
9+
})()
10+
}
11+
12+
fn main() {}

tests/crashes/125323.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@ known-bug: rust-lang/rust#125323
2+
fn main() {
3+
for _ in 0..0 {
4+
[(); loop {}];
5+
}
6+
}

tests/crashes/125476.rs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//@ known-bug: rust-lang/rust#125476
2+
pub struct Data([u8; usize::MAX >> 16]);
3+
const _: &'static [Data] = &[];

tests/crashes/125512.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//@ known-bug: rust-lang/rust#125512
2+
//@ edition:2021
3+
#![feature(object_safe_for_dispatch)]
4+
trait B {
5+
fn f(a: A) -> A;
6+
}
7+
trait A {
8+
fn concrete(b: B) -> B;
9+
}
10+
fn main() {}

tests/crashes/125553.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ known-bug: rust-lang/rust#125553
2+
//@ edition:2021
3+
4+
#[derive(Copy, Clone)]
5+
struct Foo((u32, u32));
6+
7+
fn main() {
8+
type T = impl Copy(Copy, Clone)
9+
let foo: T = Foo((1u32, 1u32));
10+
let x = move || {
11+
let derive = move || {
12+
let Foo((a, b)) = foo;
13+
};
14+
};
15+
}

0 commit comments

Comments
 (0)