Skip to content

Commit cc5a24c

Browse files
authored
Rollup merge of rust-lang#131355 - clubby789:old-tests, r=jieyouxu
Add tests for some old fixed issues Closes rust-lang#30867 Closes rust-lang#30472 Closes rust-lang#28994 Closes rust-lang#26719 (and migrates the relevant test to the new run-make) Closes rust-lang#23600 cc `@jieyouxu` for the run-make-support changes try-job: x86_64-msvc
2 parents e416a9c + 382365b commit cc5a24c

File tree

9 files changed

+166
-53
lines changed

9 files changed

+166
-53
lines changed

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

+24
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,30 @@ macro_rules! impl_common_helpers {
7070
self
7171
}
7272

73+
/// Configuration for the child process’s standard input (stdin) handle.
74+
///
75+
/// See [`std::process::Command::stdin`].
76+
pub fn stdin<T: Into<::std::process::Stdio>>(&mut self, cfg: T) -> &mut Self {
77+
self.cmd.stdin(cfg);
78+
self
79+
}
80+
81+
/// Configuration for the child process’s standard output (stdout) handle.
82+
///
83+
/// See [`std::process::Command::stdout`].
84+
pub fn stdout<T: Into<::std::process::Stdio>>(&mut self, cfg: T) -> &mut Self {
85+
self.cmd.stdout(cfg);
86+
self
87+
}
88+
89+
/// Configuration for the child process’s standard error (stderr) handle.
90+
///
91+
/// See [`std::process::Command::stderr`].
92+
pub fn stderr<T: Into<::std::process::Stdio>>(&mut self, cfg: T) -> &mut Self {
93+
self.cmd.stderr(cfg);
94+
self
95+
}
96+
7397
/// Inspect what the underlying [`Command`] is up to the
7498
/// current construction.
7599
pub fn inspect<I>(&mut self, inspector: I) -> &mut Self

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
run-make/branch-protection-check-IBT/Makefile
22
run-make/cat-and-grep-sanity-check/Makefile
3-
run-make/emit-to-stdout/Makefile
43
run-make/extern-fn-reachable/Makefile
54
run-make/incr-add-rust-src-component/Makefile
65
run-make/issue-84395-lto-embed-bitcode/Makefile

src/tools/tidy/src/issues.txt

-1
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,6 @@ ui/consts/issue-70942-trait-vs-impl-mismatch.rs
802802
ui/consts/issue-73976-monomorphic.rs
803803
ui/consts/issue-73976-polymorphic.rs
804804
ui/consts/issue-76064.rs
805-
ui/consts/issue-77062-large-zst-array.rs
806805
ui/consts/issue-78655.rs
807806
ui/consts/issue-79137-monomorphic.rs
808807
ui/consts/issue-79137-toogeneric.rs

tests/run-make/emit-to-stdout/Makefile

-51
This file was deleted.
+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
//! If `-o -` or `--emit KIND=-` is provided, output should be written to stdout
2+
//! instead. Binary output (`obj`, `llvm-bc`, `link` and `metadata`)
3+
//! being written this way will result in an error if stdout is a tty.
4+
//! Multiple output types going to stdout will trigger an error too,
5+
//! as they would all be mixed together.
6+
//!
7+
//! See <https://github.com/rust-lang/rust/pull/111626>.
8+
9+
use std::fs::File;
10+
11+
use run_make_support::{diff, run_in_tmpdir, rustc};
12+
13+
// Test emitting text outputs to stdout works correctly
14+
fn run_diff(name: &str, file_args: &[&str]) {
15+
rustc().emit(format!("{name}={name}")).input("test.rs").args(file_args).run();
16+
let out = rustc().emit(format!("{name}=-")).input("test.rs").run().stdout_utf8();
17+
diff().expected_file(name).actual_text("stdout", &out).run();
18+
}
19+
20+
// Test that emitting binary formats to a terminal gives the correct error
21+
fn run_terminal_err_diff(name: &str) {
22+
#[cfg(not(windows))]
23+
let terminal = File::create("/dev/ptmx").unwrap();
24+
// FIXME: If this test fails and the compiler does print to the console,
25+
// then this will produce a lot of output.
26+
// We should spawn a new console instead to print stdout.
27+
#[cfg(windows)]
28+
let terminal = File::options().read(true).write(true).open(r"\\.\CONOUT$").unwrap();
29+
30+
let err = File::create(name).unwrap();
31+
rustc().emit(format!("{name}=-")).input("test.rs").stdout(terminal).stderr(err).run_fail();
32+
diff().expected_file(format!("emit-{name}.stderr")).actual_file(name).run();
33+
}
34+
35+
fn main() {
36+
run_in_tmpdir(|| {
37+
run_diff("asm", &[]);
38+
run_diff("llvm-ir", &[]);
39+
run_diff("dep-info", &["-Zdep-info-omit-d-target=yes"]);
40+
run_diff("mir", &[]);
41+
42+
run_terminal_err_diff("llvm-bc");
43+
run_terminal_err_diff("obj");
44+
run_terminal_err_diff("metadata");
45+
run_terminal_err_diff("link");
46+
47+
// Test error for emitting multiple types to stdout
48+
rustc()
49+
.input("test.rs")
50+
.emit("asm=-")
51+
.emit("llvm-ir=-")
52+
.emit("dep-info=-")
53+
.emit("mir=-")
54+
.stderr(File::create("multiple-types").unwrap())
55+
.run_fail();
56+
diff().expected_file("emit-multiple-types.stderr").actual_file("multiple-types").run();
57+
58+
// Same as above, but using `-o`
59+
rustc()
60+
.input("test.rs")
61+
.output("-")
62+
.emit("asm,llvm-ir,dep-info,mir")
63+
.stderr(File::create("multiple-types-option-o").unwrap())
64+
.run_fail();
65+
diff()
66+
.expected_file("emit-multiple-types.stderr")
67+
.actual_file("multiple-types-option-o")
68+
.run();
69+
70+
// Test that `-o -` redirected to a file works correctly (#26719)
71+
rustc().input("test.rs").output("-").stdout(File::create("out-stdout").unwrap()).run();
72+
});
73+
}

tests/ui/consts/issue-77062-large-zst-array.rs tests/ui/consts/large-zst-array-77062.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ build-pass
2+
pub static FOO: [(); usize::MAX] = [(); usize::MAX];
23

34
fn main() {
45
let _ = &[(); usize::MAX];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//@ check-pass
2+
//! Tests that associated type projections normalize properly in the presence of HRTBs.
3+
//! Original issue: <https://github.com/rust-lang/rust/issues/30472>
4+
5+
6+
pub trait MyFrom<T> {}
7+
impl<T> MyFrom<T> for T {}
8+
9+
pub trait MyInto<T> {}
10+
impl<T, U> MyInto<U> for T where U: MyFrom<T> {}
11+
12+
13+
pub trait A<'self_> {
14+
type T;
15+
}
16+
pub trait B: for<'self_> A<'self_> {
17+
// Originally caused the `type U = usize` example below to fail with a type mismatch error
18+
type U: for<'self_> MyFrom<<Self as A<'self_>>::T>;
19+
}
20+
21+
22+
pub struct M;
23+
impl<'self_> A<'self_> for M {
24+
type T = usize;
25+
}
26+
27+
impl B for M {
28+
type U = usize;
29+
}
30+
31+
32+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//@ check-pass
2+
//! Tests that a HRTB + FnOnce bound involving an associated type don't prevent
3+
//! a function pointer from implementing `Fn` traits.
4+
//! Test for <https://github.com/rust-lang/rust/issues/28994>
5+
6+
trait LifetimeToType<'a> {
7+
type Out;
8+
}
9+
10+
impl<'a> LifetimeToType<'a> for () {
11+
type Out = &'a ();
12+
}
13+
14+
fn id<'a>(val: &'a ()) -> <() as LifetimeToType<'a>>::Out {
15+
val
16+
}
17+
18+
fn assert_fn<F: for<'a> FnOnce(&'a ()) -> <() as LifetimeToType<'a>>::Out>(_func: F) { }
19+
20+
fn main() {
21+
assert_fn(id);
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ check-pass
2+
//! Tests that HRTB impl selection covers type parameters not directly related
3+
//! to the trait.
4+
//! Test for <https://github.com/rust-lang/rust/issues/30867>
5+
6+
#![crate_type = "lib"]
7+
8+
trait Unary<T> {}
9+
impl<T, U, F: Fn(T) -> U> Unary<T> for F {}
10+
fn unary<F: for<'a> Unary<&'a T>, T>() {}
11+
12+
pub fn test<F: for<'a> Fn(&'a i32) -> &'a i32>() {
13+
unary::<F, i32>()
14+
}

0 commit comments

Comments
 (0)