Remove G generic param from Diag<'_, G> - #163083
Conversation
It encodes the `emit` behaviour, one of: - `BugAbort`: Abort as a bug. - `FatalAbort`: Abort as a fatal error. - `ErrorGuaranteed`: Return an `ErrorGuaranteed` (the default). - `()`: return `()`. This is useful but `Diag` is very widely used and it's arguably not useful enough to be worth the generic parameter. This commit removes it. Benefits: - Many fewer generic parameters, including many functions where the genericity is entirely uninteresting. This includes every `Diagnostic::into_diag` and `Subdiagnostic::add_to_diag`. Removes the need for the comment about `<G>` on `trait Diagnostic`. - No `PhantomData` in `Diag`. - Makes bootstrapping a bit faster. The downside is there is no longer a single `emit` method. - Getting a `!` return type requires calling `emit_bug` or `emit_fatal`. This only affects a few call sites. - Getting an `ErrorGuaranteed` return type requires calling `emit_err`. This affects a lot of call sites. (It arguably makes call sites more self-documenting.) - Using the wrong `emit_*` on a diagnostic causes a runtime abort, which previously couldn't occur. Seems unlikely, but it's not impossible. - Note: If no particular return type is needed, `emit` can be used for any diagnostic. (Bug/fatal diagnostics will still trigger abort.)
|
The rustc-dev-guide subtree was changed. If your future PRs only touch the subtree, consider submitting them directly to rust-lang/rustc-dev-guide, which is where the document is primarily maintained (and has faster CI).
cc @rust-lang/clippy Some changes occurred in compiler/rustc_attr_parsing cc @jdonszelmann, @JonathanBrouwer
cc @rust-lang/miri The parser was modified, potentially altering the grammar of (stable) Rust cc @fmease Some changes occurred in match checking cc @Nadrieril Some changes occurred to the CTFE machinery Some changes occurred to constck cc @fee1-dead HIR ty lowering was modified cc @fmease
Some changes occurred in cc @BoxyUwU Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Remove `G` generic param from `Diag<'_, G>`
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (282876a): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 2.2%, secondary -3.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 3.2%, secondary 1.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 496.585s -> 488.23s (-1.68%) |
|
@bors rollup=iffy |
Remove `G` generic param from `Diag<'_, G>` The benefits are outweighed by the costs. Details in invidual commits. some minor earlier discussion about this change in rust-lang#162630 (comment)
…uwer Rollup of 6 pull requests Successful merges: - #163083 (Remove `G` generic param from `Diag<'_, G>`) - #160679 (Staticlib rename internal symbols: add COFF support) - #162007 (Preserve parentheses in raw borrow suggestions) - #163057 (Use span context for enclosing item(s) of unmet bound) - #163070 (label the path segment that is not an associated item of the trait) - #163078 ( Add a README in tests/rustdoc-html to explain what each folder content is for)
|
⌛ Testing commit 30b8dfc with merge 929d979... Workflow: https://github.com/rust-lang/rust/actions/runs/35604359904 |
Remove `G` generic param from `Diag<'_, G>` The benefits are outweighed by the costs. Details in invidual commits. some minor earlier discussion about this change in #162630 (comment)
|
@bors yield |
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #163111. |
…uwer Rollup of 10 pull requests Successful merges: - #163083 (Remove `G` generic param from `Diag<'_, G>`) - #160679 (Staticlib rename internal symbols: add COFF support) - #160859 (`core::num::f16b` Rust's 16bit Brain Float) - #162007 (Preserve parentheses in raw borrow suggestions) - #162821 (Avoid suggesting closures when captures cross associated item boundaries) - #163057 (Use span context for enclosing item(s) of unmet bound) - #163070 (label the path segment that is not an associated item of the trait) - #163078 ( Add a README in tests/rustdoc-html to explain what each folder content is for) - #163107 (Implement Allocator for Pin unstably) - #163108 (remove old solver use of `SolverRelating`)
|
⌛ Testing commit 30b8dfc with merge e4f44de... Workflow: https://github.com/rust-lang/rust/actions/runs/35605678728 |
Remove `G` generic param from `Diag<'_, G>` The benefits are outweighed by the costs. Details in invidual commits. some minor earlier discussion about this change in #162630 (comment)
|
@bors yield |
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #163111. |
…uwer Rollup of 10 pull requests Successful merges: - #163083 (Remove `G` generic param from `Diag<'_, G>`) - #160679 (Staticlib rename internal symbols: add COFF support) - #160859 (`core::num::f16b` Rust's 16bit Brain Float) - #162007 (Preserve parentheses in raw borrow suggestions) - #162821 (Avoid suggesting closures when captures cross associated item boundaries) - #163057 (Use span context for enclosing item(s) of unmet bound) - #163070 (label the path segment that is not an associated item of the trait) - #163078 ( Add a README in tests/rustdoc-html to explain what each folder content is for) - #163107 (Implement Allocator for Pin unstably) - #163108 (remove old solver use of `SolverRelating`)
Rollup merge of #163083 - nnethercote:rm-Diag-G, r=oli-obk Remove `G` generic param from `Diag<'_, G>` The benefits are outweighed by the costs. Details in invidual commits. some minor earlier discussion about this change in #162630 (comment)
…uwer Rollup of 10 pull requests Successful merges: - rust-lang/rust#163083 (Remove `G` generic param from `Diag<'_, G>`) - rust-lang/rust#160679 (Staticlib rename internal symbols: add COFF support) - rust-lang/rust#160859 (`core::num::f16b` Rust's 16bit Brain Float) - rust-lang/rust#162007 (Preserve parentheses in raw borrow suggestions) - rust-lang/rust#162821 (Avoid suggesting closures when captures cross associated item boundaries) - rust-lang/rust#163057 (Use span context for enclosing item(s) of unmet bound) - rust-lang/rust#163070 (label the path segment that is not an associated item of the trait) - rust-lang/rust#163078 ( Add a README in tests/rustdoc-html to explain what each folder content is for) - rust-lang/rust#163107 (Implement Allocator for Pin unstably) - rust-lang/rust#163108 (remove old solver use of `SolverRelating`)
…uwer Rollup of 10 pull requests Successful merges: - rust-lang/rust#163083 (Remove `G` generic param from `Diag<'_, G>`) - rust-lang/rust#160679 (Staticlib rename internal symbols: add COFF support) - rust-lang/rust#160859 (`core::num::f16b` Rust's 16bit Brain Float) - rust-lang/rust#162007 (Preserve parentheses in raw borrow suggestions) - rust-lang/rust#162821 (Avoid suggesting closures when captures cross associated item boundaries) - rust-lang/rust#163057 (Use span context for enclosing item(s) of unmet bound) - rust-lang/rust#163070 (label the path segment that is not an associated item of the trait) - rust-lang/rust#163078 ( Add a README in tests/rustdoc-html to explain what each folder content is for) - rust-lang/rust#163107 (Implement Allocator for Pin unstably) - rust-lang/rust#163108 (remove old solver use of `SolverRelating`)
…uwer Rollup of 10 pull requests Successful merges: - rust-lang/rust#163083 (Remove `G` generic param from `Diag<'_, G>`) - rust-lang/rust#160679 (Staticlib rename internal symbols: add COFF support) - rust-lang/rust#160859 (`core::num::f16b` Rust's 16bit Brain Float) - rust-lang/rust#162007 (Preserve parentheses in raw borrow suggestions) - rust-lang/rust#162821 (Avoid suggesting closures when captures cross associated item boundaries) - rust-lang/rust#163057 (Use span context for enclosing item(s) of unmet bound) - rust-lang/rust#163070 (label the path segment that is not an associated item of the trait) - rust-lang/rust#163078 ( Add a README in tests/rustdoc-html to explain what each folder content is for) - rust-lang/rust#163107 (Implement Allocator for Pin unstably) - rust-lang/rust#163108 (remove old solver use of `SolverRelating`)

The benefits are outweighed by the costs. Details in invidual commits.
some minor earlier discussion about this change in #162630 (comment)