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

Make it an error to not declare used features #23598

Closed
wants to merge 5 commits into from
Closed

Conversation

brson
Copy link
Contributor

@brson brson commented Mar 22, 2015

Also, on the beta/stable channels, it is an error to write feature.

I had to add two hacks to rustdoc to make the doctests support crate attributes correctly, and to avoid injecting 'extern crate' items that trip the unstable feature error for doctests inside the std facade. The latter of these adds a crate-level #[doc(test(no_inject_crate))] attribute, which is pretty ugly.

This is very prone to bitrot and will be hard to land.

@rust-highfive
Copy link
Collaborator

r? @aturon

(rust_highfive has picked a reviewer for you, use r? to override)

@brson
Copy link
Contributor Author

brson commented Mar 22, 2015

Oh, still doesn't quite pass.

@brson
Copy link
Contributor Author

brson commented Mar 22, 2015

Well, I hit an ugly bug because of the hack I put in to make crate attributes work in doc tests. The rustdoc test runner wants to put 'extern crate' and 'main' functions into the source, and it needs to do that after any crate attributes. To avoid putting explicit main functions into every test that declares a feature I made the test runner try to figure out the parts of the example that are outer attributes, and make them crate attributes.

Unfortunately, this appears in the book:

#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
       html_favicon_url = "http://www.rust-lang.org/favicon.ico",
       html_root_url = "http://doc.rust-lang.org/")];

And rustdoc now thinks it should turn it into something like:

#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
fn main() {
       html_favicon_url = "http://www.rust-lang.org/favicon.ico",
       html_root_url = "http://doc.rust-lang.org/")];
}

@brson
Copy link
Contributor Author

brson commented Mar 22, 2015

Maybe I could just have rustdoc treat only #![feature specially as a hack to get this done.

@brson
Copy link
Contributor Author

brson commented Mar 22, 2015

I've run into another major problem: #23616. This isn't as close to ready as I thought.

@brson
Copy link
Contributor Author

brson commented Mar 23, 2015

This has passed tests locally.

@aturon
Copy link
Member

aturon commented Mar 23, 2015

I had a couple minor nits but basically am OK trying to get this landed (due to the bitrot issues).

I do worry a bit about adding yet more ways that tests can pedantically fail, which can be very annoying...

@brson
Copy link
Contributor Author

brson commented Mar 23, 2015

Rebased again.

@brson
Copy link
Contributor Author

brson commented Mar 23, 2015

Doesn't pass on mac/win yet.

@brson
Copy link
Contributor Author

brson commented Mar 23, 2015

@bors r=aturon p=1000

@bors
Copy link
Contributor

bors commented Mar 23, 2015

📌 Commit 97c8444 has been approved by aturon

@alexcrichton
Copy link
Member

@bors: force

@alexcrichton
Copy link
Member

@bors: r=aturon 97c8444 p=1000

@bors
Copy link
Contributor

bors commented Mar 23, 2015

🙀 97c84447b65164731087ea82685580cc81424412 is not a valid commit SHA. Please try again with 5d8367e.

@alexcrichton
Copy link
Member

@bors: r=aturon 5d8367e1e15df88653450bdb649619061f9472a6 p=1000

@alexcrichton
Copy link
Member

@bors: force

@bors
Copy link
Contributor

bors commented Mar 23, 2015

⌛ Testing commit 5d8367e with merge e067340...

@bors
Copy link
Contributor

bors commented Mar 23, 2015

💔 Test failed - auto-mac-64-nopt-t

brson added 2 commits March 23, 2015 14:40
…e attributes

This makes it possible to write `#![feature(foo)]` in doc tests.
So that collections doctests don't automatically fail themselves
by injecting `extern crate collections` when they are mostly
using the std facade.
@brson
Copy link
Contributor Author

brson commented Mar 23, 2015

@bors r=aturon p=1000

@bors
Copy link
Contributor

bors commented Mar 23, 2015

📌 Commit 8c93a79 has been approved by aturon

@alexcrichton
Copy link
Member

@bors: force

@bors
Copy link
Contributor

bors commented Mar 23, 2015

⌛ Testing commit 8c93a79 with merge 56bdd12...

@bors
Copy link
Contributor

bors commented Mar 23, 2015

💔 Test failed - auto-mac-64-opt

brson added 3 commits March 23, 2015 16:07
Now that features must be declared expanded source often does not compile.
This adds 'pretty-expanded' to a bunch of test cases that still work.
@brson
Copy link
Contributor Author

brson commented Mar 23, 2015

@bors r+ p=1000

@bors
Copy link
Contributor

bors commented Mar 23, 2015

📌 Commit 66efe89 has been approved by brson

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Mar 23, 2015
Conflicts:
	src/compiletest/compiletest.rs
	src/libcollections/lib.rs
	src/librustc_back/lib.rs
	src/libserialize/lib.rs
	src/libstd/lib.rs
	src/libtest/lib.rs
	src/test/run-make/rustdoc-default-impl/foo.rs
	src/test/run-pass/env-home-dir.rs
@alexcrichton
Copy link
Member

I'm putting the rollup (#23654) ahead of this b/c it includes this inside of it. (just FYI)

@bors
Copy link
Contributor

bors commented Mar 24, 2015

⌛ Testing commit 66efe89 with merge 7e441d4...

@bors
Copy link
Contributor

bors commented Mar 24, 2015

💔 Test failed - auto-mac-64-opt

@bors
Copy link
Contributor

bors commented Mar 24, 2015

☔ The latest upstream changes (presumably #23654) made this pull request unmergeable. Please resolve the merge conflicts.

@alexcrichton
Copy link
Member

Rolled into #23654

jieyouxu added a commit to jieyouxu/rust that referenced this pull request 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 pull request 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 pull request 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 pull request 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 pull request 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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants