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

Disallows #![feature(no_coverage)] on stable and beta (using standard crate-level gating) #84871

Merged
merged 1 commit into from
May 7, 2021

Conversation

richkadel
Copy link
Contributor

@richkadel richkadel commented May 3, 2021

Fixes: #84836

Removes the function-level feature gating solution originally implemented, and solves the same problem using allow_internal_unstable, so normal crate-level feature gating mechanism can still be used (which disallows the feature on stable and beta).

I tested this, building the compiler with and without CFG_DISABLE_UNSTABLE_FEATURES=1

With unstable features disabled, I get the expected result as shown here:

$ ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc     src/test/run-make-fulldeps/coverage/no_cov_crate.rs
error[E0554]: `#![feature]` may not be used on the dev release channel
 --> src/test/run-make-fulldeps/coverage/no_cov_crate.rs:2:1
  |
2 | #![feature(no_coverage)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0554`.

r? @Mark-Simulacrum
cc: @tmandry @wesleywiser

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 3, 2021
@richkadel richkadel force-pushed the no-coverage-unstable-only branch from 0c51f39 to f5b0874 Compare May 3, 2021 15:57
@richkadel

This comment has been minimized.

@richkadel richkadel force-pushed the no-coverage-unstable-only branch from f5b0874 to 90204fe Compare May 3, 2021 16:28
@richkadel

This comment has been minimized.

@richkadel richkadel force-pushed the no-coverage-unstable-only branch from 90204fe to a40d701 Compare May 3, 2021 16:39
@richkadel

This comment has been minimized.

@ghost
Copy link

ghost commented May 3, 2021

This does not seem like what's described in #84836 (comment) (emphasis mine)?

It should be possible to adjust the normal feature gating to correctly handle macro expanded sources - that is, allow the built-in derives to generate it without it being stabilized. We do this for the Structural trait impls somehow, for example; possibly enough to set the span appropriately.

The macro generates impl for feature-gated StructuralEq without expanding to any #[feature]: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=7d5fca8b78b2ce2dcc18c750d60af69a (click "TOOLS" -> "Expand macros")

@richkadel
Copy link
Contributor Author

This does not seem like what's described in #84836 (comment) (emphasis mine)?

No, probably not. I don't fully understand the option Mark described, and I'm not sure if it's a general solution, or one that will only work for the core library.

But this solution has the desired effect.

@tmandry
Copy link
Member

tmandry commented May 5, 2021

This will work for now but given #84836 (comment) I don't think we should continue using this mechanism without an MCP.

This wouldn't work anyway if we decided to stabilize -Zinstrument-coverage without the no_coverage feature.

@richkadel
Copy link
Contributor Author

I just uploaded a revised implementation that I believe meets everyone's expectations. Per @nagisa 's hints, I figured out how to apply the feature gating at the crate level, and used allow_internal_unstable when injecting the derived method from Eq.

I updated the ui test to include a struct that derives Eq to make sure it still fails on #[no_coverage] applied elsewhere.

Tests with #[no_coverage] that also enable the feature still work on nightly, and they still fail on beta/stable (validated using the same method described in this PR description above).

cx.attribute(doc),
];
let mut attrs = vec![cx.attribute(inline), cx.attribute(doc)];
if cx.parse_sess().unstable_features.is_nightly_build() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be conditional on is_nightly_build, does it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to change it and verify it still builds core and still disables use on beta/stable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@nagisa
Copy link
Member

nagisa commented May 5, 2021

Can you adjust the description and the title of the PR please?

@richkadel richkadel changed the title Disallows #[feature(no_coverage)] on stable and beta Disallows #![feature(no_coverage)] on stable and beta May 5, 2021
@richkadel
Copy link
Contributor Author

Can you adjust the description and the title of the PR please?

I added an exclamation point to the attribute in the title.

The description looks fine to me. (I had already removed the function-level example.)

Let me know if I'm missing something.

using allow_internal_unstable (as recommended)

Fixes: rust-lang#84836

```shell
$ ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc     src/test/run-make-fulldeps/coverage/no_cov_crate.rs
error[E0554]: `#![feature]` may not be used on the dev release channel
 --> src/test/run-make-fulldeps/coverage/no_cov_crate.rs:2:1
  |
2 | #![feature(no_coverage)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0554`.
```
@richkadel richkadel force-pushed the no-coverage-unstable-only branch from 22b355a to 3584c1d Compare May 5, 2021 14:54
@richkadel
Copy link
Contributor Author

@nagisa - I think this is ready:

  • I addressed your comment in eq.rs and removed the conditional (verified it still blocks on beta/stable, and it still works otherwise)
  • I updated the PR title, and the commit message. I had already updated the PR commit message last night.
  • I squashed the commits

Thanks

@nagisa
Copy link
Member

nagisa commented May 5, 2021

Let me know if I'm missing something.

Ah, I meant that its no longer precisely about disallowing the attribute on stable/beta (in particular no code specifically addresses this particular point) but more like making no_coverage use the usual feature gating infrastructure. But I don't care too strongly either way.

@bors r+

@bors
Copy link
Contributor

bors commented May 5, 2021

📌 Commit 3584c1d has been approved by nagisa

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 5, 2021
@richkadel richkadel changed the title Disallows #![feature(no_coverage)] on stable and beta Disallows #![feature(no_coverage)] on stable and beta (using standard crate-level gating) May 5, 2021
@richkadel
Copy link
Contributor Author

Oh, I gotcha. Done.

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request May 6, 2021
…, r=nagisa

Disallows `#![feature(no_coverage)]` on stable and beta (using standard crate-level gating)

Fixes: rust-lang#84836

Removes the function-level feature gating solution originally implemented, and solves the same problem using `allow_internal_unstable`, so normal crate-level feature gating mechanism can still be used (which disallows the feature on stable and beta).

I tested this, building the compiler with and without `CFG_DISABLE_UNSTABLE_FEATURES=1`

With unstable features disabled, I get the expected result as shown here:

```shell
$ ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc     src/test/run-make-fulldeps/coverage/no_cov_crate.rs
error[E0554]: `#![feature]` may not be used on the dev release channel
 --> src/test/run-make-fulldeps/coverage/no_cov_crate.rs:2:1
  |
2 | #![feature(no_coverage)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0554`.
```

r? `@Mark-Simulacrum`
cc: `@tmandry` `@wesleywiser`
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request May 6, 2021
…, r=nagisa

Disallows `#![feature(no_coverage)]` on stable and beta (using standard crate-level gating)

Fixes: rust-lang#84836

Removes the function-level feature gating solution originally implemented, and solves the same problem using `allow_internal_unstable`, so normal crate-level feature gating mechanism can still be used (which disallows the feature on stable and beta).

I tested this, building the compiler with and without `CFG_DISABLE_UNSTABLE_FEATURES=1`

With unstable features disabled, I get the expected result as shown here:

```shell
$ ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc     src/test/run-make-fulldeps/coverage/no_cov_crate.rs
error[E0554]: `#![feature]` may not be used on the dev release channel
 --> src/test/run-make-fulldeps/coverage/no_cov_crate.rs:2:1
  |
2 | #![feature(no_coverage)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0554`.
```

r? ``@Mark-Simulacrum``
cc: ``@tmandry`` ``@wesleywiser``
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request May 6, 2021
…, r=nagisa

Disallows `#![feature(no_coverage)]` on stable and beta (using standard crate-level gating)

Fixes: rust-lang#84836

Removes the function-level feature gating solution originally implemented, and solves the same problem using `allow_internal_unstable`, so normal crate-level feature gating mechanism can still be used (which disallows the feature on stable and beta).

I tested this, building the compiler with and without `CFG_DISABLE_UNSTABLE_FEATURES=1`

With unstable features disabled, I get the expected result as shown here:

```shell
$ ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc     src/test/run-make-fulldeps/coverage/no_cov_crate.rs
error[E0554]: `#![feature]` may not be used on the dev release channel
 --> src/test/run-make-fulldeps/coverage/no_cov_crate.rs:2:1
  |
2 | #![feature(no_coverage)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0554`.
```

r? ```@Mark-Simulacrum```
cc: ```@tmandry``` ```@wesleywiser```
bors added a commit to rust-lang-ci/rust that referenced this pull request May 7, 2021
Rollup of 11 pull requests

Successful merges:

 - rust-lang#84409 (Ensure TLS destructors run before thread joins in SGX)
 - rust-lang#84500 (Add --run flag to compiletest)
 - rust-lang#84728 (Add test for suggestion to borrow unsized function parameters)
 - rust-lang#84734 (Add `needs-unwind` and beginning of support for testing `panic=abort` std to compiletest)
 - rust-lang#84755 (Allow using `core::` in intra-doc links within core itself)
 - rust-lang#84871 (Disallows `#![feature(no_coverage)]` on stable and beta (using standard crate-level gating))
 - rust-lang#84872 (Wire up tidy dependency checks for cg_clif)
 - rust-lang#84896 (Handle incorrect placement of parentheses in trait bounds more gracefully)
 - rust-lang#84905 (CTFE engine: rename copy → copy_intrinsic, move to intrinsics.rs)
 - rust-lang#84953 (Remove unneeded call to with_default_session_globals in rustdoc highlight)
 - rust-lang#84987 (small nits)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit aaf2389 into rust-lang:master May 7, 2021
@rustbot rustbot added this to the 1.54.0 milestone May 7, 2021
@pietroalbini
Copy link
Member

My understanding is that this should be backported to 1.53 beta, correct?

@wesleywiser
Copy link
Member

Yes, nominating for beta-backport.

@wesleywiser wesleywiser added beta-nominated Nominated for backporting to the compiler in the beta channel. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 7, 2021
@pnkfelix
Copy link
Member

discussed in T-compiler meeting, beta backport approved.

@pnkfelix pnkfelix added the beta-accepted Accepted for backporting to the compiler in the beta channel. label May 13, 2021
@Mark-Simulacrum Mark-Simulacrum modified the milestones: 1.54.0, 1.53.0 May 22, 2021
@Mark-Simulacrum Mark-Simulacrum removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label May 22, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request May 22, 2021
…ulacrum

[beta] backports

 * Backport 1.52.1 release notes rust-lang#85404
 * remove InPlaceIterable marker from Peekable due to unsoundness rust-lang#85340
 * rustdoc: Call initSidebarItems in root module of crate rust-lang#85304
 * Update LLVM submodule rust-lang#85236
 * Do not ICE on invalid const param rust-lang#84913
 * Disallows #![feature(no_coverage)] on stable and beta (using standard crate-level gating) rust-lang#84871
 * Ensure TLS destructors run before thread joins in SGX rust-lang#84409
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

no_coverage feature-gated on function, not crate?
10 participants