1
Fork 0
rust/compiler
Nicholas Nethercote 72b172bdf6 Overhaul the handling of errors at the top-level.
Currently `emit_stashed_diagnostic` is called from four(!) different
places: `print_error_count`, `DiagCtxtInner::drop`, `abort_if_errors`,
and `compile_status`.

And `flush_delayed` is called from two different places:
`DiagCtxtInner::drop` and `Queries`.

This is pretty gross! Each one should really be called from a single
place, but there's a bunch of entanglements. This commit cleans up this
mess.

Specifically, it:
- Removes all the existing calls to `emit_stashed_diagnostic`, and adds
  a single new call in `finish_diagnostics`.
- Removes the early `flush_delayed` call in `codegen_and_build_linker`,
  replacing it with a simple early return if delayed bugs are present.
- Changes `DiagCtxtInner::drop` and `DiagCtxtInner::flush_delayed` so
  they both assert that the stashed diagnostics are empty (i.e.
  processed beforehand).
- Changes `interface::run_compiler` so that any errors emitted during
  `finish_diagnostics` (i.e. late-emitted stashed diagnostics) are
  counted and cannot be overlooked. This requires adding
  `ErrorGuaranteed` return values to several functions.
- Removes the `stashed_err_count` call in `analysis`. This is possible
  now that we don't have to worry about calling `flush_delayed` early
  from `codegen_and_build_linker` when stashed diagnostics are pending.
- Changes the `span_bug` case in `handle_tuple_field_pattern_match` to a
  `delayed_span_bug`, because it now can be reached due to the removal
  of the `stashed_err_count` call in `analysis`.
- Slightly changes the expected output of three tests. If no errors are
  emitted but there are delayed bugs, the error count is no longer
  printed. This is because delayed bugs are now always printed after the
  error count is printed (or not printed, if the error count is zero).

There is a lot going on in this commit. It's hard to break into smaller
pieces because the existing code is very tangled. It took me a long time
and a lot of effort to understand how the different pieces interact, and
I think the new code is a lot simpler and easier to understand.
2024-02-22 08:03:47 +11:00
..
rustc
rustc_abi Fix rustc_abi build on stable 2024-01-16 21:15:31 +01:00
rustc_arena Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
rustc_ast Allow AST and HIR visitors to return ControlFlow 2024-02-18 03:49:28 -05:00
rustc_ast_lowering Convert delayed_bugs to bugs. 2024-02-21 10:20:05 +11:00
rustc_ast_passes Remove an unchecked_error_guaranteed call. 2024-02-21 17:02:30 +11:00
rustc_ast_pretty Rollup merge of #121109 - nnethercote:TyKind-Err-guar-2, r=oli-obk 2024-02-16 00:27:32 +01:00
rustc_attr Use generic NonZero internally. 2024-02-15 08:09:42 +01:00
rustc_baked_icu_data
rustc_borrowck Convert bugs back to delayed_bugs. 2024-02-21 10:35:54 +11:00
rustc_builtin_macros Rollup merge of #121318 - kadiwa4:no_assembly_in_supposedly_safe_code, r=Nilstrieb 2024-02-20 15:13:55 +01:00
rustc_codegen_cranelift Auto merge of #120718 - saethlin:reasonable-fast-math, r=nnethercote 2024-02-21 09:43:33 +00:00
rustc_codegen_gcc Auto merge of #120718 - saethlin:reasonable-fast-math, r=nnethercote 2024-02-21 09:43:33 +00:00
rustc_codegen_llvm Auto merge of #120718 - saethlin:reasonable-fast-math, r=nnethercote 2024-02-21 09:43:33 +00:00
rustc_codegen_ssa Auto merge of #120718 - saethlin:reasonable-fast-math, r=nnethercote 2024-02-21 09:43:33 +00:00
rustc_const_eval Rollup merge of #121396 - RalfJung:mir-const-value-inspect, r=oli-obk 2024-02-21 16:33:00 +01:00
rustc_data_structures Auto merge of #121265 - klensy:bump-18-02-24, r=Mark-Simulacrum 2024-02-18 16:54:15 +00:00
rustc_driver
rustc_driver_impl Remove EarlyDiagCtxt::abort_if_errors. 2024-02-22 08:03:47 +11:00
rustc_error_codes Improve wording of static_mut_ref 2024-02-18 06:01:40 +03:00
rustc_error_messages errors: only eagerly translate subdiagnostics 2024-02-15 10:34:41 +00:00
rustc_errors Overhaul the handling of errors at the top-level. 2024-02-22 08:03:47 +11:00
rustc_expand Rollup merge of #121288 - tshepang:make-expand-translatable, r=michaelwoerister 2024-02-21 08:55:56 +00:00
rustc_feature Auto merge of #120500 - oli-obk:intrinsics2.0, r=WaffleLapkin 2024-02-16 09:53:01 +00:00
rustc_fluent_macro Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
rustc_fs_util Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
rustc_graphviz Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
rustc_hir Rollup merge of #121256 - Jarcho:visitor2, r=oli-obk 2024-02-20 07:35:47 +01:00
rustc_hir_analysis Auto merge of #121383 - Dylan-DPC:rollup-735p4u4, r=Dylan-DPC 2024-02-21 12:09:22 +00:00
rustc_hir_pretty Lower anonymous structs or unions to HIR 2024-02-12 12:47:23 +08:00
rustc_hir_typeck Rollup merge of #121328 - ffmancera:ff/verbose_long_type, r=compiler-errors 2024-02-21 08:55:57 +00:00
rustc_incremental Adjust the has_errors* methods. 2024-02-22 08:03:47 +11:00
rustc_index Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
rustc_index_macros Step all bootstrap cfgs forward 2024-02-08 07:44:34 -05:00
rustc_infer Adjust the has_errors* methods. 2024-02-22 08:03:47 +11:00
rustc_interface Overhaul the handling of errors at the top-level. 2024-02-22 08:03:47 +11:00
rustc_lexer Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
rustc_lint Rollup merge of #121338 - jieyouxu:ambiguous_wide_pointer_comparisons_suggestion, r=Nadrieril 2024-02-21 08:55:58 +00:00
rustc_lint_defs Rollup merge of #120716 - spastorino:change-some-lint-msgs, r=lcnr 2024-02-20 07:35:45 +01:00
rustc_llvm Add "algebraic" versions of the fast-math intrinsics 2024-02-20 12:39:03 -05:00
rustc_log Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
rustc_macros Docs for extension proc-macro 2024-02-21 05:32:08 +00:00
rustc_metadata Adjust the has_errors* methods. 2024-02-22 08:03:47 +11:00
rustc_middle Remove dead expect_error_or_delayed_bug method. 2024-02-22 08:03:47 +11:00
rustc_mir_build Rollup merge of #121175 - Nadrieril:simplify-or-selection, r=matthewjasper 2024-02-21 16:32:57 +01:00
rustc_mir_dataflow Auto merge of #120500 - oli-obk:intrinsics2.0, r=WaffleLapkin 2024-02-16 09:53:01 +00:00
rustc_mir_transform Convert delayed_bugs to bugs. 2024-02-21 10:20:05 +11:00
rustc_monomorphize Reduce capabilities of Diagnostic. 2024-02-20 13:22:17 +11:00
rustc_next_trait_solver Move visitable bounds up into interner 2024-02-13 15:53:15 +00:00
rustc_parse Rollup merge of #121379 - nnethercote:rm-unchecked_error_guaranteed, r=oli-obk 2024-02-21 16:32:59 +01:00
rustc_parse_format remove a couple of redundant clones 2024-02-17 12:46:18 +01:00
rustc_passes Overhaul the handling of errors at the top-level. 2024-02-22 08:03:47 +11:00
rustc_pattern_analysis Auto merge of #120576 - nnethercote:merge-Diagnostic-DiagnosticBuilder, r=davidtwco 2024-02-20 12:05:09 +00:00
rustc_privacy Dejargnonize subst 2024-02-12 15:46:35 +09:00
rustc_query_impl Replace NonZero::<_>::new with NonZero::new. 2024-02-15 08:09:42 +01:00
rustc_query_system Adjust the has_errors* methods. 2024-02-22 08:03:47 +11:00
rustc_resolve Convert bugs back to delayed_bugs. 2024-02-21 10:35:54 +11:00
rustc_serialize Replace NonZero::<_>::new with NonZero::new. 2024-02-15 08:09:42 +01:00
rustc_session Overhaul the handling of errors at the top-level. 2024-02-22 08:03:47 +11:00
rustc_smir Merge CompilerError::CompilationFailed and CompilerError::ICE. 2024-02-17 09:40:44 +11:00
rustc_span Auto merge of #120718 - saethlin:reasonable-fast-math, r=nnethercote 2024-02-21 09:43:33 +00:00
rustc_symbol_mangling Rollup merge of #120958 - ShoyuVanilla:remove-subst, r=oli-obk 2024-02-12 23:18:54 +01:00
rustc_target Rollup merge of #121291 - heiher:revert-medium-cmodel, r=Nilstrieb 2024-02-20 15:13:54 +01:00
rustc_trait_selection Rollup merge of #121359 - lcnr:typesystem-cleanup, r=compiler-errors 2024-02-21 16:32:58 +01:00
rustc_traits Rename some normalization-related items 2024-02-20 17:30:49 +01:00
rustc_transmute Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
rustc_ty_utils Rollup merge of #121208 - nnethercote:delayed_bug-to-bug, r=lcnr 2024-02-21 08:55:56 +00:00
rustc_type_ir Remove dead expect_error_or_delayed_bug method. 2024-02-22 08:03:47 +11:00
stable_mir Merge CompilerError::CompilationFailed and CompilerError::ICE. 2024-02-17 09:40:44 +11:00