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

very minor cleanups #111606

Merged
merged 1 commit into from
May 20, 2023
Merged

very minor cleanups #111606

merged 1 commit into from
May 20, 2023

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented May 15, 2023

  • add must_use to early_error_no_abort

    this was already being used at its only callsite, but this ensures that new code remembers to use it if it's called in the future. found this while investigating stable: Give a better error message for rustc +nightly -Zunstable-options #110090.

  • remove outdated and incorrect comment in builder.rs. doc_rust_lang_org_channel doesn't exist in rustdoc, it gets it from an env var instead:

    /// A link to `doc.rust-lang.org` that includes the channel name. Use this instead of manual links
    /// so that the channel is consistent.
    ///
    /// Set by `bootstrap::Builder::doc_rust_lang_org_channel` in order to keep tests passing on beta/stable.
    pub(crate) const DOC_RUST_LANG_ORG_CHANNEL: &str = env!("DOC_RUST_LANG_ORG_CHANNEL");

@rustbot
Copy link
Collaborator

rustbot commented May 15, 2023

r? @lcnr

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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. labels May 15, 2023
@rust-log-analyzer

This comment has been minimized.

@jyn514 jyn514 force-pushed the nightly-diagnostics branch from 4a1f8c1 to 666d183 Compare May 15, 2023 17:32
Comment on lines 1233 to 1254
// the error code is already going to be reported when the panic unwinds up the stack
let _ = early_error_no_abort(ErrorOutputType::default(), &msg);
Copy link
Member Author

Choose a reason for hiding this comment

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

I tested this does the right thing as follows:

C:\Users\jyn\src\rust2>(rustc -C help || call echo %%^^errorlevel%% 1>&2) | cmd /c exit
error: failed printing to stdout: The pipe is being closed. (os error 232)

%101%

@@ -1741,6 +1741,7 @@ fn early_error_handler(output: config::ErrorOutputType) -> rustc_errors::Handler

#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
#[must_use = "ErrorGuaranteed does nothing unless returned from build_session_options"]
Copy link
Contributor

Choose a reason for hiding this comment

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

that feels a bit weird to me 🤔 what do you mean with "does nothing unless"?

ErrorGuaranteed never does anything, I thought it is only meant to be used as a token for "we already errored, so feel free to skip some other errors or checks".

Copy link
Member Author

Choose a reason for hiding this comment

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

ErrorGuaranteed is used in rustc_driver to determine whether to exit with a success status code or not: https://github.com/rust-lang/rust/blob/666d1831c5a4215165f37417bda6667f27ef7790/compiler/rustc_driver_impl/src/lib.rs#L1386-L1399
If someone forgets to return ErrorGuaranteed from run_compiler, we'll exit with a 0 status code even though we emitted an error.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, this feels generally a bit sketchy, I see why you'd want to use #[must_use] now.

could anything that have an TyCtxt instead check for has_errors()? or I guess sess.has_errors()?

Copy link
Contributor

@lcnr lcnr May 18, 2023

Choose a reason for hiding this comment

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

ErrorGuaranteed is used in rustc_driver to determine whether to exit with a success status code or not:

can you put that as part of the #[must_use] explanation?

r=me after that

Copy link
Member Author

@jyn514 jyn514 May 18, 2023

Choose a reason for hiding this comment

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

could anything that have an TyCtxt instead check for has_errors()? or I guess sess.has_errors()?

all the callers of early_error and early_error_no_abort happen before we construct a sess (otherwise they could just call sess.err or sess.fatal).

can you put that as part of the #[must_use] explanation?

👍 will do :)

@bors
Copy link
Contributor

bors commented May 18, 2023

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

@jyn514 jyn514 force-pushed the nightly-diagnostics branch from 666d183 to 464fd0c Compare May 18, 2023 13:04
- add `must_use` to `early_error_no_abort`

  this was already being used at its only callsite, but this ensures
that new code remembers to use it if it's called in the future.

- remove outdated and incorrect comment in `builder.rs`.
  `doc_rust_lang_org_channel` doesn't exist in rustdoc, it gets it from
an env var instead.
@jyn514 jyn514 force-pushed the nightly-diagnostics branch from 464fd0c to 0426562 Compare May 18, 2023 13:07
@jyn514
Copy link
Member Author

jyn514 commented May 18, 2023

@bors r=lcnr rollup

@bors
Copy link
Contributor

bors commented May 18, 2023

📌 Commit 0426562 has been approved by lcnr

It is now in the queue for this repository.

@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 18, 2023
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request May 18, 2023
very minor cleanups

- add `must_use` to `early_error_no_abort`

  this was already being used at its only callsite, but this ensures that new code remembers to use it if it's called in the future. found this while investigating rust-lang#110090.

- remove outdated and incorrect comment in `builder.rs`. `doc_rust_lang_org_channel` doesn't exist in rustdoc, it gets it from an env var instead: https://github.com/rust-lang/rust/blob/b275d2c30b6e88cc48747f349f7137076d450658/src/librustdoc/clean/utils.rs#L569-L573
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request May 19, 2023
very minor cleanups

- add `must_use` to `early_error_no_abort`

  this was already being used at its only callsite, but this ensures that new code remembers to use it if it's called in the future. found this while investigating rust-lang#110090.

- remove outdated and incorrect comment in `builder.rs`. `doc_rust_lang_org_channel` doesn't exist in rustdoc, it gets it from an env var instead: https://github.com/rust-lang/rust/blob/b275d2c30b6e88cc48747f349f7137076d450658/src/librustdoc/clean/utils.rs#L569-L573
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request May 19, 2023
very minor cleanups

- add `must_use` to `early_error_no_abort`

  this was already being used at its only callsite, but this ensures that new code remembers to use it if it's called in the future. found this while investigating rust-lang#110090.

- remove outdated and incorrect comment in `builder.rs`. `doc_rust_lang_org_channel` doesn't exist in rustdoc, it gets it from an env var instead: https://github.com/rust-lang/rust/blob/b275d2c30b6e88cc48747f349f7137076d450658/src/librustdoc/clean/utils.rs#L569-L573
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request May 19, 2023
very minor cleanups

- add `must_use` to `early_error_no_abort`

  this was already being used at its only callsite, but this ensures that new code remembers to use it if it's called in the future. found this while investigating rust-lang#110090.

- remove outdated and incorrect comment in `builder.rs`. `doc_rust_lang_org_channel` doesn't exist in rustdoc, it gets it from an env var instead: https://github.com/rust-lang/rust/blob/b275d2c30b6e88cc48747f349f7137076d450658/src/librustdoc/clean/utils.rs#L569-L573
bors added a commit to rust-lang-ci/rust that referenced this pull request May 20, 2023
Rollup of 10 pull requests

Successful merges:

 - rust-lang#111491 (Dont check `must_use` on nested `impl Future` from fn)
 - rust-lang#111606 (very minor cleanups)
 - rust-lang#111619 (Add timings for MIR passes to profiling report)
 - rust-lang#111652 (Better diagnostic for `use Self::..`)
 - rust-lang#111665 (Add more tests for the offset_of macro)
 - rust-lang#111708 (Give a more useful location for where a span_bug was delayed)
 - rust-lang#111715 (Fix doc comment for `ConstParamTy` derive)
 - rust-lang#111723 (style: do not overwrite obligations)
 - rust-lang#111743 (Improve cgu merging debug output)
 - rust-lang#111762 (fix: emit error when fragment is `MethodReceiverExpr` and items is empty)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit fa11c9e into rust-lang:master May 20, 2023
@rustbot rustbot added this to the 1.71.0 milestone May 20, 2023
@jyn514 jyn514 deleted the nightly-diagnostics branch June 16, 2023 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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

Successfully merging this pull request may close these issues.

5 participants