Commit Graph

246706 Commits

Author SHA1 Message Date
bjorn3
f25c90a83f Unify dylib loading between proc macros and codegen backends
As bonus this makes the errors when failing to load a proc macro more
informative to match the backend loading errors. In addition it makes it
slightly easier to patch rustc to work on platforms that don't support
dynamic linking like wasm.
2024-02-21 11:17:07 +00:00
bors
0987e41d1c Auto merge of #121380 - weihanglo:update-cargo, r=weihanglo
Update cargo

9 commits in 7b7af3077bff8d60b7f124189bc9de227d3063a9..194a60b2952bd5d12ba15dd2577a97eed7d3c587
2024-02-17 14:13:00 +0000 to 2024-02-21 01:53:45 +0000
- fix: remove unused `sysroot_host_libdir` (rust-lang/cargo#13468)
- feat: support `target.<triple>.rustdocflags` officially (rust-lang/cargo#13197)
- Fix unused imports on Windows. (rust-lang/cargo#13469)
- Fix more redundant imports. (rust-lang/cargo#13466)
- test: Remove empty snapshots (rust-lang/cargo#13465)
- chore: Rename `Config` to `GlobalContext` (rust-lang/cargo#13409)
- Fix redundant imports. (rust-lang/cargo#13464)
- feat: respect `rust-version` when generating lockfile (rust-lang/cargo#12861)
- chore(ci): bump CI tools (rust-lang/cargo#13459)

r? ghost
2024-02-21 05:16:38 +00:00
Weihang Lo
bb1f70048f
Update cargo 2024-02-21 00:01:34 -05:00
bors
096598dc79 Auto merge of #121172 - Nadrieril:simplify-empty-selection, r=matthewjasper
match lowering: simplify empty candidate selection

In match lowering, `match_simplified_candidates` is tasked with removing candidates that are fully matched and linking them up properly. The code that does that was needlessly complicated; this PR simplifies it.

The overall change isn't big but I split it up into tiny commits to convince myself that I was correctly preserving behavior. The test changes are all due to the first commit. Let me know if you'd prefer me to split up the PR to make reviewing easier.

r? `@matthewjasper`
2024-02-21 03:11:24 +00:00
bors
4e65074933 Auto merge of #120904 - Nadrieril:match-lowering-intermediate-repr, r=matthewjasper
match lowering: eagerly simplify match pairs

This removes one important complication from match lowering. Before this, match pair simplification (which includes collecting bindings and type ascriptions) was intertwined with the whole match lowering algorithm.

I'm avoiding this by storing in each `MatchPair` the sub-`MatchPair`s that correspond to its subfields. This makes it possible to simplify everything (except or-patterns) in `Candidate::new()`.

This should open up further simplifications. It will also give us proper control over the order of bindings.

r? `@matthewjasper`
2024-02-21 01:11:34 +00:00
bors
2dc0170233 Auto merge of #121356 - matthiaskrgr:rollup-d80af2s, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #119203 (Correct the simd_masked_{load,store} intrinsic docs)
 - #121277 (Refactor trait implementations in `core::convert::num`.)
 - #121322 (Don't ICE when hitting overflow limit in fulfillment loop in next solver)
 - #121323 (Don't use raw parameter types in `find_builder_fn`)
 - #121344 (Expand weak alias types before collecting constrained/referenced late bound regions + refactorings)
 - #121350 (Fix stray trait mismatch in `resolve_associated_item` for `AsyncFn`)
 - #121352 (docs: add missing "the" to `str::strip_prefix` doc)

Failed merges:

 - #121340 (bootstrap: apply most of clippy's suggestions)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-20 22:55:07 +00:00
Matthias Krüger
c03f61ba69
Rollup merge of #121352 - malobre:patch-1, r=Nilstrieb
docs: add missing "the" to `str::strip_prefix` doc

Fix #121348
2024-02-20 19:35:42 +01:00
Matthias Krüger
433180e0cb
Rollup merge of #121350 - compiler-errors:resolve, r=oli-obk
Fix stray trait mismatch in `resolve_associated_item` for `AsyncFn`

Copy-paste error meant that we were calling `fn_trait_kind_from_def_id` instead of `async_fn_trait_kind_from_def_id`. But turns out we don't even need to do that, since we already matched the trait def id above.

Fixes #121306

r? oli-obk
2024-02-20 19:35:42 +01:00
Matthias Krüger
532b3eacb7
Rollup merge of #121344 - fmease:lta-constr-by-input, r=oli-obk
Expand weak alias types before collecting constrained/referenced late bound regions + refactorings

Fixes #114220.
Follow-up to #120780.

r? `@oli-obk`
2024-02-20 19:35:41 +01:00
Matthias Krüger
e3ff2a8e38
Rollup merge of #121323 - compiler-errors:raw-param-types, r=oli-obk
Don't use raw parameter types in `find_builder_fn`

We shouldn't really ever be using `EarlyBinder::skip_binder` then performing type equality, since param types will never be equal to other types. When checking compatibility with the signature, we instead create some fresh args.

Fixes #121314
2024-02-20 19:35:41 +01:00
Matthias Krüger
d43fd29bf2
Rollup merge of #121322 - compiler-errors:next-solver-fulfillment-ice, r=lcnr
Don't ICE when hitting overflow limit in fulfillment loop in next solver

As the title says, let's not ICE when hitting the overflow limit in fulfill. On the other hand, we don't want to treat these as true errors, since it means that whether something is considered a true error or an ambiguity is dependent on overflow handling in the solver, which seems not worth it.

Now that we use the presence of true errors in fulfillment for implicit negative coherence, we especially don't want to tie together coherence and overflow.

I guess I could also drain these errors out of fulfillment and put them into some `ambiguities` storage so we could return them in `select_all_or_error` without having to re-process them every time we call `select_where_possible`. Let me know if that's desired.

r? lcnr
2024-02-20 19:35:40 +01:00
Matthias Krüger
3099a7931a
Rollup merge of #121277 - reitermarkus:generic-nonzero-convert-num, r=dtolnay
Refactor trait implementations in `core::convert::num`.

Tracking issue: https://github.com/rust-lang/rust/issues/120257

Implement conversion traits using generic `NonZero` type, and refactor all macros to use a consistent format/order of parameters.

r? `@dtolnay`
2024-02-20 19:35:40 +01:00
Matthias Krüger
fc5f6f88e5
Rollup merge of #119203 - farnoy:simd-masked-intrinsic-docfix, r=RalfJung
Correct the simd_masked_{load,store} intrinsic docs

Explains the uniform pointer being used for these two operations and how elements are offset from it.
2024-02-20 19:35:39 +01:00
Malobre
9ac73cbdc6
docs: add missing "the" to str::strip_prefix doc 2024-02-20 18:05:55 +01:00
León Orell Valerian Liehr
f515f99e91
Move the peeling function for weak alias types 2024-02-20 17:32:01 +01:00
León Orell Valerian Liehr
1b3df6f068
Use expand_weak_alias_tys when collecting constrained generics params in impls 2024-02-20 17:31:59 +01:00
León Orell Valerian Liehr
da01cced15
Expand weak alias types before collecting constrained and referenced late bound regions 2024-02-20 17:31:54 +01:00
León Orell Valerian Liehr
515d805a0e
Introduce expand_weak_alias_tys 2024-02-20 17:31:49 +01:00
León Orell Valerian Liehr
05ce209d20
Rename some normalization-related items 2024-02-20 17:30:49 +01:00
bors
bb594538fc Auto merge of #121345 - Nilstrieb:rollup-reb0xge, r=Nilstrieb
Rollup of 8 pull requests

Successful merges:

 - #121167 (resolve: Scale back unloading of speculatively loaded crates)
 - #121196 (Always inline check in `assert_unsafe_precondition` with cfg(debug_assertions))
 - #121241 (Implement `NonZero` traits generically.)
 - #121278 (Remove the "codegen" profile from bootstrap)
 - #121286 (Rename `ConstPropLint` to `KnownPanicsLint`)
 - #121291 (target: Revert default to the medium code model on LoongArch targets)
 - #121302 (Remove `RefMutL` hack in `proc_macro::bridge`)
 - #121318 (Trigger `unsafe_code` lint on invocations of `global_asm`)

Failed merges:

 - #121206 (Top level error handling)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-20 16:22:48 +00:00
Jakub Okoński
14a4551695
Correct the simd_masked_{load,store} intrinsic docs 2024-02-20 17:03:24 +01:00
Nadrieril
a45d8925b8 Upgrade a debug_assert to assert 2024-02-20 16:53:16 +01:00
Michael Goulet
762febdaf3 Fix stray trait mismatch in resolve_associated_item for AsyncFn 2024-02-20 15:45:05 +00:00
Nilstrieb
d61adbffe1
Rollup merge of #121318 - kadiwa4:no_assembly_in_supposedly_safe_code, r=Nilstrieb
Trigger `unsafe_code` lint on invocations of `global_asm`

`unsafe_code` already warns about things that don't involve the `unsafe` keyword, e.g. `#[no_mangle]`. This makes it warn on `core::arch::global_asm` too.

Fixes #103078
2024-02-20 15:13:55 +01:00
Nilstrieb
739f83d906
Rollup merge of #121302 - GrigorenkoPV:refmutl, r=bjorn3
Remove `RefMutL` hack in `proc_macro::bridge`

From what I can tell, #52812 is now fixed, so there is no longer any need to keep this hack around.
2024-02-20 15:13:54 +01:00
Nilstrieb
5540d817e3
Rollup merge of #121291 - heiher:revert-medium-cmodel, r=Nilstrieb
target: Revert default to the medium code model on LoongArch targets

This reverts commit 35dad14dfb.

Fixes #121289
2024-02-20 15:13:54 +01:00
Nilstrieb
bc7489c546
Rollup merge of #121286 - gurry:constprop-lint-rename, r=oli-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`
2024-02-20 15:13:53 +01:00
Nilstrieb
c5d2159dec
Rollup merge of #121278 - Nilstrieb:no-more-codegen, r=clubby789
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.
2024-02-20 15:13:52 +01:00
Nilstrieb
f6b4080592
Rollup merge of #121241 - reitermarkus:generic-nonzero-traits, r=dtolnay
Implement `NonZero` traits generically.

Tracking issue: https://github.com/rust-lang/rust/issues/120257

r? ````@dtolnay````
2024-02-20 15:13:52 +01:00
Nilstrieb
4ff6bb51e2
Rollup merge of #121196 - Nilstrieb:the-clever-solution, r=saethlin
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), (#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]` #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 #121110, supposedly
2024-02-20 15:13:51 +01:00
Nilstrieb
073d2983a4
Rollup merge of #121167 - petrochenkov:unload2, r=wesleywiser
resolve: Scale back unloading of speculatively loaded crates

Fixes https://github.com/rust-lang/rust/issues/120830 and fixes https://github.com/rust-lang/rust/issues/120909 while still unblocking https://github.com/rust-lang/rust/pull/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.
2024-02-20 15:13:50 +01:00
bors
2b43e75c98 Auto merge of #120863 - saethlin:slice-get-checked, r=the8472
Use intrinsics::debug_assertions in debug_assert_nounwind

This is the first item in https://github.com/rust-lang/rust/issues/120848.

Based on the benchmarking in this PR, it looks like, for the programs in our benchmark suite, enabling all these additional checks does not introduce significant compile-time overhead, with the single exception of `Alignment::new_unchecked`. Therefore, I've added `#[cfg(debug_assertions)]` to that one call site, so that it remains compiled out in the distributed standard library.

The trailing commas in the previous calls to `debug_assert_nounwind!` were causing the macro to expand to `panic_nouwnind_fmt`, which requires more work to set up its arguments, and that overhead alone is measured between this perf run and the next: https://github.com/rust-lang/rust/pull/120863#issuecomment-1937423502
2024-02-20 14:04:57 +00:00
bors
29f87ade9d Auto merge of #120576 - nnethercote:merge-Diagnostic-DiagnosticBuilder, r=davidtwco
Overhaul `Diagnostic` and `DiagnosticBuilder`

Implements the first part of https://github.com/rust-lang/compiler-team/issues/722, which moves functionality and use away from `Diagnostic`, onto `DiagnosticBuilder`.

Likely follow-ups:
- Move things around, because this PR was written to minimize diff size, so some things end up in sub-optimal places. E.g. `DiagnosticBuilder` has impls in both `diagnostic.rs` and `diagnostic_builder.rs`.
- Rename `Diagnostic` as `DiagInner` and `DiagnosticBuilder` as `Diag`.

r? `@davidtwco`
2024-02-20 12:05:09 +00:00
bors
cce6a6e22e Auto merge of #121087 - oli-obk:eager_const_failures, r=lcnr
Always evaluate free constants and statics, even if previous errors occurred

work towards https://github.com/rust-lang/rust/issues/79738

We will need to evaluate static items before the `definitions.freeze()` below, as we will start creating new `DefId`s (for nested allocations) within the `eval_static_initializer` query.

But even without that motivation, this is a good change. Hard errors should always be reported and not silenced if other errors happened earlier.
2024-02-20 09:02:34 +00:00
bors
5af2130440 Auto merge of #121327 - Nilstrieb:rollup-zxcwwwy, r=Nilstrieb
Rollup of 10 pull requests

Successful merges:

 - #120716 (Change leak check and suspicious auto trait lint warning messages)
 - #121195 (unstable-book: Separate testing and production sanitizers)
 - #121205 (Merge `CompilerError::CompilationFailed` and `CompilerError::ICE`.)
 - #121233 (Move the extra directives for `Mode::CoverageRun` into `iter_header`)
 - #121256 (Allow AST and HIR visitors to return `ControlFlow`)
 - #121307 (Drive-by `DUMMY_SP` -> `Span` and fmt changes)
 - #121308 (Add regression test for #103369)
 - #121310 (Remove an old hack for rustdoc)
 - #121311 (Make `is_nonoverlapping` `#[inline]`)
 - #121319 (return `ty::Error` when equating `ty::Error`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-20 06:56:41 +00:00
Nilstrieb
599768d930
Rollup merge of #121319 - compiler-errors:err, r=oli-obk
return `ty::Error` when equating `ty::Error`

This helps iron out a difference in diagnostics between `Sub` and `Equate` relations, which I'm currently trying to unify.

r? oli-obk
2024-02-20 07:35:49 +01:00
Nilstrieb
9788b192bb
Rollup merge of #121311 - Nilstrieb:is-it-overlapping, r=saethlin
Make `is_nonoverlapping` `#[inline]`

It showed up with 3% execution time in a compiler profile.

backlink to #120848

r? ``@saethlin``
2024-02-20 07:35:48 +01:00
Nilstrieb
dcb7c6919f
Rollup merge of #121310 - GrigorenkoPV:doc-smallfix, r=Nilstrieb
Remove an old hack for rustdoc

Since #78696 has been resolved
2024-02-20 07:35:48 +01:00
Nilstrieb
930566fe1a
Rollup merge of #121308 - kadiwa4:test_103369, r=TaKO8Ki
Add regression test for #103369

The issue was fixed in 1.70.0.
Closes #103369.
2024-02-20 07:35:48 +01:00
Nilstrieb
ac030bcf05
Rollup merge of #121307 - estebank:drive-by, r=compiler-errors
Drive-by `DUMMY_SP` -> `Span` and fmt changes

Noticed these while doing something else. There's no practical change, but it's preferable to use `DUMMY_SP` as little as possible, particularly when we have perfectlly useful `Span`s available.
2024-02-20 07:35:47 +01:00
Nilstrieb
46cab11ed1
Rollup merge of #121256 - Jarcho:visitor2, r=oli-obk
Allow AST and HIR visitors to return `ControlFlow`

Alternative to #108598.

Since rust-lang/libs-team#187 was rejected, this implements our own version of the `Try` trait (`VisitorResult`) and the `try` macro (`try_visit`). Since this change still allows visitors to return `()`, no changes have been made to the existing ones. They can be done in a separate PR.
2024-02-20 07:35:47 +01:00
Nilstrieb
4131f6e730
Rollup merge of #121233 - Zalathar:extra-directives, r=oli-obk
Move the extra directives for `Mode::CoverageRun` into `iter_header`

When these extra directives were ported over as part of #112300, it made sense to introduce `iter_header_extra` and pass them in as an extra argument.

But now that #120881 has added a `mode` parameter to `iter_header` for its own purposes, it's slightly simpler to move the coverage special-case code directly into `iter_header` as well. This lets us get rid of `iter_header_extra`.
2024-02-20 07:35:46 +01:00
Nilstrieb
328a5b7719
Rollup merge of #121205 - nnethercote:fix-stable-mir-CompilerError, r=oli-obk
Merge `CompilerError::CompilationFailed` and `CompilerError::ICE`.

`CompilerError` has `CompilationFailed` and `ICE` variants, which seems reasonable at first. But the way it identifies them is flawed:
- If compilation errors out, i.e. `RunCompiler::run` returns an `Err`, it uses `CompilationFailed`, which is reasonable.
- If compilation panics with `FatalError`, it catches the panic and uses `ICE`. This is sometimes right, because ICEs do cause `FatalError` panics, but sometimes wrong, because certain compiler errors also cause `FatalError` panics. (The compiler/rustdoc/clippy/whatever just catches the `FatalError` with `catch_with_exit_code` in `main`.)

In other words, certain non-ICE compilation failures get miscategorized as ICEs. It's not possible to reliably distinguish the two cases, so this commit merges them. It also renames the combined variant as just `Failed`, to better match the existing `Interrupted` and `Skipped` variants.

Here is an example of a non-ICE failure that causes a `FatalError` panic, from `tests/ui/recursion_limit/issue-105700.rs`:
```
 #![recursion_limit="4"]
 #![invalid_attribute]
 #![invalid_attribute]
 #![invalid_attribute]
 #![invalid_attribute]
 #![invalid_attribute]
 //~^ERROR recursion limit reached while expanding

 fn main() {{}}
```

r? ``@spastorino``
2024-02-20 07:35:46 +01:00
Nilstrieb
4c2af78778
Rollup merge of #121195 - D0liphin:master, r=ehuss
unstable-book: Separate testing and production sanitizers

This is a redo of [this PR](https://github.com/rust-lang/rust/pull/108942). Left the commit as before (except for reflowing to 80-width), since it already got approved.
2024-02-20 07:35:45 +01:00
Nilstrieb
5b8b435d5d
Rollup merge of #120716 - spastorino:change-some-lint-msgs, r=lcnr
Change leak check and suspicious auto trait lint warning messages

The leak check lint message "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!" is misleading as some cases may not be phased out and could end being accepted. This is under discussion still.

The suspicious auto trait lint the change in behavior already happened, so the new message is probably more accurate.

r? `@lcnr`

Closes #93367
2024-02-20 07:35:45 +01:00
bors
bcea3cb748 Auto merge of #120692 - Nadrieril:move-column-analysis-to-placeinfo, r=compiler-errors
pattern_analysis: Move constructor selection logic to `PlaceInfo`

This is a small refactor PR. There was a dense bit of constructor-related logic in `compute_exhaustiveness_and_usefulness`. I'm moving it out into a `PlaceInfo` method to make it easier to follow both separately. I also have plans that will complicate it further so it's good that it's somewhat encapsulated.

r? `@compiler-errors`
2024-02-20 04:57:15 +00:00
Michael Goulet
1c80aadb05 test 2024-02-20 03:01:35 +00:00
Michael Goulet
18fdf59bf5 Don't use raw parameter types in find_builder_fn 2024-02-20 02:58:07 +00:00
bors
0b9f6ad994 Auto merge of #120628 - workingjubilee:reimpl-meaningful-test-name-lint, r=compiler-errors
Reimpl meaningful test name lint MCP658

This reintroduces the tidy rule originally proposed in https://github.com/rust-lang/rust/pull/113583 that then became an MCP in https://github.com/rust-lang/compiler-team/issues/658 which eventually surfaced a quite-reasonable request for a diagnostic enhancement. I have added that to the rule. It produces output like this:
```
tidy error: file `ui/unsized/issue-115809.rs` must begin with a descriptive name, try `{reason}-issue-115809.rs`
tidy error: file `ui/unsized/issue-115203.rs` must begin with a descriptive name, try `{reason}-issue-115203.rs`
tidy error: file `ui/privacy/issue-113860-2.rs` must begin with a descriptive name, try `{reason}-issue-113860.rs`
tidy error: file `ui/privacy/issue-117997.rs` must begin with a descriptive name, try `{reason}-issue-117997.rs`
tidy error: file `ui/privacy/issue-119463.rs` must begin with a descriptive name, try `{reason}-issue-119463.rs`
tidy error: file `ui/privacy/auxiliary/issue-117997.rs` must begin with a descriptive name, try `{reason}-issue-117997.rs`
tidy error: file `ui/privacy/auxiliary/issue-119463-extern.rs` must begin with a descriptive name, try `{reason}-issue-119463.rs`
tidy error: file `ui/privacy/issue-113860-1.rs` must begin with a descriptive name, try `{reason}-issue-113860.rs`
tidy error: file `ui/privacy/issue-113860.rs` must begin with a descriptive name, try `{reason}-issue-113860.rs`
tidy error: file `ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.rs` must begin with a descriptive name, try `{reason}-issue-114151.rs`
tidy error: file `ui/did_you_mean/issue-114112.rs` must begin with a descriptive name, try `{reason}-issue-114112.rs`
tidy error: file `ui/did_you_mean/issue-105225.rs` must begin with a descriptive name, try `{reason}-issue-105225.rs`
tidy error: file `ui/did_you_mean/issue-105225-named-args.rs` must begin with a descriptive name, try `{reason}-issue-105225.rs`
```

You get the idea.

There are some tests which merely would require reordering of the name according to the rule. I could modify the diagnostic further to identify those, but doing such would make it prone to bad suggestions. I have opted to trust contributors to recognize the diagnostic is robotic, as the pattern we are linting on is easier to match if we do not speculate on what parts of the name are meaningful: sometimes a word is a reason, but sometimes it is a mere "tag", such as with a pair like:
- issue-314159265-blue.rs
- issue-314159265-red.rs

Starting them with `red-` and `blue-` means they do not sort together, despite being related, and the color names are still not very descriptive. Recognizing a good name is an open-ended task, though this pair might be:
- colored-circle-gen-blue.rs
- colored-circle-gen-red.rs

Deciding exactly *how* to solve this is not the business of tidy, only recognizing a what.

r? `@compiler-errors`
2024-02-20 02:31:17 +00:00
Nicholas Nethercote
f6f8779843 Reduce capabilities of Diagnostic.
Currently many diagnostic modifier methods are available on both
`Diagnostic` and `DiagnosticBuilder`. This commit removes most of them
from `Diagnostic`. To minimize the diff size, it keeps them within
`diagnostic.rs` but changes the surrounding `impl Diagnostic` block to
`impl DiagnosticBuilder`. (I intend to move things around later, to give
a more sensible code layout.)

`Diagnostic` keeps a few methods that it still needs, like `sub`,
`arg`, and `replace_args`.

The `forward!` macro, which defined two additional methods per call
(e.g. `note` and `with_note`), is replaced by the `with_fn!` macro,
which defines one additional method per call (e.g. `with_note`). It's
now also only used when necessary -- not all modifier methods currently
need a `with_*` form. (New ones can be easily added as necessary.)

All this also requires changing `trait AddToDiagnostic` so its methods
take `DiagnosticBuilder` instead of `Diagnostic`, which leads to many
mechanical changes. `SubdiagnosticMessageOp` gains a type parameter `G`.

There are three subdiagnostics -- `DelayedAtWithoutNewline`,
`DelayedAtWithNewline`, and `InvalidFlushedDelayedDiagnosticLevel` --
that are created within the diagnostics machinery and appended to
external diagnostics. These are handled at the `Diagnostic` level, which
means it's now hard to construct them via `derive(Diagnostic)`, so
instead we construct them by hand. This has no effect on what they look
like when printed.

There are lots of new `allow` markers for `untranslatable_diagnostics`
and `diagnostics_outside_of_impl`. This is because
`#[rustc_lint_diagnostics]` annotations were present on the `Diagnostic`
modifier methods, but missing from the `DiagnosticBuilder` modifier
methods. They're now present.
2024-02-20 13:22:17 +11:00