Skip to content

Commit cc5a24c

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

9 files changed

Lines changed: 166 additions & 53 deletions

File tree

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

Lines changed: 24 additions & 0 deletions
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+
pubfn stdin<T:Into<::std::process::Stdio>>(&mutself, cfg:T) -> &mutSelf{
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+
pubfn stdout<T:Into<::std::process::Stdio>>(&mutself, cfg:T) -> &mutSelf{
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+
pubfn stderr<T:Into<::std::process::Stdio>>(&mutself, cfg:T) -> &mutSelf{
93+
self.cmd.stderr(cfg);
94+
self
95+
}
96+
7397
/// Inspect what the underlying [`Command`] is up to the
7498
/// current construction.
7599
pubfn inspect<I>(&mutself, inspector:I) -> &mutSelf

‎src/tools/tidy/src/allowed_run_make_makefiles.txt‎

Lines changed: 0 additions & 1 deletion
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‎

Lines changed: 0 additions & 1 deletion
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‎

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 73 additions & 0 deletions
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+
fnrun_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+
fnrun_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+
fnmain(){
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 renamed to tests/ui/consts/large-zst-array-77062.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ build-pass
2+
pubstaticFOO:[(); usize::MAX] = [(); usize::MAX];
23

34
fnmain(){
45
let _ = &[(); usize::MAX];
Lines changed: 32 additions & 0 deletions
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+
pubtraitMyFrom<T>{}
7+
impl<T>MyFrom<T>forT{}
8+
9+
pubtraitMyInto<T>{}
10+
impl<T,U>MyInto<U>forTwhereU:MyFrom<T>{}
11+
12+
13+
pubtraitA<'self_>{
14+
typeT;
15+
}
16+
pubtraitB:for<'self_>A<'self_>{
17+
// Originally caused the `type U = usize` example below to fail with a type mismatch error
18+
typeU:for<'self_>MyFrom<<SelfasA<'self_>>::T>;
19+
}
20+
21+
22+
pubstructM;
23+
impl<'self_>A<'self_>forM{
24+
typeT = usize;
25+
}
26+
27+
implBforM{
28+
typeU = usize;
29+
}
30+
31+
32+
fnmain(){}
Lines changed: 22 additions & 0 deletions
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+
traitLifetimeToType<'a>{
7+
typeOut;
8+
}
9+
10+
impl<'a>LifetimeToType<'a>for(){
11+
typeOut = &'a();
12+
}
13+
14+
fnid<'a>(val:&'a()) -> <()asLifetimeToType<'a>>::Out{
15+
val
16+
}
17+
18+
fnassert_fn<F:for<'a>FnOnce(&'a()) -> <()asLifetimeToType<'a>>::Out>(_func:F){}
19+
20+
fnmain(){
21+
assert_fn(id);
22+
}
Lines changed: 14 additions & 0 deletions
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+
traitUnary<T>{}
9+
impl<T,U,F:Fn(T) -> U>Unary<T>forF{}
10+
fnunary<F:for<'a>Unary<&'aT>,T>(){}
11+
12+
pubfntest<F:for<'a>Fn(&'ai32) -> &'ai32>(){
13+
unary::<F,i32>()
14+
}

0 commit comments

Comments
 (0)