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

Overhaul Diagnostic and DiagnosticBuilder #120576

Merged
merged 2 commits into from
Feb 20, 2024

Conversation

nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Feb 2, 2024

Implements the first part of rust-lang/compiler-team#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

@rustbot rustbot added A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 2, 2024
@rustbot
Copy link
Collaborator

rustbot commented Feb 2, 2024

rustc_macros::diagnostics was changed

cc @davidtwco, @compiler-errors, @TaKO8Ki

Some changes might have occurred in exhaustiveness checking

cc @Nadrieril

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rustbot rustbot added T-compiler Relevant to the compiler 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. labels Feb 2, 2024
@nnethercote nnethercote marked this pull request as draft February 2, 2024 06:51
@nnethercote nnethercote changed the title Merge diagnostic diagnostic builder Overhaul Diagnostic and DiagnosticBuilder Feb 2, 2024
@rust-log-analyzer

This comment has been minimized.

@bors

This comment was marked as resolved.

@nnethercote nnethercote force-pushed the merge-Diagnostic-DiagnosticBuilder branch from a9e8c80 to 76be22d Compare February 6, 2024 09:26
@rust-log-analyzer

This comment has been minimized.

@nnethercote nnethercote force-pushed the merge-Diagnostic-DiagnosticBuilder branch from 76be22d to 008e4b8 Compare February 6, 2024 10:27
@rust-log-analyzer

This comment has been minimized.

@nnethercote nnethercote force-pushed the merge-Diagnostic-DiagnosticBuilder branch from 008e4b8 to bbdf6fd Compare February 6, 2024 21:28
@rust-log-analyzer

This comment has been minimized.

@nnethercote nnethercote force-pushed the merge-Diagnostic-DiagnosticBuilder branch 2 times, most recently from 1cc4994 to 90f2b64 Compare February 6, 2024 22:23
@rust-log-analyzer

This comment has been minimized.

@nnethercote nnethercote force-pushed the merge-Diagnostic-DiagnosticBuilder branch 2 times, most recently from d4ae95d to 18e2e92 Compare February 7, 2024 06:28
@bors

This comment was marked as resolved.

@nnethercote nnethercote force-pushed the merge-Diagnostic-DiagnosticBuilder branch from 18e2e92 to 40fb7d5 Compare February 8, 2024 03:16
@nnethercote nnethercote marked this pull request as ready for review February 8, 2024 03:19
@rustbot
Copy link
Collaborator

rustbot commented Feb 8, 2024

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@nnethercote
Copy link
Contributor Author

@bors try

@bors
Copy link
Contributor

bors commented Feb 8, 2024

⌛ Trying commit 40fb7d5 with merge dcb3508...

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 8, 2024
…ticBuilder, r=<try>

Overhaul `Diagnostic` and `DiagnosticBuilder`

Implements the first part of rust-lang/compiler-team#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? `@ghost`
@bors
Copy link
Contributor

bors commented Feb 8, 2024

☀️ Try build successful - checks-actions
Build commit: dcb3508 (dcb3508f801971ecd3d274efc644c3f4229af03c)

@nnethercote nnethercote force-pushed the merge-Diagnostic-DiagnosticBuilder branch from 40fb7d5 to 670cb07 Compare February 12, 2024 21:21
@bors
Copy link
Contributor

bors commented Feb 20, 2024

📌 Commit f6f8779 has been approved by davidtwco

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

⌛ Testing commit f6f8779 with merge 29f87ad...

@bors
Copy link
Contributor

bors commented Feb 20, 2024

☀️ Test successful - checks-actions
Approved by: davidtwco
Pushing 29f87ad to master...

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (29f87ad): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.3% [-0.3%, -0.3%] 1
Improvements ✅
(secondary)
-3.6% [-5.2%, -1.9%] 2
All ❌✅ (primary) -0.3% [-0.3%, -0.3%] 1

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
2.1% [2.1%, 2.1%] 1
Regressions ❌
(secondary)
3.1% [3.0%, 3.2%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.6% [-3.7%, -0.8%] 4
All ❌✅ (primary) 2.1% [2.1%, 2.1%] 1

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.3% [-3.7%, -2.9%] 2
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 639.567s -> 640.822s (0.20%)
Artifact size: 310.63 MiB -> 308.66 MiB (-0.63%)

@nnethercote nnethercote deleted the merge-Diagnostic-DiagnosticBuilder branch February 20, 2024 21:10
fmease added a commit to fmease/rust that referenced this pull request Feb 21, 2024
…rs, r=compiler-errors

Remove `diagnostic_builder.rs`

rust-lang#120576 moved a big chunk of `DiagnosticBuilder`'s functionality out of `diagnostic_builder.rs` into `diagnostic.rs`, which left `DiagnosticBuilder` spread across the two files.

This PR fixes that messiness by merging what remains of `diagnostic_builder.rs` into `diagnostic.rs`.

This is part of rust-lang/compiler-team#722.

r? `@davidtwco`
@SergioBenitez
Copy link
Contributor

I believe this has broken Rocket on nightly. Here's the ICE:

thread 'rustc' panicked at compiler/rustc_errors/src/diagnostic_builder.rs:117:9:
invalid diagnostic level (Warning)
stack backtrace:
   0:     0x7ff40f98caf6 - std::backtrace_rs::backtrace::libunwind::trace::h1eedb42239d9af6b
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7ff40f98caf6 - std::backtrace_rs::backtrace::trace_unsynchronized::hf37e37075d32c152
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ff40f98caf6 - std::sys_common::backtrace::_print_fmt::h089ff4e21712e78d
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7ff40f98caf6 - ::fmt::h249f2f40a85530bd
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7ff40f9dda7c - core::fmt::rt::Argument::fmt::h0aeed2b676ebf5da
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/core/src/fmt/rt.rs:142:9
   5:     0x7ff40f9dda7c - core::fmt::write::h25b3f5340152b6c4
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/core/src/fmt/mod.rs:1120:17
   6:     0x7ff40f98142f - std::io::Write::write_fmt::h8746a81e0adfe285
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/std/src/io/mod.rs:1846:15
   7:     0x7ff40f98c8a4 - std::sys_common::backtrace::_print::hcf22409f3667d346
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7ff40f98c8a4 - std::sys_common::backtrace::print::h7d3fd33863df24d3
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7ff40f98f5eb - std::panicking::default_hook::{{closure}}::h69f3f4f5b3bceec1
  10:     0x7ff40f98f339 - std::panicking::default_hook::hf73563d650f0e118
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/std/src/panicking.rs:292:9
  11:     0x7ff41281a63c - std[38a2ac7f7aa65357]::panicking::update_hook::>::{closure#0}
  12:     0x7ff40f98fd50 -  as core::ops::function::Fn>::call::h0f1d4fd9cb21869d
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/alloc/src/boxed.rs:2030:9
  13:     0x7ff40f98fd50 - std::panicking::rust_panic_with_hook::h55549baaf7aa2e9c
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/std/src/panicking.rs:786:13
  14:     0x7ff40f98fa92 - std::panicking::begin_panic_handler::{{closure}}::ha0f2b022514542bd
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/std/src/panicking.rs:660:13
  15:     0x7ff40f98cfd6 - std::sys_common::backtrace::__rust_end_short_backtrace::h710104fb518da581
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7ff40f98f7c4 - rust_begin_unwind
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/std/src/panicking.rs:648:5
  17:     0x7ff40f9d9f95 - core::panicking::panic_fmt::h98f81ca1314e2b14
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/core/src/panicking.rs:72:14
  18:     0x7ff414aee592 - ::emit_producing_guarantee
  19:     0x7ff413f0b2a4 - > as proc_macro[478832a3ff351ddb]::bridge::server::DispatcherTrait>::dispatch
  20:     0x7ff413f08376 -  as core[9082f35584c4c405]::convert::From<&mut _>>::from::call::::run_bridge_and_client>>::{closure#0}>
  21:     0x7ff3ecde306f - proc_macro::bridge::closure::Closure::call::h98a90dd4c3bd18d9
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/proc_macro/src/bridge/closure.rs:30:18
  22:     0x7ff3ecde306f - proc_macro::bridge::client::FreeFunctions::emit_diagnostic::{{closure}}::h02a3b7ffb0337edf
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/proc_macro/src/bridge/client.rs:238:43
  23:     0x7ff3ecde306f - proc_macro::bridge::client::Bridge::with::{{closure}}::h4a7782b669169a4e
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/proc_macro/src/bridge/client.rs:312:47
  24:     0x7ff3ecde306f - proc_macro::bridge::scoped_cell::ScopedCell::replace::h71fa0068b5643e5f
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/proc_macro/src/bridge/scoped_cell.rs:56:9
  25:     0x7ff3ecde306f - proc_macro::bridge::client::BridgeState::with::{{closure}}::ha67dc0[569](https://github.com/rwf2/Rocket/actions/runs/7985532655/job/21804162579#step:11:570)336188c
                               at /rustc/bb594538fc6e84213a6b8d5e165442[570](https://github.com/rwf2/Rocket/actions/runs/7985532655/job/21804162579#step:11:571)aa48923/library/proc_macro/src/bridge/client.rs:299:35
  26:     0x7ff3ecde306f - std::thread::local::LocalKey::try_with::hf59b7c62c02da428
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/std/src/thread/local.rs:286:16
  27:     0x7ff3ecde306f - std::thread::local::LocalKey::with::h4a285a6948869979
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/std/src/thread/local.rs:262:9
  28:     0x7ff3ecde306f - proc_macro::bridge::client::BridgeState::with::h7efcfe9838a80494
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/proc_macro/src/bridge/client.rs:299:22
  29:     0x7ff3ecde306f - proc_macro::bridge::client::Bridge::with::h1aa91c3ee1cfd06f
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/proc_macro/src/bridge/client.rs:305:9
  30:     0x7ff3ecde306f - proc_macro::bridge::client::FreeFunctions::emit_diagnostic::h1e0a8325d6884b21
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/proc_macro/src/bridge/client.rs:231:17
  31:     0x7ff3ecde306f - proc_macro::diagnostic::Diagnostic::emit::h4d32195130f72312
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/proc_macro/src/diagnostic.rs:173:9
  32:     0x7ff3ecc0cb8c - proc_macro2_diagnostics::diagnostic::Diagnostic::emit_as_tokens::h7376933de7600d53
                               at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-diagnostics-0.10.1/src/diagnostic.rs:185:9
  33:     0x7ff3ecc0cc7e - proc_macro2_diagnostics::diagnostic::Diagnostic::emit_as_item_tokens::hdefbf272558007fd
                               at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-diagnostics-0.10.1/src/diagnostic.rs:193:9
  34:     0x7ff3ecafd3e6 - ::from_meta::h7686f3e587a6c6bc
  35:     0x7ff3ecb53efa -  as devise_core::from_meta::FromMeta>::from_meta::h0aab5359903e7f4d
  36:     0x7ff3ecb78556 - rocket_codegen::attribute::route::parse::_::::from_meta::h44442893fb49c605
  37:     0x7ff3ecb728a3 - rocket_codegen::attribute::route::incomplete_route::h71b825bdcb5b45d4
  38:     0x7ff3ecb7365c - rocket_codegen::attribute::route::route_attribute::hb228309f02baa254
  39:     0x7ff3ecaec0bf - rocket_codegen::put::h9ddfe8d1e9c1b876
  40:     0x7ff3ecadd7b4 - core::ops::function::Fn::call::hb0b2d304bd8ba2ba
  41:     0x7ff3eca86737 - proc_macro::bridge::client::Client<(proc_macro::TokenStream,proc_macro::TokenStream),proc_macro::TokenStream>::expand2::{{closure}}::{{closure}}::h939fd429ff3286cb
  42:     0x7ff3eca817da - proc_macro::bridge::client::run_client::{{closure}}::{{closure}}::{{closure}}::hd4e8941be918b5db
  43:     0x7ff3ecac33f5 - proc_macro::bridge::scoped_cell::ScopedCell::set::{{closure}}::hf03972e6461bce0f
  44:     0x7ff3ecac902e - proc_macro::bridge::scoped_cell::ScopedCell::replace::hce4c1096696e01bb
  45:     0x7ff3eca7f4a9 - proc_macro::bridge::client::run_client::{{closure}}::{{closure}}::h043cd408ee94a581
  46:     0x7ff3ecb03d7f - std::thread::local::LocalKey::try_with::h543e6d9cce3dc718
  47:     0x7ff3eca7e287 - proc_macro::bridge::client::run_client::{{closure}}::hced0a0af3245c14b
  48:     0x7ff3ecad50a0 -  as core::ops::function::FnOnce<()>>::call_once::h0bbe229a4e3be272
  49:     0x7ff3ecb0751c - std::panicking::try::do_call::hdeb2794ce764b7fd
  50:     0x7ff3ecb0fb9b - __rust_try
  51:     0x7ff3ecb069f2 - std::panicking::try::h52b9394acec22072
  52:     0x7ff3eca788da - proc_macro::bridge::client::run_client::h8d2ee80dfdd540c0
  53:     0x7ff3eca86396 - proc_macro::bridge::client::Client<(proc_macro::TokenStream,proc_macro::TokenStream),proc_macro::TokenStream>::expand2::{{closure}}::h6a7d2511[574](https://github.com/rwf2/Rocket/actions/runs/7985532655/job/21804162579#step:11:575)dcc92
  54:     0x7ff3ecb01304 - proc_macro::bridge::selfless_reify::reify_to_extern_c_fn_hrt_bridge::wrapper::h917564c63114f6bb
  55:     0x7ff4142f976b - > as proc_macro[478832a3ff351ddb]::bridge::server::ExecutionStrategy>::run_bridge_and_client::>>
  56:     0x7ff4128a3970 - ::expand
  57:     0x7ff4144df997 - ::fully_expand_fragment
  58:     0x7ff4144d9bb7 - ::expand_crate
  59:     0x7ff4149b0d92 - rustc_interface[d43ea88de449c898]::passes::resolver_for_lowering
  60:     0x7ff4149b0267 - rustc_query_impl[72e671e77ccdc0fd]::plumbing::__rust_begin_short_backtrace::>
  61:     0x7ff4147176ce - rustc_query_system[eb6d0acd22a0ff82]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[72e671e77ccdc0fd]::plumbing::QueryCtxt, false>
  62:     0x7ff414716e4b - rustc_query_impl[72e671e77ccdc0fd]::query_impl::resolver_for_lowering::get_query_non_incr::__rust_end_short_backtrace
  63:     0x7ff414764697 - rustc_interface[d43ea88de449c898]::interface::run_compiler::, rustc_driver_impl[98bdfcf9c8fb7ba2]::run_compiler::{closure#0}>::{closure#0}
  64:     0x7ff4149c1c05 - std[38a2ac7f7aa65357]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[98bdfcf9c8fb7ba2]::run_compiler::{closure#0}>::{closure#0}, core[9082f35584c4c405]::result::Result<(), rustc_span[39701832932d6f53]::ErrorGuaranteed>>::{closure#0}, core[9082f35584c4c405]::result::Result<(), rustc_span[39701832932d6f53]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9082f35584c4c405]::result::Result<(), rustc_span[39701832932d6f53]::ErrorGuaranteed>>
  65:     0x7ff4149c1a32 - <::spawn_unchecked_, rustc_driver_impl[98bdfcf9c8fb7ba2]::run_compiler::{closure#0}>::{closure#0}, core[9082f35584c4c405]::result::Result<(), rustc_span[39701832932d6f53]::ErrorGuaranteed>>::{closure#0}, core[9082f35584c4c405]::result::Result<(), rustc_span[39701832932d6f53]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9082f35584c4c405]::result::Result<(), rustc_span[39701832932d6f53]::ErrorGuaranteed>>::{closure#1} as core[9082f35584c4c405]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  66:     0x7ff40f999725 -  as core::ops::function::FnOnce>::call_once::h8e2928e2096a726d
                               at /rustc/bb[594](https://github.com/rwf2/Rocket/actions/runs/7985532655/job/21804162579#step:11:595)538fc6e84213a6b8d5e165442570aa48923/library/alloc/src/boxed.rs:2016:9
  67:     0x7ff40f999725 -  as core::ops::function::FnOnce>::call_once::h4f25e5317edfd[617](https://github.com/rwf2/Rocket/actions/runs/7985532655/job/21804162579#step:11:618)
                               at /rustc/bb594538fc6e84213a6b8d5e1[654](https://github.com/rwf2/Rocket/actions/runs/7985532655/job/21804162579#step:11:655)42570aa48923/library/alloc/src/boxed.rs:2016:9
  68:     0x7ff40f999725 - std::sys::pal::unix::thread::Thread::new::thread_start::hc7193b55f6b48c9a
                               at /rustc/bb594538fc6e84213a6b8d5e165442570aa48923/library/std/src/sys/pal/unix/thread.rs:108:17
  69:     0x7ff40f694ac3 - 
  70:     0x7ff40f726850 - 
  71:                0x0 - 

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please attach the file at /home/runner/work/Rocket/Rocket/rustc-ice-2024-02-21T07_39_46-10723.txt to your bug report

note: compiler flags: -C embed-bitcode=no -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [resolver_for_lowering] getting the resolver for lowering
end of query stack
error: custom attribute panicked
--> core/codegen/tests/route-format.rs:82:1
|
82 | #[put("/", format = "bar/baz")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: message: invalid diagnostic level (Warning)

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 21, 2024
Rollup merge of rust-lang#121366 - nnethercote:rm-diagnostic_builder.rs, r=compiler-errors

Remove `diagnostic_builder.rs`

rust-lang#120576 moved a big chunk of `DiagnosticBuilder`'s functionality out of `diagnostic_builder.rs` into `diagnostic.rs`, which left `DiagnosticBuilder` spread across the two files.

This PR fixes that messiness by merging what remains of `diagnostic_builder.rs` into `diagnostic.rs`.

This is part of rust-lang/compiler-team#722.

r? `@davidtwco`
nnethercote added a commit to nnethercote/rust that referenced this pull request Feb 22, 2024
`Rustc::emit_diagnostic` reconstructs a diagnostic passed in from the
macro machinery. Currently it uses the type `DiagnosticBuilder<'_,
ErrorGuaranteed>`, which is incorrect, because the diagnostic might be a
warning. And if it is a warning, because of the `ErrorGuaranteed` we end
up calling into `emit_producing_error_guaranteed` and the assertion
within that function (correctly) fails because the level is not an error
level.

The fix is simple: change the type to `DiagnosticBuilder<'_, ()>`. Using
`()` works no matter what the diagnostic level is, and we don't need an
`ErrorGuaranteed` here.

The panic was reported in rust-lang#120576.
@nnethercote
Copy link
Contributor Author

I believe this has broken Rocket on nightly.

Thanks for the report, #121427 should fix it.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 22, 2024
Fix panic when compiling `Rocket`.

This panic was reported [here](rust-lang#120576 (comment)).

r? `@oli-obk`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 22, 2024
Fix panic when compiling `Rocket`.

This panic was reported [here](rust-lang#120576 (comment)).

r? ``@oli-obk``
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 22, 2024
Rollup merge of rust-lang#121427 - nnethercote:fix-Rocket, r=oli-obk

Fix panic when compiling `Rocket`.

This panic was reported [here](rust-lang#120576 (comment)).

r? ``@oli-obk``
@SergioBenitez
Copy link
Contributor

Sure did! Thank you!

flip1995 pushed a commit to flip1995/rust that referenced this pull request Feb 26, 2024
…ticBuilder, r=davidtwco

Overhaul `Diagnostic` and `DiagnosticBuilder`

Implements the first part of rust-lang/compiler-team#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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic 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. 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.

7 participants