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

Rollup of 8 pull requests #121339

Closed
wants to merge 24 commits into from
Closed

Conversation

Noratrieb
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

reitermarkus and others added 24 commits February 17, 2024 21:58
Its one use isn't necessary, because it's not possible for errors to
have been emitted at that point.
Currently `has_errors` excludes lint errors. This commit changes it to
include lint errors.

The motivation for this is that for most places it doesn't matter
whether lint errors are included or not. But there are multiple places
where they must be includes, and only one place where they must not be
included. So it makes sense for `has_errors` to do the thing that fits
the most situations, and the new `has_errors_excluding_lint_errors`
method in the one exceptional place.

The same change is made for `err_count`. Annoyingly, this requires the
introduction of `err_count_excluding_lint_errs` for one place, to
preserve existing error printing behaviour. But I still think the change
is worthwhile overall.
This profile originally made sense when download-ci-llvm = if-unchanged
didn't exist and we had the bad tradeoff of "never modify or always
compile".

Thankfully, these grim times are over and we have discovered clean
water, so the only differentiator between the two profiles is the
codegen profile having LLVM assertions. Adding them doesn't cause that
much of a slowdown, <10% on UI tests from an unscientific benchmark.

It also had LLVM warnings when compiling, which makes sense for every
compiler contributor brave enough to compile LLVM.

The way I removed is by just issueing a nice error message. Given that
everyone with this profile should be a contributor and not someone like
a distro who is more upset when things break, this should be fine.
If it isn't, we can always fall back to just letting codegen mean
compiler.
…sertions)

The current complexities in `assert_unsafe_precondition` are delicately
balancing several concerns, among them compile times for the cases where
there are no debug assertions. This comes at a large runtime cost when
the assertions are enabled, making the debug assertion compiler a lot
slower, which is very annoying.

To avoid this, we always inline the check when building with debug
assertions.

Numbers (compiling stage1 library after touching core):
- master: 80s
- just adding `#[inline(always)]` to the `cfg(bootstrap)`
  `debug_assertions`: 67s
- this: 54s

So this seems like a good solution. I think we can still get
the same run-time perf improvements for other users too by
massaging this code further (see my other PR about adding
`#[rustc_no_mir_inline]`) but this is a simpler step that
solves the imminent problem of "holy shit my rustc is sooo slow".

Funny consequence: This now means compiling the standard library with
dbeug assertions makes it faster (than without, when using debug
assertions downstream)!
Currently `emit_stashed_diagnostic` is called from four(!) different
places: `print_error_count`, `DiagCtxtInner::drop`, `abort_if_errors`,
and `compile_status`.

And `flush_delayed` is called from two different places:
`DiagCtxtInner::drop` and `Queries`.

This is pretty gross! Each one should really be called from a single
place, but there's a bunch of entanglements. This commit cleans up this
mess.

Specifically, it:
- Removes all the existing calls to `emit_stashed_diagnostic`, and adds
  a single new call in `finish_diagnostics`.
- Removes the early `flush_delayed` call in `codegen_and_build_linker`,
  replacing it with a simple early return if delayed bugs are present.
- Changes `DiagCtxtInner::drop` and `DiagCtxtInner::flush_delayed` so
  they both assert that the stashed diagnostics are empty (i.e.
  processed beforehand).
- Changes `interface::run_compiler` so that any errors emitted during
  `finish_diagnostics` (i.e. late-emitted stashed diagnostics) are
  counted and cannot be overlooked. This requires adding
  `ErrorGuaranteed` return values to several functions.
- Removes the `stashed_err_count` call in `analysis`. This is possible
  now that we don't have to worry about calling `flush_delayed` early
  from `codegen_and_build_linker` when stashed diagnostics are pending.
- Changes the `span_bug` case in `handle_tuple_field_pattern_match` to a
  `delayed_span_bug`, because it now can be reached due to the removal
  of the `stashed_err_count` call in `analysis`.
- Slightly changes the expected output of three tests. If no errors are
  emitted but there are delayed bugs, the error count is no longer
  printed. This is because delayed bugs are now always printed after the
  error count is printed (or not printed, if the error count is zero).

There is a lot going on in this commit. It's hard to break into smaller
pieces because the existing code is very tangled. It took me a long time
and a lot of effort to understand how the different pieces interact, and
I think the new code is a lot simpler and easier to understand.
Because it's now simple enough that it doesn't provide much benefit.
It currently is infallible and uses `abort_if_errors` and
`FatalError.raise()` to signal errors. It's easy to instead return a
`Result<_, ErrorGuaranteed>`, which is the more usual way of doing
things.
Replace `abort_if_errors` calls that are certain to abort -- because
we emit an error immediately beforehand -- with `FatalErro.raise()`.
It's clumsy and doesn't improve readability.
It is a clearer name because it communicates what the lint does
instead of the underlying mechanism it uses (const propagation).
resolve: Scale back unloading of speculatively loaded crates

Fixes rust-lang#120830 and fixes rust-lang#120909 while still unblocking rust-lang#117772.

I cannot reproduce https://github.com/parasyte/crash-rustc as an UI test for some reason, but I tested all the cases linked above manually.
…aethlin

Always inline check in `assert_unsafe_precondition` with cfg(debug_assertions)

The current complexities in `assert_unsafe_precondition` are delicately balancing several concerns, among them compile times for the cases where there are no debug assertions. This comes at a large runtime cost when the assertions are enabled, making the debug assertion compiler a lot slower, which is very annoying.

To avoid this, we always inline the check when building with debug assertions.

Numbers (compiling stage1 library after touching core):
- master: 80s
- just adding `#[inline(always)]` to the `cfg(bootstrap)` `debug_assertions` (equivalent to a bootstrap bump (uhh, i just realized that i was on a slightly outdated master so this bump might have happened already), (rust-lang#121112)): 67s
- this: 54s

So this seems like a good solution. I think we can still get the same run-time perf improvements for other users too by massaging this code further (see my other PR about adding `#[rustc_no_mir_inline]` rust-lang#121114) but this is a simpler step that solves the imminent problem of "holy shit my rustc is sooo slow".

Funny consequence: This now means compiling the standard library with dbeug assertions makes it faster (than without, when using debug assertions downstream)!

r? ``@saethlin`` (or anyone else if someone wants to review this)

fixes rust-lang#121110, supposedly
…ng, r=oli-obk

Top level error handling

The interactions between the following things are surprisingly complicated:
- `emit_stashed_diagnostics`,
- `flush_delayed`,
- normal return vs `abort_if_errors`/`FatalError.raise()` unwinding in the call to the closure in `interface::run_compiler`.

This PR disentangles it all.

r? ``@oli-obk``
…s, r=dtolnay

Implement `NonZero` traits generically.

Tracking issue: rust-lang#120257

r? ```@dtolnay```
…y789

Remove the "codegen" profile from bootstrap

This profile originally made sense when download-ci-llvm = if-unchanged didn't exist and we had the bad tradeoff of "never modify or always compile".

Thankfully, these grim times are over and we have discovered clean water, so the only differentiator between the two profiles is the codegen profile having LLVM assertions. Adding them doesn't cause that much of a slowdown, <10% on UI tests from an unscientific benchmark.

It also had LLVM warnings when compiling, which makes sense for every compiler contributor brave enough to compile LLVM.

The way I removed is by just issueing a nice error message. Given that everyone with this profile should be a contributor and not someone like a distro who is more upset when things break, this should be fine. If it isn't, we can always fall back to just letting codegen mean compiler.
…-obk

Rename `ConstPropLint` to `KnownPanicsLint`

`OverflowLint` is a clearer name because it communicates what the lint does instead of the underlying mechanism it uses (const propagation) which should be of secondary concern.

`OverflowLint` isn't the most accurate name because the lint looks for other errors as well such as division by zero not just overflows, but I couldn't think of another equally succinct name.

As a part of this change. I've also added/updated some of the comments.

cc ``@RalfJung`` ``@oli-obk`` for visibility in case you go looking for the lint using the old name.

Edit:

Changed the name from `OverflowLint` to `KnownPanicsLint`
…strieb

target: Revert default to the medium code model on LoongArch targets

This reverts commit 35dad14.

Fixes rust-lang#121289
Remove `RefMutL` hack in `proc_macro::bridge`

From what I can tell, rust-lang#52812 is now fixed, so there is no longer any need to keep this hack around.
@rustbot rustbot added A-meta Area: Issues & PRs about the rust-lang/rust repository itself A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 20, 2024
@rustbot rustbot added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. rollup A PR which is a rollup labels Feb 20, 2024
@Noratrieb
Copy link
Member Author

@bors r+ rollup=never p=8

@bors
Copy link
Contributor

bors commented Feb 20, 2024

📌 Commit 8957df0 has been approved by Nilstrieb

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 Feb 20, 2024
@bors
Copy link
Contributor

bors commented Feb 20, 2024

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout rollup-796zjsf (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self rollup-796zjsf --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
Removing src/bootstrap/defaults/config.codegen.toml
Auto-merging compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs
CONFLICT (content): Merge conflict in compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs
Auto-merging compiler/rustc_errors/src/lib.rs
Automatic merge failed; fix conflicts and then commit the result.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 20, 2024
@Noratrieb
Copy link
Member Author

:(

@Noratrieb Noratrieb closed this Feb 20, 2024
@Noratrieb Noratrieb deleted the rollup-796zjsf branch February 20, 2024 14:14
@bors
Copy link
Contributor

bors commented Feb 20, 2024

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

@Noratrieb
Copy link
Member Author

thanks bors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-meta Area: Issues & PRs about the rust-lang/rust repository itself A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) rollup A PR which is a rollup S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants