Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There are very few tests for -Z unpretty expansion #23616

Open
brson opened this issue Mar 22, 2015 · 9 comments
Open

There are very few tests for -Z unpretty expansion #23616

brson opened this issue Mar 22, 2015 · 9 comments
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`) A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@brson
Copy link
Contributor

brson commented Mar 22, 2015

See #23616 (comment) for a current issue description. The original description follows below.


Pretty-expanded source that results in unstable code can't build. After it becomes illegal to not declare features this is going to cause a bunch of expanded source to not build.

@brson
Copy link
Contributor Author

brson commented Mar 22, 2015

I'm going to be adding no-pretty-expanded to a bunch of tests.

@steveklabnik
Copy link
Member

at least expanded is unstable, yeah?

@steveklabnik steveklabnik added the A-pretty Area: Pretty printing (including `-Z unpretty`) label Mar 22, 2015
@alexcrichton
Copy link
Member

Unfortunately I think that this is just a fundamental limitation. We have a number of problems that make it such that expanded source cannot actually compile at all:

  • #[allow_internal_unstable] make it such that macros can use unstable features without declaration
  • #[no_std] which is injected is unstable
  • Hygiene (e.g. a macro's local variable foo is very different than the outer variable foo)

I would also be fine just assuming that tests cannot be pretty printed when expected unless there is an explicit opt-in directive.

@brson
Copy link
Contributor Author

brson commented Mar 22, 2015

Perhaps I will switch compiletest to support pretty-expanded and add that to a bunch that are passing now. It does seem like it would be pretty annoying to maintain all the no-pretty-expanded flags.

@nikomatsakis
Copy link
Contributor

can we just disable the pretty-printing tests for the beta branch or something like that?

@nikomatsakis
Copy link
Contributor

(Does that make sense?)

@steveklabnik
Copy link
Member

Triage: not aware of any specific issue here, though I haven't heard about anyone running into this in practice in the last year.

@steveklabnik
Copy link
Member

Triage: lots of FIXMEs referring to this issue still remain.

@jethrogb
Copy link
Contributor

jethrogb commented Apr 19, 2019

Ran into this while looking at the compiletest framework and was thoroughly confused. As far as I can tell, this is the situation as of early 2019:

Certain parts of the Rust test suite can be run in “pretty” mode. This will test the pretty-printing output of rustc. One of the pretty-printing outputs of rustc is the expanded mode, which may result in code that can't subsequently be compiled, that is what this issue is about. Tests that were in 2015 known to work with expanded mode have the pretty-expanded attribute to test that mode. All pretty-expanded annotations are marked with “FIXME #23616”, but this is misleading: the tests that have the attribute don't need to be fixed, it's the tests that don't have the pretty-expanded/FIXME annotation that are blocked on this issue.

I think it was a mistake to replace no-pretty-expanded with pretty-expanded in #23598, because the test coverage of expanded pretty printing has basically stagnated. Since 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. Now, everyone has basically forgotten about this attribute.

@jyn514 jyn514 added the A-testsuite Area: The testsuite used to check the correctness of rustc label Apr 3, 2023
@jyn514 jyn514 changed the title Pretty-expanded source that results in unstable code can't build. There are very few tests for -Z unpretty expansion Apr 3, 2023
@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Nov 25, 2024
jieyouxu added a commit to jieyouxu/rust that referenced this issue Nov 25, 2024
Foreword
========

Let us begin the journey to rediscover what the `//@ pretty-expanded`
directive does, brave traveller --

    "My good friend, [..] when I wrote that passage, God and I knew what
    it meant. It is possible that God knows it still; but as for me, I
    have totally forgotten."

                                 -- Johann Paul Friedrich Richter, 1826

We must retrace the steps of those before us, for history shall guide us
in the present and inform us of the future.

The Past
========

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
`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 (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.

The Present
===========

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 of the `//@ pretty-expanded` in `ui` tests to do
absolutely nothing -- the compiletest logic for `pretty-expanded` only
triggered in the *pretty* test suite, but none of the pretty tests use
it. Oops.

The Future
==========

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
jieyouxu added a commit to jieyouxu/rust that referenced this issue Nov 25, 2024
Foreword
========

Let us begin the journey to rediscover what the `//@ pretty-expanded`
directive does, brave traveller --

    "My good friend, [..] when I wrote that passage, God and I knew what
    it meant. It is possible that God knows it still; but as for me, I
    have totally forgotten."

                                 -- Johann Paul Friedrich Richter, 1826

We must retrace the steps of those before us, for history shall guide us
in the present and inform us of the future.

The Past
========

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
`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 (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.

The Present
===========

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 of the `//@ pretty-expanded` in `ui` tests to do
absolutely nothing -- the compiletest logic for `pretty-expanded` only
triggered in the *pretty* test suite, but none of the pretty tests use
it. Oops.

The Future
==========

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
jhpratt added a commit to jhpratt/rust that referenced this issue Nov 26, 2024
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
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Nov 26, 2024
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
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Nov 26, 2024
Rollup merge of rust-lang#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 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`) A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

8 participants