Skip to content

Commit 0d9a57d

Browse files
Rollup merge of #133470 - jieyouxu:ugly, r=compiler-errors
Cleanup: delete `//@ pretty-expanded` directive This PR removes the `//@ pretty-expanded` directive support in compiletest and removes its usage inside ui tests because it does not actually do anything, and its existence is itself misleading. This PR is split into two commits: 1. The first commit just drops `pretty-expanded` directive support in compiletest. 2. The second commit is created by `sd '//@ pretty-expanded.*\n' '' tests/ui/**/*.rs`[^1], reblessing, and slightly adjusting some leading whitespace in a few tests. We can tell this is fully removed because compiletest doesn't complain about unknown directive when running the `ui` test suite. cc #23616 ### History Originally, there was some effort to introduce more test coverage for `-Z unpretty=expanded` (in 2015 this was called `--pretty=expanded`). In [Make it an error to not declare used features #23598][pr-23598], there was a flip from `//@ no-pretty-expanded` (opt-out of `-Z unpretty=expanded` test) to `//@ pretty-expanded` (opt-in to `-Z unpretty=expanded` test). This was needed because back then the dedicated `tests/pretty` ("pretty") test suite did not existed, and the pretty tests were grouped together under `run-pass` tests (I believe the `ui` test suite didn't exist back then either). Unfortunately, in this process the replacement `//@ pretty-expanded` directives contained a `FIXME #23616` linking to [There are very few tests for `-Z unpretty` expansion #23616][issue-23616]. But this was arguably backwards and somewhat misleading, as noted in [#23616](#23616 (comment)): The attribute is off by default and things just work if you don't test it, people have not been adding the `pretty-expanded` annotation to new tests even if it would work. Which basically renders this useless. ### Current status As of Nov 2024, we have a dedicated `pretty` test suite, and some time over the years the split between `run-pass` into `ui` and `pretty` test suites caused all the `//@ pretty-expanded` in `ui` tests to do absolutely nothing: the compiletest logic for `pretty-expanded` only triggers in the *pretty* test suite, but none of the pretty tests use it. Oops. Nobody remembers this, nobody uses this, it's misleading in ui tests. Let's get rid of this directive altogether. [pr-23598]: #23598 [issue-23616]: #23616 ### Follow-ups - [x] Yeet this directive from rustc-dev-guide docs. rust-lang/rustc-dev-guide#2147 [^1]: https://github.com/chmln/sd r? compiler
2 parents c8c225f + 95ff642 commit 0d9a57d

File tree

659 files changed

+23
-684
lines changed

Some content is hidden

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

659 files changed

+23
-684
lines changed

src/tools/compiletest/src/directive-list.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
214214
"only-x86_64-unknown-linux-gnu",
215215
"pp-exact",
216216
"pretty-compare-only",
217-
"pretty-expanded",
218217
"pretty-mode",
219218
"reference",
220219
"regex-error-pattern",

src/tools/compiletest/src/header.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ pub struct TestProps {
124124
// a proc-macro and needs `#![crate_type = "proc-macro"]`. This ensures
125125
// that the aux file is compiled as a `proc-macro` and not as a `dylib`.
126126
pub no_prefer_dynamic: bool,
127-
// Run -Zunpretty expanded when running pretty printing tests
128-
pub pretty_expanded: bool,
129127
// Which pretty mode are we testing with, default to 'normal'
130128
pub pretty_mode: String,
131129
// Only compare pretty output and don't try compiling
@@ -218,7 +216,6 @@ mod directives {
218216
pub const DONT_CHECK_COMPILER_STDOUT: &'static str = "dont-check-compiler-stdout";
219217
pub const DONT_CHECK_COMPILER_STDERR: &'static str = "dont-check-compiler-stderr";
220218
pub const NO_PREFER_DYNAMIC: &'static str = "no-prefer-dynamic";
221-
pub const PRETTY_EXPANDED: &'static str = "pretty-expanded";
222219
pub const PRETTY_MODE: &'static str = "pretty-mode";
223220
pub const PRETTY_COMPARE_ONLY: &'static str = "pretty-compare-only";
224221
pub const AUX_BIN: &'static str = "aux-bin";
@@ -278,7 +275,6 @@ impl TestProps {
278275
dont_check_compiler_stderr: false,
279276
compare_output_lines_by_subset: false,
280277
no_prefer_dynamic: false,
281-
pretty_expanded: false,
282278
pretty_mode: "normal".to_string(),
283279
pretty_compare_only: false,
284280
forbid_output: vec![],
@@ -425,7 +421,6 @@ impl TestProps {
425421
&mut self.dont_check_compiler_stderr,
426422
);
427423
config.set_name_directive(ln, NO_PREFER_DYNAMIC, &mut self.no_prefer_dynamic);
428-
config.set_name_directive(ln, PRETTY_EXPANDED, &mut self.pretty_expanded);
429424

430425
if let Some(m) = config.parse_name_value_directive(ln, PRETTY_MODE) {
431426
self.pretty_mode = m;

src/tools/compiletest/src/runtest/pretty.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,5 @@ impl TestCx<'_> {
8484
if !proc_res.status.success() {
8585
self.fatal_proc_rec("pretty-printed source does not typecheck", &proc_res);
8686
}
87-
88-
if !self.props.pretty_expanded {
89-
return;
90-
}
91-
92-
// additionally, run `-Zunpretty=expanded` and try to build it.
93-
let proc_res = self.print_source(ReadFrom::Path, "expanded");
94-
if !proc_res.status.success() {
95-
self.fatal_proc_rec("pretty-printing (expanded) failed", &proc_res);
96-
}
97-
98-
let ProcRes { stdout: expanded_src, .. } = proc_res;
99-
let proc_res = self.typecheck_source(expanded_src);
100-
if !proc_res.status.success() {
101-
self.fatal_proc_rec("pretty-printed source (expanded) does not typecheck", &proc_res);
102-
}
10387
}
10488
}

tests/ui/abi/anon-extern-mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ run-pass
2-
//@ pretty-expanded FIXME #23616
32

43
#[link(name = "rust_test_helpers", kind = "static")]
54
extern "C" {

tests/ui/abi/c-stack-as-value.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ run-pass
2-
//@ pretty-expanded FIXME #23616
32

43
mod rustrt {
54
#[link(name = "rust_test_helpers", kind = "static")]

tests/ui/abi/cross-crate/anon-extern-mod-cross-crate-2.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//@ run-pass
22
//@ aux-build:anon-extern-mod-cross-crate-1.rs
3-
//@ pretty-expanded FIXME #23616
43

54
extern crate anonexternmod;
65

tests/ui/abi/cross-crate/duplicated-external-mods.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@ run-pass
22
//@ aux-build:anon-extern-mod-cross-crate-1.rs
33
//@ aux-build:anon-extern-mod-cross-crate-1.rs
4-
//@ pretty-expanded FIXME #23616
54

65
extern crate anonexternmod;
76

tests/ui/abi/extern/extern-pass-empty.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
// Test a foreign function that accepts empty struct.
55

6-
//@ pretty-expanded FIXME #23616
76
//@ ignore-msvc
87
//@ ignore-emscripten emcc asserts on an empty struct as an argument
98

tests/ui/abi/foreign/invoke-external-foreign.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// successfully (and safely) invoke external, cdecl
66
// functions from outside the crate.
77

8-
//@ pretty-expanded FIXME #23616
98

109
extern crate foreign_lib;
1110

tests/ui/alias-uninit-value.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
// Regression test for issue #374
99

10-
//@ pretty-expanded FIXME #23616
1110

1211
enum sty { ty_nil, }
1312

0 commit comments

Comments
 (0)