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

Count stashed errors again #121669

Merged
merged 6 commits into from
Feb 29, 2024
Merged

Commits on Feb 29, 2024

  1. Don't cancel stashed OpaqueHiddenTypeMismatch errors.

    This gives one extra error message on one test, but is necessary to fix
    bigger problems caused by the cancellation of stashed errors.
    
    (Note: why not just avoid stashing altogether? Because that resulted in
    additional output changes.)
    nnethercote committed Feb 29, 2024
    Configuration menu
    Copy the full SHA
    c4ec196 View commit details
    Browse the repository at this point in the history
  2. Don't cancel stashed TraitMissingMethod errors.

    This gives one extra error message on two tests, but is necessary to fix
    bigger problems caused by the cancellation of stashed errors.
    
    (Note: why not just avoid stashing altogether? Because that resulted in
    additional output changes.)
    nnethercote committed Feb 29, 2024
    Configuration menu
    Copy the full SHA
    ec25d6d View commit details
    Browse the repository at this point in the history
  3. Overhaul how stashed diagnostics work, again.

    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 committed Feb 29, 2024
    Configuration menu
    Copy the full SHA
    260ae70 View commit details
    Browse the repository at this point in the history
  4. Mark some once-again-unreachable paths as unreachable.

    This undoes the changes from rust-lang#121482 and rust-lang#121586, now that stashed errors
    will trigger more early aborts.
    nnethercote committed Feb 29, 2024
    Configuration menu
    Copy the full SHA
    b4e9f93 View commit details
    Browse the repository at this point in the history
  5. Stop miri if delayed bugs are present.

    Seems wise, since it shouldn't proceed in that case.
    nnethercote committed Feb 29, 2024
    Configuration menu
    Copy the full SHA
    9aff357 View commit details
    Browse the repository at this point in the history
  6. Reinstate emit_stashed_diagnostics in DiagCtxtInner::drop.

    I removed it in rust-lang#121206 because I thought thought it wasn't necessary.
    But then I had to add an `emit_stashed_diagnostics` call elsewhere in
    rustfmt to avoid the assertion failure (which took two attempts to get
    right, rust-lang#121487 and rust-lang#121615), and now there's an assertion failure in
    clippy as well (rust-lang/rust-clippy#12364).
    
    So this commit just reinstates the call in `DiagCtxtInner::drop`. It
    also reverts the rustfmt changes from rust-lang#121487 and rust-lang#121615, though it
    keeps the tests added for those PRs.
    nnethercote committed Feb 29, 2024
    Configuration menu
    Copy the full SHA
    82961c0 View commit details
    Browse the repository at this point in the history