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](https://github.com/rust-lang/rust/issues/23616#issuecomment-484999901):

    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]: https://github.com/rust-lang/rust/pull/23598
[issue-23616]: https://github.com/rust-lang/rust/issues/23616

### Follow-ups

- [x] Yeet this directive from rustc-dev-guide docs. https://github.com/rust-lang/rustc-dev-guide/pull/2147

[^1]: https://github.com/chmln/sd

r? compiler
This commit is contained in:
Guillaume Gomez 2024-11-26 15:32:18 +01:00 committed by GitHub
commit 0d9a57d979
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
659 changed files with 23 additions and 684 deletions

View File

@ -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",

View File

@ -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
@ -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";
@ -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![],
@ -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;

View File

@ -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);
}
}
}

View File

@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
#[link(name = "rust_test_helpers", kind = "static")]
extern "C" {

View File

@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
mod rustrt {
#[link(name = "rust_test_helpers", kind = "static")]

View File

@ -1,6 +1,5 @@
//@ run-pass
//@ aux-build:anon-extern-mod-cross-crate-1.rs
//@ pretty-expanded FIXME #23616
extern crate anonexternmod;

View File

@ -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;

View File

@ -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

View File

@ -5,7 +5,6 @@
// successfully (and safely) invoke external, cdecl
// functions from outside the crate.
//@ pretty-expanded FIXME #23616
extern crate foreign_lib;

View File

@ -7,7 +7,6 @@
// Regression test for issue #374
//@ pretty-expanded FIXME #23616
enum sty { ty_nil, }

View File

@ -2,7 +2,6 @@
// issues #10618 and #16382
//@ pretty-expanded FIXME #23616
const SIZE: isize = 25;

View File

@ -1,6 +1,5 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
#![allow(unused_mut)]

View File

@ -1,7 +1,6 @@
//@ run-pass
#![allow(unused_mut)]
#![allow(unused_variables)]
//@ pretty-expanded FIXME #23616
fn main() {
let mut array = [1, 2, 3];

View File

@ -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];

View File

@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
pub fn main() {
let _x: &mut [isize] = &mut [ 1, 2, 3 ];

View File

@ -1,7 +1,6 @@
//@ run-pass
#![allow(unused_variables)]
//@ pretty-expanded FIXME #23616
macro_rules! vec [
($($e:expr),*) => ({

View File

@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
pub fn main() { let _a = [0; 1 as usize]; }

View File

@ -1,6 +1,5 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
pub fn main() {
let _quux: Box<Vec<usize>> = Box::new(Vec::new());

View File

@ -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;

View File

@ -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;

View File

@ -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,

View File

@ -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;

View File

@ -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;

View File

@ -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; }

View File

@ -2,7 +2,6 @@
#![allow(unused_variables)]
// Test that we can resolve nested projection types. Issue #20666.
//@ pretty-expanded FIXME #23616
use std::slice;

View File

@ -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

View File

@ -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)]

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -3,7 +3,6 @@
#![allow(unused_variables)]
// Test a where clause that uses a non-normalized projection type.
//@ pretty-expanded FIXME #23616
trait Int
{

View File

@ -1,5 +1,4 @@
//@ check-pass
//@ pretty-expanded FIXME #23616
trait Foo<T> {
type Bar;

View File

@ -1,7 +1,6 @@
//@ run-pass
// Test associated type references in structure fields.
//@ pretty-expanded FIXME #23616
trait Test {
type V;

View File

@ -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]

View File

@ -1,5 +1,4 @@
//@ check-pass
//@ pretty-expanded FIXME #23616
trait Get<T> {
fn get(&self) -> T;

View File

@ -1,5 +1,4 @@
//@ check-pass
//@ pretty-expanded FIXME #23616
trait Trait<Input> {
type Output;

View File

@ -1,6 +1,5 @@
//@ check-pass
#![allow(unused_variables)]
//@ pretty-expanded FIXME #23616
trait Trait<Input> {
type Output;

View File

@ -1,6 +1,5 @@
//@ check-pass
#![allow(dead_code)]
//@ pretty-expanded FIXME #23616
trait T0 {
type O;

View File

@ -1,6 +1,5 @@
//@ check-pass
#![allow(dead_code)]
//@ pretty-expanded FIXME #23616
trait T0 {
type O;

View File

@ -1,5 +1,4 @@
//@ check-pass
//@ pretty-expanded FIXME #23616
#![no_implicit_prelude]

View File

@ -4,7 +4,6 @@
// subtyping of projection types that resulted in an unconstrained
// region, yielding region inference failures.
//@ pretty-expanded FIXME #23616
fn main() { }

View File

@ -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;

View File

@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
#![feature(start)]

View File

@ -1,5 +1,4 @@
//@ build-pass (FIXME(62277): could be check-pass?)
//@ pretty-expanded FIXME #23616
#![feature(rustc_attrs)]
#![feature(test)]

View File

@ -1,5 +1,4 @@
//@ build-pass (FIXME(62277): could be check-pass?)
//@ pretty-expanded FIXME #23616
#![feature(rustc_attrs)]
#![feature(test)]

View File

@ -1,5 +1,4 @@
//@ build-pass (FIXME(62277): could be check-pass?)
//@ pretty-expanded FIXME #23616
#![feature(rustc_attrs)]

View File

@ -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)]

View File

@ -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)]

View File

@ -1,6 +1,5 @@
//@ run-pass
#![allow(dead_code)]
//@ pretty-expanded FIXME #23616
struct Foo {
x: isize,

View File

@ -1,6 +1,5 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
fn main() {
let _ = test(Some(0).into_iter());

View File

@ -1,6 +1,5 @@
//@ run-pass
#![allow(dead_code)]
//@ pretty-expanded FIXME #23616
fn foo(_: &[&str]) {}

View File

@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
struct X { x: isize }

View File

@ -1,6 +1,5 @@
//@ run-pass
#![allow(dead_code)]
//@ pretty-expanded FIXME #23616
struct X { x: isize }

View File

@ -3,7 +3,6 @@
#![allow(non_camel_case_types)]
//@ pretty-expanded FIXME #23616
mod m1 {
pub enum foo { foo1, foo2, }

View File

@ -2,7 +2,6 @@
#![allow(dead_code)]
//@ pretty-expanded FIXME #23616
fn altsimple(f: isize) { match f { _x => () } }

View File

@ -1,7 +1,6 @@
//@ run-pass
#![allow(dead_code)]
#![allow(unused_assignments)]
//@ pretty-expanded FIXME #23616
#![allow(non_camel_case_types)]
#![allow(unused_variables)]

View File

@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
#![allow(non_upper_case_globals)]
const s: isize = 1;

View File

@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
fn foo(x: Option<Box<isize>>, b: bool) -> isize {
match x {

View File

@ -1,4 +1,3 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
pub fn main() { let x = (); match x { () => { } } }

View File

@ -1,7 +1,6 @@
//@ run-pass
#![allow(non_camel_case_types)]
//@ pretty-expanded FIXME #23616
enum clam<T> { a(#[allow(dead_code)] T), }

View File

@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
pub fn main() {
struct A {

View File

@ -7,7 +7,6 @@
//
// Example from compiler/rustc_borrowck/borrowck/README.md
//@ pretty-expanded FIXME #23616
fn foo<'a>(mut t0: &'a mut isize,
mut t1: &'a mut isize) {

View File

@ -2,7 +2,6 @@
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dropping_copy_types)]
//@ pretty-expanded FIXME #23616
struct A { a: isize, b: Box<isize> }
struct B { a: Box<isize>, b: Box<isize> }

View File

@ -1,7 +1,6 @@
//@ run-pass
#![allow(dead_code)]
//@ pretty-expanded FIXME #23616
fn borrow(_v: &isize) {}

View File

@ -2,7 +2,6 @@
#![allow(dead_code)]
// Regression test for issue #7740
//@ pretty-expanded FIXME #23616
pub fn main() {
static A: &'static char = &'A';

View File

@ -3,7 +3,6 @@
// This test verifies that casting from the same lifetime on a value
// to the same lifetime on a trait succeeds. See issue #10766.
//@ pretty-expanded FIXME #23616
#![allow(dead_code)]

View File

@ -1,7 +1,6 @@
//@ run-pass
#![allow(dead_code)]
//@ pretty-expanded FIXME #23616
struct Rec {
f: Box<isize>,

View File

@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
#![allow(dropping_copy_types)]

View File

@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

View File

@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
fn main() {
let _a = Box::new(1);

View File

@ -2,7 +2,6 @@
#![allow(dead_code)]
#![allow(non_camel_case_types)]
//@ pretty-expanded FIXME #23616
pub fn main() {
enum t { t1(isize), t2(isize), }

View File

@ -1,6 +1,5 @@
//@ run-pass
#![allow(dead_code)]
//@ pretty-expanded FIXME #23616
pub fn main() {
let _: Box<_> = Box::new(100);

View File

@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
pub fn main() {
let _x: Box<_> = Box::new(vec![0,0,0,0,0]);

View File

@ -3,7 +3,6 @@
// Issue #976
//@ pretty-expanded FIXME #23616
fn f<T>(x: Box<T>) {
let _x2 = x;

View File

@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
pub fn main() {
let _i: Box<_> = Box::new(100);

View File

@ -2,7 +2,6 @@
#![allow(dead_code)]
// Issue #961
//@ pretty-expanded FIXME #23616
fn altsimple() {
match Box::new(true) {

View File

@ -2,7 +2,6 @@
#![allow(dead_code)]
// Issue #5192
//@ pretty-expanded FIXME #23616
pub trait EventLoop { fn foo(&self) {} }

View File

@ -5,7 +5,6 @@
// super-builtin-kind of a trait, if the type parameter is never used,
// the type can implement the trait anyway.
//@ pretty-expanded FIXME #23616
use std::marker;

View File

@ -1,7 +1,6 @@
//@ check-pass
// Simple test case of implementing a trait with super-builtin-kinds.
//@ pretty-expanded FIXME #23616
trait Foo : Send { }

View File

@ -2,7 +2,6 @@
// Tests correct implementation of traits with super-builtin-kinds
// using a bounded type parameter.
//@ pretty-expanded FIXME #23616
trait Foo : Send { }

View File

@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

View File

@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
fn foo(x: &mut Box<u8>) {
*x = Box::new(5);

View File

@ -2,7 +2,6 @@
// main is conditionally compiled, but the conditional compilation
// is conditional too!
//@ pretty-expanded FIXME #23616
#[cfg_attr(FALSE, cfg(bar))]
fn main() { }

View File

@ -1,7 +1,6 @@
//@ run-pass
// https://github.com/rust-lang/rust/issues/21833#issuecomment-72353044
//@ pretty-expanded FIXME #23616
#![cfg_attr(FALSE, no_core)]

View File

@ -1,5 +1,4 @@
//@ build-pass
//@ pretty-expanded FIXME #23616
//@ ignore-wasm32 no bare family
//@ ignore-sgx

View File

@ -1,6 +1,5 @@
//@ run-pass
#![allow(dead_code)]
//@ pretty-expanded FIXME #23616
enum Foo {
Bar,

View File

@ -1,7 +1,6 @@
//@ build-pass
//@ ignore-sgx
//@ pretty-expanded FIXME #23616
#[cfg(target_family = "windows")]
pub fn main() {}

View File

@ -1,7 +1,6 @@
//@ run-pass
//@ aux-build:cfg_inner_static.rs
//@ pretty-expanded FIXME #23616
extern crate cfg_inner_static;

View File

@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
#[cfg(target_arch = "x86")]
pub fn main() { }

View File

@ -1,7 +1,6 @@
//@ run-pass
// Test that cleanups for the RHS of shortcircuiting operators work.
//@ pretty-expanded FIXME #23616
#![allow(deref_nullptr)]

View File

@ -2,7 +2,6 @@
// Regression test for issue #10682
// Nested `proc` usage can't use outer owned data
//@ pretty-expanded FIXME #23616
fn work(_: Box<isize>) {}
fn foo<F:FnOnce()>(_: F) {}

View File

@ -1,6 +1,5 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
pub fn main() {
{|i: u32| if 1 == i { }}; //~ WARN unused closure that must be used

View File

@ -1,5 +1,5 @@
warning: unused closure that must be used
--> $DIR/issue-1460.rs:6:6
--> $DIR/issue-1460.rs:5:6
|
LL | {|i: u32| if 1 == i { }};
| ^^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,7 +1,6 @@
//@ run-pass
#![allow(unused_parens)]
#![allow(unit_bindings)]
//@ pretty-expanded FIXME #23616
fn f<T, F>(g: F) -> T where F: FnOnce() -> T { g() }

View File

@ -6,7 +6,6 @@
// Doing it incorrectly causes massive slowdown in LLVM during
// optimisation.
//@ pretty-expanded FIXME #23616
//@ needs-threads
#![feature(intrinsics)]

View File

@ -1,7 +1,6 @@
//@ run-pass
#![allow(unused_braces)]
#![allow(dead_code)]
//@ pretty-expanded FIXME #23616
use std::rc::Rc;

View File

@ -1,6 +1,5 @@
//@ run-pass
#![allow(dead_code)]
//@ pretty-expanded FIXME #23616
fn negate(x: &isize) -> isize {
-*x

View File

@ -1,6 +1,5 @@
//@ run-pass
#![allow(dead_code)]
//@ pretty-expanded FIXME #23616
fn sum(x: &[isize]) -> isize {
let mut sum = 0;

View File

@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
struct SpeechMaker {
speeches: usize

View File

@ -1,5 +1,4 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
struct SpeechMaker {
speeches: usize

Some files were not shown because too many files have changed in this diff Show More