Skip to content

Commit

Permalink
Rollup merge of rust-lang#133470 - jieyouxu:ugly, r=compiler-errors
Browse files Browse the repository at this point in the history
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 rust-lang#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 rust-lang#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 rust-lang#23616` linking to [There are very few tests for `-Z unpretty` expansion rust-lang#23616][issue-23616]. But this was arguably backwards and somewhat misleading, as noted in [rust-lang#23616](rust-lang#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]: rust-lang#23598
[issue-23616]: rust-lang#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
  • Loading branch information
GuillaumeGomez authored Nov 26, 2024
2 parents c8c225f + 95ff642 commit 0d9a57d
Show file tree
Hide file tree
Showing 659 changed files with 23 additions and 684 deletions.
1 change: 0 additions & 1 deletion src/tools/compiletest/src/directive-list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"only-x86_64-unknown-linux-gnu",
"pp-exact",
"pretty-compare-only",
"pretty-expanded",
"pretty-mode",
"reference",
"regex-error-pattern",
Expand Down
5 changes: 0 additions & 5 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ pub struct TestProps {
// a proc-macro and needs `#![crate_type = "proc-macro"]`. This ensures
// that the aux file is compiled as a `proc-macro` and not as a `dylib`.
pub no_prefer_dynamic: bool,
// Run -Zunpretty expanded when running pretty printing tests
pub pretty_expanded: bool,
// Which pretty mode are we testing with, default to 'normal'
pub pretty_mode: String,
// Only compare pretty output and don't try compiling
Expand Down Expand Up @@ -218,7 +216,6 @@ mod directives {
pub const DONT_CHECK_COMPILER_STDOUT: &'static str = "dont-check-compiler-stdout";
pub const DONT_CHECK_COMPILER_STDERR: &'static str = "dont-check-compiler-stderr";
pub const NO_PREFER_DYNAMIC: &'static str = "no-prefer-dynamic";
pub const PRETTY_EXPANDED: &'static str = "pretty-expanded";
pub const PRETTY_MODE: &'static str = "pretty-mode";
pub const PRETTY_COMPARE_ONLY: &'static str = "pretty-compare-only";
pub const AUX_BIN: &'static str = "aux-bin";
Expand Down Expand Up @@ -278,7 +275,6 @@ impl TestProps {
dont_check_compiler_stderr: false,
compare_output_lines_by_subset: false,
no_prefer_dynamic: false,
pretty_expanded: false,
pretty_mode: "normal".to_string(),
pretty_compare_only: false,
forbid_output: vec![],
Expand Down Expand Up @@ -425,7 +421,6 @@ impl TestProps {
&mut self.dont_check_compiler_stderr,
);
config.set_name_directive(ln, NO_PREFER_DYNAMIC, &mut self.no_prefer_dynamic);
config.set_name_directive(ln, PRETTY_EXPANDED, &mut self.pretty_expanded);

if let Some(m) = config.parse_name_value_directive(ln, PRETTY_MODE) {
self.pretty_mode = m;
Expand Down
16 changes: 0 additions & 16 deletions src/tools/compiletest/src/runtest/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,5 @@ impl TestCx<'_> {
if !proc_res.status.success() {
self.fatal_proc_rec("pretty-printed source does not typecheck", &proc_res);
}

if !self.props.pretty_expanded {
return;
}

// additionally, run `-Zunpretty=expanded` and try to build it.
let proc_res = self.print_source(ReadFrom::Path, "expanded");
if !proc_res.status.success() {
self.fatal_proc_rec("pretty-printing (expanded) failed", &proc_res);
}

let ProcRes { stdout: expanded_src, .. } = proc_res;
let proc_res = self.typecheck_source(expanded_src);
if !proc_res.status.success() {
self.fatal_proc_rec("pretty-printed source (expanded) does not typecheck", &proc_res);
}
}
}
1 change: 0 additions & 1 deletion tests/ui/abi/anon-extern-mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616

#[link(name = "rust_test_helpers", kind = "static")]
extern "C" {
Expand Down
1 change: 0 additions & 1 deletion tests/ui/abi/c-stack-as-value.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616

mod rustrt {
#[link(name = "rust_test_helpers", kind = "static")]
Expand Down
1 change: 0 additions & 1 deletion tests/ui/abi/cross-crate/anon-extern-mod-cross-crate-2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@ run-pass
//@ aux-build:anon-extern-mod-cross-crate-1.rs
//@ pretty-expanded FIXME #23616

extern crate anonexternmod;

Expand Down
1 change: 0 additions & 1 deletion tests/ui/abi/cross-crate/duplicated-external-mods.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@ run-pass
//@ aux-build:anon-extern-mod-cross-crate-1.rs
//@ aux-build:anon-extern-mod-cross-crate-1.rs
//@ pretty-expanded FIXME #23616

extern crate anonexternmod;

Expand Down
1 change: 0 additions & 1 deletion tests/ui/abi/extern/extern-pass-empty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

// Test a foreign function that accepts empty struct.

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

Expand Down
1 change: 0 additions & 1 deletion tests/ui/abi/foreign/invoke-external-foreign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// successfully (and safely) invoke external, cdecl
// functions from outside the crate.

//@ pretty-expanded FIXME #23616

extern crate foreign_lib;

Expand Down
1 change: 0 additions & 1 deletion tests/ui/alias-uninit-value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

// Regression test for issue #374

//@ pretty-expanded FIXME #23616

enum sty { ty_nil, }

Expand Down
1 change: 0 additions & 1 deletion tests/ui/array-slice-vec/cast-in-array-size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


// issues #10618 and #16382
//@ pretty-expanded FIXME #23616

const SIZE: isize = 25;

Expand Down
1 change: 0 additions & 1 deletion tests/ui/array-slice-vec/empty-mutable-vec.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@ run-pass

//@ pretty-expanded FIXME #23616

#![allow(unused_mut)]

Expand Down
1 change: 0 additions & 1 deletion tests/ui/array-slice-vec/issue-15730.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@ run-pass
#![allow(unused_mut)]
#![allow(unused_variables)]
//@ pretty-expanded FIXME #23616

fn main() {
let mut array = [1, 2, 3];
Expand Down
1 change: 0 additions & 1 deletion tests/ui/array-slice-vec/issue-18425.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Check that codegen doesn't ICE when codegenning an array repeat
// expression with a count of 1 and a non-Copy element type.

//@ pretty-expanded FIXME #23616

fn main() {
let _ = [Box::new(1_usize); 1];
Expand Down
1 change: 0 additions & 1 deletion tests/ui/array-slice-vec/mut-vstore-expr.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616

pub fn main() {
let _x: &mut [isize] = &mut [ 1, 2, 3 ];
Expand Down
1 change: 0 additions & 1 deletion tests/ui/array-slice-vec/vec-macro-with-brackets.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@ run-pass
#![allow(unused_variables)]

//@ pretty-expanded FIXME #23616

macro_rules! vec [
($($e:expr),*) => ({
Expand Down
1 change: 0 additions & 1 deletion tests/ui/array-slice-vec/vec-repeat-with-cast.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ run-pass

//@ pretty-expanded FIXME #23616

pub fn main() { let _a = [0; 1 as usize]; }
1 change: 0 additions & 1 deletion tests/ui/array-slice-vec/vector-no-ann-2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@ run-pass

//@ pretty-expanded FIXME #23616

pub fn main() {
let _quux: Box<Vec<usize>> = Box::new(Vec::new());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@ run-pass
// Test equality constraints on associated types in a where clause.

//@ pretty-expanded FIXME #23616

pub trait Foo {
type A;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// `Target=[A]`, then the impl marked with `(*)` is seen to conflict
// with all the others.

//@ pretty-expanded FIXME #23616

use std::marker::PhantomData;
use std::ops::Deref;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// (modulo bound lifetime names) appears in the environment
// twice. Issue #21965.

//@ pretty-expanded FIXME #23616

fn foo<T>(t: T) -> i32
where T : for<'a> Fn(&'a u8) -> i32,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Check that we do not report ambiguities when the same predicate
// appears in the environment twice. Issue #21965.

//@ pretty-expanded FIXME #23616

trait Foo {
type B;
Expand Down
1 change: 0 additions & 1 deletion tests/ui/associated-types/associated-types-eq-obj.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@ run-pass
// Test equality constraints on associated types inside of an object type

//@ pretty-expanded FIXME #23616

pub trait Foo {
type A;
Expand Down
1 change: 0 additions & 1 deletion tests/ui/associated-types/associated-types-issue-20371.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Test that we are able to have an impl that defines an associated type
// before the actual trait.

//@ pretty-expanded FIXME #23616

impl X for f64 { type Y = isize; }
trait X { type Y; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#![allow(unused_variables)]
// Test that we can resolve nested projection types. Issue #20666.

//@ pretty-expanded FIXME #23616

use std::slice;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: method `into_iter` is never used
--> $DIR/associated-types-nested-projections.rs:16:8
--> $DIR/associated-types-nested-projections.rs:15:8
|
LL | trait IntoIterator {
| ------------ method in this trait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Test that we normalize associated types that appear in a bound that
// contains a binding. Issue #21664.

//@ pretty-expanded FIXME #23616

#![allow(dead_code)]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Test that we normalize associated types that appear in bounds; if
// we didn't, the call to `self.split2()` fails to type check.

//@ pretty-expanded FIXME #23616

use std::marker::PhantomData;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Test that we normalize associated types that appear in bounds; if
// we didn't, the call to `self.split2()` fails to type check.

//@ pretty-expanded FIXME #23616

use std::marker::PhantomData;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// appear in associated type bindings in object types, which were not
// being properly flagged.

//@ pretty-expanded FIXME #23616

use std::ops::{Shl, Shr};
use std::cell::RefCell;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#![allow(unused_variables)]
// Test a where clause that uses a non-normalized projection type.

//@ pretty-expanded FIXME #23616

trait Int
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ check-pass
//@ pretty-expanded FIXME #23616

trait Foo<T> {
type Bar;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@ run-pass
// Test associated type references in structure fields.

//@ pretty-expanded FIXME #23616

trait Test {
type V;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Regression test for #20582. This test caused an ICE related to
// inconsistent region erasure in codegen.

//@ pretty-expanded FIXME #23616

struct Foo<'a> {
buf: &'a[u8]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ check-pass
//@ pretty-expanded FIXME #23616

trait Get<T> {
fn get(&self) -> T;
Expand Down
1 change: 0 additions & 1 deletion tests/ui/associated-types/issue-19129-1.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ check-pass
//@ pretty-expanded FIXME #23616

trait Trait<Input> {
type Output;
Expand Down
1 change: 0 additions & 1 deletion tests/ui/associated-types/issue-19129-2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@ check-pass
#![allow(unused_variables)]
//@ pretty-expanded FIXME #23616

trait Trait<Input> {
type Output;
Expand Down
1 change: 0 additions & 1 deletion tests/ui/associated-types/issue-20763-1.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@ check-pass
#![allow(dead_code)]
//@ pretty-expanded FIXME #23616

trait T0 {
type O;
Expand Down
1 change: 0 additions & 1 deletion tests/ui/associated-types/issue-20763-2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@ check-pass
#![allow(dead_code)]
//@ pretty-expanded FIXME #23616

trait T0 {
type O;
Expand Down
1 change: 0 additions & 1 deletion tests/ui/associated-types/issue-21363.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ check-pass
//@ pretty-expanded FIXME #23616

#![no_implicit_prelude]

Expand Down
1 change: 0 additions & 1 deletion tests/ui/associated-types/issue-21726.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// subtyping of projection types that resulted in an unconstrained
// region, yielding region inference failures.

//@ pretty-expanded FIXME #23616

fn main() { }

Expand Down
1 change: 0 additions & 1 deletion tests/ui/associated-types/issue-22828.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Test transitive analysis for associated types. Collected types
// should be normalized and new obligations generated.

//@ pretty-expanded FIXME #23616

trait Foo {
type A;
Expand Down
1 change: 0 additions & 1 deletion tests/ui/attr-start.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616

#![feature(start)]

Expand Down
1 change: 0 additions & 1 deletion tests/ui/attributes/attr-before-view-item.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ build-pass (FIXME(62277): could be check-pass?)
//@ pretty-expanded FIXME #23616

#![feature(rustc_attrs)]
#![feature(test)]
Expand Down
1 change: 0 additions & 1 deletion tests/ui/attributes/attr-before-view-item2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ build-pass (FIXME(62277): could be check-pass?)
//@ pretty-expanded FIXME #23616

#![feature(rustc_attrs)]
#![feature(test)]
Expand Down
1 change: 0 additions & 1 deletion tests/ui/attributes/attr-mix-new.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ build-pass (FIXME(62277): could be check-pass?)
//@ pretty-expanded FIXME #23616

#![feature(rustc_attrs)]

Expand Down
1 change: 0 additions & 1 deletion tests/ui/attributes/method-attributes.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@ build-pass (FIXME(62277): could be check-pass?)
//@ pp-exact - Make sure we print all the attributes
//@ pretty-expanded FIXME #23616

#![feature(rustc_attrs)]

Expand Down
1 change: 0 additions & 1 deletion tests/ui/attributes/variant-attributes.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@ build-pass (FIXME(62277): could be check-pass?)
//@ pp-exact - Make sure we actually print the attributes
//@ pretty-expanded FIXME #23616

#![allow(non_camel_case_types)]
#![feature(rustc_attrs)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@ run-pass
#![allow(dead_code)]
//@ pretty-expanded FIXME #23616

struct Foo {
x: isize,
Expand Down
Loading

0 comments on commit 0d9a57d

Please sign in to comment.