-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Overhaul Diagnostic
and DiagnosticBuilder
#120576
Conversation
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 |
Diagnostic
and DiagnosticBuilder
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
a9e8c80
to
76be22d
Compare
This comment has been minimized.
This comment has been minimized.
76be22d
to
008e4b8
Compare
This comment has been minimized.
This comment has been minimized.
008e4b8
to
bbdf6fd
Compare
This comment has been minimized.
This comment has been minimized.
1cc4994
to
90f2b64
Compare
This comment has been minimized.
This comment has been minimized.
d4ae95d
to
18e2e92
Compare
This comment was marked as resolved.
This comment was marked as resolved.
18e2e92
to
40fb7d5
Compare
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
@bors try |
…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`
☀️ Try build successful - checks-actions |
40fb7d5
to
670cb07
Compare
☀️ Test successful - checks-actions |
Finished benchmarking commit (29f87ad): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis 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.
CyclesResultsThis 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.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 639.567s -> 640.822s (0.20%) |
…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`
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 - |
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`
`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.
Thanks for the report, #121427 should fix it. |
Fix panic when compiling `Rocket`. This panic was reported [here](rust-lang#120576 (comment)). r? `@oli-obk`
Fix panic when compiling `Rocket`. This panic was reported [here](rust-lang#120576 (comment)). r? ``@oli-obk``
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``
Sure did! Thank you! |
…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`
Implements the first part of rust-lang/compiler-team#722, which moves functionality and use away from
Diagnostic
, ontoDiagnosticBuilder
.Likely follow-ups:
DiagnosticBuilder
has impls in bothdiagnostic.rs
anddiagnostic_builder.rs
.Diagnostic
asDiagInner
andDiagnosticBuilder
asDiag
.r? @davidtwco