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

Implement rustc side of report-future-incompat #75534

Merged
merged 10 commits into from
Nov 1, 2020

Conversation

Aaron1011
Copy link
Member

@Aaron1011 Aaron1011 commented Aug 14, 2020

cc #71249

This is an alternative to @pnkfelix's initial implementation in https://github.com/pnkfelix/rust/commits/prototype-rustc-side-of-report-future-incompat (mainly because I started working before seeing that branch 😄 ).

My approach outputs the entire original Diagnostic, in a way that is compatible with incremental compilation. This is not yet integrated with compiletest, but can be used manually by passing -Z emit-future-incompat-report to rustc.

Several changes are made to support this feature:

  • The librustc_session/lint module is moved to a new crate librustc_lint_defs (name bikesheddable). This allows accessing lint definitions from librustc_errors.
  • The Lint struct is extended with an Option<FutureBreakage>. When present, it indicates that we should display a lint in the future-compat report. FutureBreakage contains additional information that we may want to display in the report (currently, a date field indicating when the crate will stop compiling).
  • A new variant rustc_error::Level::Allow is added. This is used when constructing a diagnostic for a future-breakage lint that is marked as allowed (via #[allow] or --cap-lints). This allows us to capture any future-breakage diagnostics in one place, while still discarding them before they are passed to the Emitter.
  • DiagnosticId::Lint is extended with a has_future_breakage field, indicating whether or not the Lint has future breakage information (and should therefore show up in the report).
  • Session is given access to the LintStore via a new SessionLintStore trait (since librustc_session cannot directly reference LintStore without a cyclic dependency). We use this to turn a string DiagnosticId::Lint back into a Lint, to retrieve the FutureBreakage data.

Currently, FutureBreakage.date is always set to None. However, this could potentially be interpreted by Cargo in the future.

I've enabled the future-breakage report for the ARRAY_INTO_ITER lint, which can be used to test out this PR. The intent is to use the field to allow Cargo to determine the date of future breakage (as described in RFC 2834) without needing to parse the diagnostic itself.

cc @pnkfelix

@rust-highfive
Copy link
Collaborator

r? @ecstatic-morse

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 14, 2020
@bors

This comment has been minimized.

@ecstatic-morse
Copy link
Contributor

Not familiar with this part of the code.

r? @pnkfelix maybe?

@bors

This comment has been minimized.

@bors

This comment has been minimized.

@bors

This comment has been minimized.

@bors

This comment has been minimized.

@Aaron1011
Copy link
Member Author

@pnkfelix: This is now ready for review

@bors

This comment has been minimized.

@jyn514 jyn514 added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-future-incompatibility Category: Future-incompatibility lints labels Sep 15, 2020
@Aaron1011
Copy link
Member Author

@pnkfelix: Are there any changes that you'd like me to make?

@bors
Copy link
Contributor

bors commented Sep 26, 2020

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

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@Aaron1011
Copy link
Member Author

@pnkfelix: Do you think you'll be able to review this sometime soon? There are several issues that would benefit from having this available.

@bors
Copy link
Contributor

bors commented Oct 5, 2020

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

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@bors
Copy link
Contributor

bors commented Nov 1, 2020

⌛ Testing commit 6db00a2 with merge 7bcd889ebca66a5d5e6224220bc58bca2a240ddf...

@bors
Copy link
Contributor

bors commented Nov 1, 2020

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 1, 2020
@Aaron1011
Copy link
Member Author

@bors retry

@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 Nov 1, 2020
@bors
Copy link
Contributor

bors commented Nov 1, 2020

⌛ Testing commit 6db00a2 with merge b202532...

@bors
Copy link
Contributor

bors commented Nov 1, 2020

☀️ Test successful - checks-actions
Approved by: pnkfelix
Pushing b202532 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 1, 2020
@bors bors merged commit b202532 into rust-lang:master Nov 1, 2020
@rustbot rustbot added this to the 1.49.0 milestone Nov 1, 2020
Aaron1011 added a commit to Aaron1011/rust that referenced this pull request Nov 2, 2020
Fixes rust-lang#78660

With PR rust-lang#75534 merged, we now run
more lint-related code for future-incompat-report, even when their final
level is Allow. Some lint-related code was not expecting `Level::Allow`,
and had an explicit panic.

This PR explicitly tracks the lint level set on the command line before
`--cap-lints` is applied. This is used to emit a more precise error
note (e.g. we don't say that `-W lint-name` was specified on the
command line just because a lint was capped to Warn). As a result, we
can now correctly emit a note that `-A` was used if we got
`Level::Allow` from the command line (before the cap is applied).
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Nov 3, 2020
…tmandry

Fix ICE when a future-incompat-report has its command-line level capped

Fixes rust-lang#78660

With PR rust-lang#75534 merged, we now run
more lint-related code for future-incompat-report, even when their final
level is Allow. Some lint-related code was not expecting `Level::Allow`,
and had an explicit panic.

This PR explicitly tracks the lint level set on the command line before
`--cap-lints` is applied. This is used to emit a more precise error
note (e.g. we don't say that `-W lint-name` was specified on the
command line just because a lint was capped to Warn). As a result, we
can now correctly emit a note that `-A` was used if we got
`Level::Allow` from the command line (before the cap is applied).
flip1995 pushed a commit to flip1995/rust that referenced this pull request Nov 3, 2020
…, r=pnkfelix

Implement rustc side of report-future-incompat

cc rust-lang#71249

This is an alternative to `@pnkfelix's` initial implementation in https://github.com/pnkfelix/rust/commits/prototype-rustc-side-of-report-future-incompat (mainly because I started working before seeing that branch 😄 ).

My approach outputs the entire original `Diagnostic`, in a way that is compatible with incremental compilation. This is not yet integrated with compiletest, but can be used manually by passing `-Z emit-future-incompat-report` to `rustc`.

Several changes are made to support this feature:
* The `librustc_session/lint` module is moved to a new crate `librustc_lint_defs` (name bikesheddable). This allows accessing lint definitions from `librustc_errors`.
* The `Lint` struct is extended with an `Option<FutureBreakage>`. When present, it indicates that we should display a lint in the future-compat report. `FutureBreakage` contains additional information that we may want to display in the report (currently, a `date` field indicating when the crate will stop compiling).
* A new variant `rustc_error::Level::Allow` is added. This is used when constructing a diagnostic for a future-breakage lint that is marked as allowed (via `#[allow]` or `--cap-lints`). This allows us to capture any future-breakage diagnostics in one place, while still discarding them before they are passed to the `Emitter`.
* `DiagnosticId::Lint` is extended with a `has_future_breakage` field, indicating whether or not the `Lint` has future breakage information (and should therefore show up in the report).
* `Session` is given access to the `LintStore` via a new `SessionLintStore` trait (since `librustc_session` cannot directly reference `LintStore` without a cyclic dependency). We use this to turn a string `DiagnosticId::Lint` back into a `Lint`, to retrieve the `FutureBreakage` data.

Currently, `FutureBreakage.date` is always set to `None`. However, this could potentially be interpreted by Cargo in the future.

I've enabled the future-breakage report for the `ARRAY_INTO_ITER` lint, which can be used to test out this PR. The intent is to use the field to allow Cargo to determine the date of future breakage (as described in [RFC 2834](https://github.com/rust-lang/rfcs/blob/master/text/2834-cargo-report-future-incompat.md)) without needing to parse the diagnostic itself.

cc `@pnkfelix`
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Sep 28, 2021
rustc_session: Remove lint store from `Session`

It was added in rust-lang#75534, but after the cleanup in rust-lang#87070 it's no longer necessary.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Sep 28, 2021
rustc_session: Remove lint store from `Session`

It was added in rust-lang#75534, but after the cleanup in rust-lang#87070 it's no longer necessary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-future-incompatibility Category: Future-incompatibility lints merged-by-bors This PR was explicitly merged by bors. 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.

7 participants