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

ICE: clippy: entered unreachable code: expr must be an array or slice due to ExprKind::Array #121477

Closed
matthiaskrgr opened this issue Feb 22, 2024 · 5 comments
Assignees
Labels
A-clippy Area: Clippy C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

struct Foo(isize, isize, isize, isize);

pub fn main() {
    let Self::anything_here_kills_it(a, b, ..) = Foo(5, 5, 5, 5);
    match [5, 5, 5, 5] {
        [..] => { }
    }
}

Meta

rustc --version --verbose:

clippy 0.1.78 (f62f490 2024-02-22)

rustc 1.78.0-nightly (f62f490fd 2024-02-22)
binary: rustc
commit-hash: f62f490fd410c06031a57915b4e5580ccbd7a30f
commit-date: 2024-02-22
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Error output

warning: fields `0`, `1`, `2`, and `3` are never read
 --> a.rs:2:12
  |
2 | struct Foo(isize, isize, isize, isize);
  |        --- ^^^^^  ^^^^^  ^^^^^  ^^^^^
  |        |
  |        fields in this struct
  |
  = note: `#[warn(dead_code)]` on by default
help: consider changing the fields to be of unit type to suppress this warning while preserving the field numbering, or remove the fields
  |
2 | struct Foo((), (), (), ());
  |            ~~  ~~  ~~  ~~
Backtrace

thread 'rustc' panicked at src/tools/clippy/clippy_lints/src/tuple_array_conversions.rs:68:9:
internal error: entered unreachable code: `expr` must be an array or slice due to `ExprKind::Array`
stack backtrace:
   0:     0x7f3bd538caf6 - std::backtrace_rs::backtrace::libunwind::trace::h4fc804798bc2611b
                               at /rustc/f62f490fd410c06031a57915b4e5580ccbd7a30f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f3bd538caf6 - std::backtrace_rs::backtrace::trace_unsynchronized::hd4bd33e8c8272882
                               at /rustc/f62f490fd410c06031a57915b4e5580ccbd7a30f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f3bd538caf6 - std::sys_common::backtrace::_print_fmt::h545c234117c22fc9
                               at /rustc/f62f490fd410c06031a57915b4e5580ccbd7a30f/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f3bd538caf6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h7a473c1b58fe7e10
                               at /rustc/f62f490fd410c06031a57915b4e5580ccbd7a30f/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f3bd53dda7c - core::fmt::rt::Argument::fmt::h36d6352937d87a88
                               at /rustc/f62f490fd410c06031a57915b4e5580ccbd7a30f/library/core/src/fmt/rt.rs:142:9
   5:     0x7f3bd53dda7c - core::fmt::write::h9c73f4067236af99
                               at /rustc/f62f490fd410c06031a57915b4e5580ccbd7a30f/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f3bd53814bf - std::io::Write::write_fmt::hcc9c8f66fb450b80
                               at /rustc/f62f490fd410c06031a57915b4e5580ccbd7a30f/library/std/src/io/mod.rs:1846:15
   7:     0x7f3bd538c8a4 - std::sys_common::backtrace::_print::h4e88c1e97f0d4518
                               at /rustc/f62f490fd410c06031a57915b4e5580ccbd7a30f/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f3bd538c8a4 - std::sys_common::backtrace::print::h92dce13ce44b3a91
                               at /rustc/f62f490fd410c06031a57915b4e5580ccbd7a30f/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f3bd538f5eb - std::panicking::default_hook::{{closure}}::h2c5fd0429c678c6f
  10:     0x7f3bd538f339 - std::panicking::default_hook::ha5d30dbe4da7a79b
                               at /rustc/f62f490fd410c06031a57915b4e5580ccbd7a30f/library/std/src/panicking.rs:292:9
  11:     0x7f3bd8271c7c - std[821c6b3b8c530c40]::panicking::update_hook::<alloc[8ac6b170fd61b1e2]::boxed::Box<rustc_driver_impl[59d1908ab5d44cab]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f3bd538fd50 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hcaa5eb95c84b3711
                               at /rustc/f62f490fd410c06031a57915b4e5580ccbd7a30f/library/alloc/src/boxed.rs:2030:9
  13:     0x7f3bd538fd50 - std::panicking::rust_panic_with_hook::h0d9771b9524e7484
                               at /rustc/f62f490fd410c06031a57915b4e5580ccbd7a30f/library/std/src/panicking.rs:786:13
  14:     0x7f3bd538fa59 - std::panicking::begin_panic_handler::{{closure}}::hbcb115fc368d9d99
                               at /rustc/f62f490fd410c06031a57915b4e5580ccbd7a30f/library/std/src/panicking.rs:652:13
  15:     0x7f3bd538cfd6 - std::sys_common::backtrace::__rust_end_short_backtrace::h43dd1fced9908690
                               at /rustc/f62f490fd410c06031a57915b4e5580ccbd7a30f/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f3bd538f7c4 - rust_begin_unwind
                               at /rustc/f62f490fd410c06031a57915b4e5580ccbd7a30f/library/std/src/panicking.rs:648:5
  17:     0x7f3bd53d9f95 - core::panicking::panic_fmt::hd4728c4b0ec637f4
                               at /rustc/f62f490fd410c06031a57915b4e5580ccbd7a30f/library/core/src/panicking.rs:72:14
  18:     0x563c0c9cc504 - <clippy_lints[ceaf82ba4fb68b51]::tuple_array_conversions::TupleArrayConversions as rustc_lint[4f8e23604aba8bf8]::passes::LateLintPass>::check_expr
  19:     0x7f3bd85f8fb2 - <rustc_lint[4f8e23604aba8bf8]::late::LateContextAndPass<rustc_lint[4f8e23604aba8bf8]::late::RuntimeCombinedLateLintPass> as rustc_hir[d91d3a3bd337c424]::intravisit::Visitor>::visit_expr::{closure#0}
  20:     0x7f3bd85f8e48 - <rustc_lint[4f8e23604aba8bf8]::late::LateContextAndPass<rustc_lint[4f8e23604aba8bf8]::late::RuntimeCombinedLateLintPass> as rustc_hir[d91d3a3bd337c424]::intravisit::Visitor>::visit_expr
  21:     0x7f3bd85f91f2 - <rustc_lint[4f8e23604aba8bf8]::late::LateContextAndPass<rustc_lint[4f8e23604aba8bf8]::late::RuntimeCombinedLateLintPass> as rustc_hir[d91d3a3bd337c424]::intravisit::Visitor>::visit_expr::{closure#0}
  22:     0x7f3bd85f8e48 - <rustc_lint[4f8e23604aba8bf8]::late::LateContextAndPass<rustc_lint[4f8e23604aba8bf8]::late::RuntimeCombinedLateLintPass> as rustc_hir[d91d3a3bd337c424]::intravisit::Visitor>::visit_expr
  23:     0x7f3bd85f9ebf - <rustc_lint[4f8e23604aba8bf8]::late::LateContextAndPass<rustc_lint[4f8e23604aba8bf8]::late::RuntimeCombinedLateLintPass> as rustc_hir[d91d3a3bd337c424]::intravisit::Visitor>::visit_block
  24:     0x7f3bd85f9454 - <rustc_lint[4f8e23604aba8bf8]::late::LateContextAndPass<rustc_lint[4f8e23604aba8bf8]::late::RuntimeCombinedLateLintPass> as rustc_hir[d91d3a3bd337c424]::intravisit::Visitor>::visit_expr::{closure#0}
  25:     0x7f3bd85f8e48 - <rustc_lint[4f8e23604aba8bf8]::late::LateContextAndPass<rustc_lint[4f8e23604aba8bf8]::late::RuntimeCombinedLateLintPass> as rustc_hir[d91d3a3bd337c424]::intravisit::Visitor>::visit_expr
  26:     0x7f3bd85f8d48 - <rustc_lint[4f8e23604aba8bf8]::late::LateContextAndPass<rustc_lint[4f8e23604aba8bf8]::late::RuntimeCombinedLateLintPass> as rustc_hir[d91d3a3bd337c424]::intravisit::Visitor>::visit_nested_body
  27:     0x7f3bd85f9a04 - <rustc_lint[4f8e23604aba8bf8]::late::LateContextAndPass<rustc_lint[4f8e23604aba8bf8]::late::RuntimeCombinedLateLintPass> as rustc_hir[d91d3a3bd337c424]::intravisit::Visitor>::visit_fn
  28:     0x7f3bd85e8e04 - <rustc_lint[4f8e23604aba8bf8]::late::LateContextAndPass<rustc_lint[4f8e23604aba8bf8]::late::RuntimeCombinedLateLintPass> as rustc_hir[d91d3a3bd337c424]::intravisit::Visitor>::visit_nested_item
  29:     0x7f3bda1a1e7d - rustc_lint[4f8e23604aba8bf8]::late::check_crate::{closure#0}
  30:     0x7f3bda1a20d1 - rustc_lint[4f8e23604aba8bf8]::late::check_crate
  31:     0x7f3bda19bfe5 - rustc_interface[8734248df239def8]::passes::analysis
  32:     0x7f3bda19acd9 - rustc_query_impl[ecde01aee8afea7b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ecde01aee8afea7b]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2eacc124c30f1755]::query::erase::Erased<[u8; 1usize]>>
  33:     0x7f3bda336f65 - rustc_query_system[e0ca4a2ac3d1a2c5]::query::plumbing::try_execute_query::<rustc_query_impl[ecde01aee8afea7b]::DynamicConfig<rustc_query_system[e0ca4a2ac3d1a2c5]::query::caches::SingleCache<rustc_middle[2eacc124c30f1755]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[ecde01aee8afea7b]::plumbing::QueryCtxt, false>
  34:     0x7f3bda336cc9 - rustc_query_impl[ecde01aee8afea7b]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7f3bda346196 - rustc_interface[8734248df239def8]::interface::run_compiler::<core[256ba93ffbc6f60f]::result::Result<(), rustc_span[503fa18317341f7e]::ErrorGuaranteed>, rustc_driver_impl[59d1908ab5d44cab]::run_compiler::{closure#0}>::{closure#0}
  36:     0x7f3bda5c2dcd - std[821c6b3b8c530c40]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[8734248df239def8]::util::run_in_thread_with_globals<rustc_interface[8734248df239def8]::util::run_in_thread_pool_with_globals<rustc_interface[8734248df239def8]::interface::run_compiler<core[256ba93ffbc6f60f]::result::Result<(), rustc_span[503fa18317341f7e]::ErrorGuaranteed>, rustc_driver_impl[59d1908ab5d44cab]::run_compiler::{closure#0}>::{closure#0}, core[256ba93ffbc6f60f]::result::Result<(), rustc_span[503fa18317341f7e]::ErrorGuaranteed>>::{closure#0}, core[256ba93ffbc6f60f]::result::Result<(), rustc_span[503fa18317341f7e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[256ba93ffbc6f60f]::result::Result<(), rustc_span[503fa18317341f7e]::ErrorGuaranteed>>
  37:     0x7f3bda5c2bfa - <<std[821c6b3b8c530c40]::thread::Builder>::spawn_unchecked_<rustc_interface[8734248df239def8]::util::run_in_thread_with_globals<rustc_interface[8734248df239def8]::util::run_in_thread_pool_with_globals<rustc_interface[8734248df239def8]::interface::run_compiler<core[256ba93ffbc6f60f]::result::Result<(), rustc_span[503fa18317341f7e]::ErrorGuaranteed>, rustc_driver_impl[59d1908ab5d44cab]::run_compiler::{closure#0}>::{closure#0}, core[256ba93ffbc6f60f]::result::Result<(), rustc_span[503fa18317341f7e]::ErrorGuaranteed>>::{closure#0}, core[256ba93ffbc6f60f]::result::Result<(), rustc_span[503fa18317341f7e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[256ba93ffbc6f60f]::result::Result<(), rustc_span[503fa18317341f7e]::ErrorGuaranteed>>::{closure#1} as core[256ba93ffbc6f60f]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7f3bd5399725 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h707c303233e58066
                               at /rustc/f62f490fd410c06031a57915b4e5580ccbd7a30f/library/alloc/src/boxed.rs:2016:9
  39:     0x7f3bd5399725 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3bccdf5582e5652c
                               at /rustc/f62f490fd410c06031a57915b4e5580ccbd7a30f/library/alloc/src/boxed.rs:2016:9
  40:     0x7f3bd5399725 - std::sys::pal::unix::thread::Thread::new::thread_start::h279bb1ec141bc5eb
                               at /rustc/f62f490fd410c06031a57915b4e5580ccbd7a30f/library/std/src/sys/pal/unix/thread.rs:108:17
  41:     0x7f3bd50949eb - <unknown>
  42:     0x7f3bd51187cc - <unknown>
  43:                0x0 - <unknown>

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new?template=ice.yml

note: please attach the file at `/tmp/im/rustc-ice-2024-02-22T19_49_41-1815680.txt` to your bug report

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
note: Clippy version: clippy 0.1.78 (f62f490 2024-02-22)

error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions
 --> a.rs:5:9
  |
5 |     let Self::anything_here_kills_it(a, b, ..) = Foo(5, 5, 5, 5);
  |         ^^^^ `Self` is only available in impls, traits, and type definitions

error: aborting due to 1 previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0433`.

@matthiaskrgr matthiaskrgr added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Feb 22, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 22, 2024
@matthiaskrgr
Copy link
Member Author

This bisects to #118634 hmm
cc @Jules-Bertholet

@jieyouxu jieyouxu added A-clippy Area: Clippy S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 22, 2024
@Jules-Bertholet
Copy link
Contributor

Jules-Bertholet commented Feb 22, 2024

#118634 just removes a few where clauses in the stdlib, it doesn't even touch the compiler or Clippy

@matthiaskrgr
Copy link
Member Author

Hm I don't understand why cargo-bisect-rustc always concludes 118642.
When I try manually it seems to be #121415 , so I suspect its related to #121206

@Jules-Bertholet
Copy link
Contributor

Jules-Bertholet commented Feb 22, 2024

This bisects to #118634

Hm I don't understand why cargo-bisect-rustc always concludes 118642.

#118634 and #118642 are not the same PR

@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented Feb 22, 2024

ops I meant the #118634 there 😅

@fmease fmease changed the title ICE: clippy: entered unreachable code: expr must be an array or slice due to ExprKind::Array` ICE: clippy: ` entered unreachable code: expr must be an array or slice due to ExprKind::Array ` Feb 23, 2024
@fmease fmease changed the title ICE: clippy: ` entered unreachable code: expr must be an array or slice due to ExprKind::Array ` ICE: clippy: entered unreachable code: expr must be an array or slice due to ExprKind::Array Feb 23, 2024
@nnethercote nnethercote self-assigned this Feb 27, 2024
nnethercote added a commit to nnethercote/rust that referenced this issue Feb 27, 2024
Stashed errors used to be counted as errors, but could then be
cancelled, leading to `ErrorGuaranteed` soundness holes. rust-lang#120828 changed
that, closing the soundness hole. But it introduced other difficulties
because you sometimes have to account for pending stashed errors when
making decisions about whether errors have occured/will occur and it's
easy to overlook these.

This commit aims for a middle ground.
- Stashed errors (not warnings) are counted immediately as emitted
  errors, avoiding the possibility of forgetting to consider them.
- The ability to cancel (or downgrade) stashed errors is eliminated, by
  disallowing the use of `steal_diagnostic` with errors, and introducing
  the more restrictive methods `try_steal_{modify,replace}_and_emit_err`
  that can be used instead.

Other things:
- `DiagnosticBuilder::stash` and `DiagCtxt::stash_diagnostic` now both
  return `Option<ErrorGuaranteed>`, which enables the removal of two
  `delayed_bug` calls and one `Ty::new_error_with_message` call. This is
  possible because we store error guarantees in
  `DiagCtxt::stashed_diagnostics`.
- Storing the guarantees also saves us having to maintain a counter.
- Calls to the `stashed_err_count` method are no longer necessary
  alongside calls to `has_errors`, which is a nice simplification, and
  eliminates two more `span_delayed_bug` calls and one FIXME comment.
- Tests are added for three of the four fixed PRs mentioned below.
- `issue-121108.rs`'s output improved slightly, omitting a non-useful
  error message.

Fixes rust-lang#121451.
Fixes rust-lang#121477.
Fixes rust-lang#121504.
Fixes rust-lang#121508.
nnethercote added a commit to nnethercote/rust that referenced this issue Feb 27, 2024
Stashed errors used to be counted as errors, but could then be
cancelled, leading to `ErrorGuaranteed` soundness holes. rust-lang#120828 changed
that, closing the soundness hole. But it introduced other difficulties
because you sometimes have to account for pending stashed errors when
making decisions about whether errors have occured/will occur and it's
easy to overlook these.

This commit aims for a middle ground.
- Stashed errors (not warnings) are counted immediately as emitted
  errors, avoiding the possibility of forgetting to consider them.
- The ability to cancel (or downgrade) stashed errors is eliminated, by
  disallowing the use of `steal_diagnostic` with errors, and introducing
  the more restrictive methods `try_steal_{modify,replace}_and_emit_err`
  that can be used instead.

Other things:
- `DiagnosticBuilder::stash` and `DiagCtxt::stash_diagnostic` now both
  return `Option<ErrorGuaranteed>`, which enables the removal of two
  `delayed_bug` calls and one `Ty::new_error_with_message` call. This is
  possible because we store error guarantees in
  `DiagCtxt::stashed_diagnostics`.
- Storing the guarantees also saves us having to maintain a counter.
- Calls to the `stashed_err_count` method are no longer necessary
  alongside calls to `has_errors`, which is a nice simplification, and
  eliminates two more `span_delayed_bug` calls and one FIXME comment.
- Tests are added for three of the four fixed PRs mentioned below.
- `issue-121108.rs`'s output improved slightly, omitting a non-useful
  error message.

Fixes rust-lang#121451.
Fixes rust-lang#121477.
Fixes rust-lang#121504.
Fixes rust-lang#121508.
nnethercote added a commit to nnethercote/rust that referenced this issue Feb 27, 2024
Stashed errors used to be counted as errors, but could then be
cancelled, leading to `ErrorGuaranteed` soundness holes. rust-lang#120828 changed
that, closing the soundness hole. But it introduced other difficulties
because you sometimes have to account for pending stashed errors when
making decisions about whether errors have occured/will occur and it's
easy to overlook these.

This commit aims for a middle ground.
- Stashed errors (not warnings) are counted immediately as emitted
  errors, avoiding the possibility of forgetting to consider them.
- The ability to cancel (or downgrade) stashed errors is eliminated, by
  disallowing the use of `steal_diagnostic` with errors, and introducing
  the more restrictive methods `try_steal_{modify,replace}_and_emit_err`
  that can be used instead.

Other things:
- `DiagnosticBuilder::stash` and `DiagCtxt::stash_diagnostic` now both
  return `Option<ErrorGuaranteed>`, which enables the removal of two
  `delayed_bug` calls and one `Ty::new_error_with_message` call. This is
  possible because we store error guarantees in
  `DiagCtxt::stashed_diagnostics`.
- Storing the guarantees also saves us having to maintain a counter.
- Calls to the `stashed_err_count` method are no longer necessary
  alongside calls to `has_errors`, which is a nice simplification, and
  eliminates two more `span_delayed_bug` calls and one FIXME comment.
- Tests are added for three of the four fixed PRs mentioned below.
- `issue-121108.rs`'s output improved slightly, omitting a non-useful
  error message.

Fixes rust-lang#121451.
Fixes rust-lang#121477.
Fixes rust-lang#121504.
Fixes rust-lang#121508.
@bors bors closed this as completed in 260ae70 Feb 29, 2024
nnethercote added a commit to nnethercote/rust that referenced this issue Mar 1, 2024
Stashed errors used to be counted as errors, but could then be
cancelled, leading to `ErrorGuaranteed` soundness holes. rust-lang#120828 changed
that, closing the soundness hole. But it introduced other difficulties
because you sometimes have to account for pending stashed errors when
making decisions about whether errors have occured/will occur and it's
easy to overlook these.

This commit aims for a middle ground.
- Stashed errors (not warnings) are counted immediately as emitted
  errors, avoiding the possibility of forgetting to consider them.
- The ability to cancel (or downgrade) stashed errors is eliminated, by
  disallowing the use of `steal_diagnostic` with errors, and introducing
  the more restrictive methods `try_steal_{modify,replace}_and_emit_err`
  that can be used instead.

Other things:
- `DiagnosticBuilder::stash` and `DiagCtxt::stash_diagnostic` now both
  return `Option<ErrorGuaranteed>`, which enables the removal of two
  `delayed_bug` calls and one `Ty::new_error_with_message` call. This is
  possible because we store error guarantees in
  `DiagCtxt::stashed_diagnostics`.
- Storing the guarantees also saves us having to maintain a counter.
- Calls to the `stashed_err_count` method are no longer necessary
  alongside calls to `has_errors`, which is a nice simplification, and
  eliminates two more `span_delayed_bug` calls and one FIXME comment.
- Tests are added for three of the four fixed PRs mentioned below.
- `issue-121108.rs`'s output improved slightly, omitting a non-useful
  error message.

Fixes rust-lang#121451.
Fixes rust-lang#121477.
Fixes rust-lang#121504.
Fixes rust-lang#121508.
flip1995 pushed a commit to flip1995/rust that referenced this issue Mar 7, 2024
Stashed errors used to be counted as errors, but could then be
cancelled, leading to `ErrorGuaranteed` soundness holes. rust-lang#120828 changed
that, closing the soundness hole. But it introduced other difficulties
because you sometimes have to account for pending stashed errors when
making decisions about whether errors have occured/will occur and it's
easy to overlook these.

This commit aims for a middle ground.
- Stashed errors (not warnings) are counted immediately as emitted
  errors, avoiding the possibility of forgetting to consider them.
- The ability to cancel (or downgrade) stashed errors is eliminated, by
  disallowing the use of `steal_diagnostic` with errors, and introducing
  the more restrictive methods `try_steal_{modify,replace}_and_emit_err`
  that can be used instead.

Other things:
- `DiagnosticBuilder::stash` and `DiagCtxt::stash_diagnostic` now both
  return `Option<ErrorGuaranteed>`, which enables the removal of two
  `delayed_bug` calls and one `Ty::new_error_with_message` call. This is
  possible because we store error guarantees in
  `DiagCtxt::stashed_diagnostics`.
- Storing the guarantees also saves us having to maintain a counter.
- Calls to the `stashed_err_count` method are no longer necessary
  alongside calls to `has_errors`, which is a nice simplification, and
  eliminates two more `span_delayed_bug` calls and one FIXME comment.
- Tests are added for three of the four fixed PRs mentioned below.
- `issue-121108.rs`'s output improved slightly, omitting a non-useful
  error message.

Fixes rust-lang#121451.
Fixes rust-lang#121477.
Fixes rust-lang#121504.
Fixes rust-lang#121508.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-clippy Area: Clippy C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants