diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2025-03-30 17:59:28 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-30 17:59:28 -0400 |
| commit | eb424222582784ddf5d5aceb408980d4d3401e4d (patch) | |
| tree | ab55a4606d960189d0005c57a0db79bef0ff0857 /compiler/rustc_interface/src | |
| parent | 1296a23bb4eeba423254d4c9f3f99f948616a11d (diff) | |
| parent | 2dfd2a2a242e920b7378328b87f901652d9d81be (diff) | |
| download | rust-eb424222582784ddf5d5aceb408980d4d3401e4d.tar.gz rust-eb424222582784ddf5d5aceb408980d4d3401e4d.zip | |
Rollup merge of #139122 - petrochenkov:norerr, r=compiler-errors
Remove attribute `#[rustc_error]` It was an ancient way to write `check-pass` tests, but now it's no longer necessary (except for the `delayed_bug_from_inside_query` flavor, which is retained).
Diffstat (limited to 'compiler/rustc_interface/src')
| -rw-r--r-- | compiler/rustc_interface/src/errors.rs | 14 | ||||
| -rw-r--r-- | compiler/rustc_interface/src/passes.rs | 42 |
2 files changed, 6 insertions, 50 deletions
diff --git a/compiler/rustc_interface/src/errors.rs b/compiler/rustc_interface/src/errors.rs index ef0235b5577..6b39b4f1891 100644 --- a/compiler/rustc_interface/src/errors.rs +++ b/compiler/rustc_interface/src/errors.rs @@ -74,20 +74,6 @@ pub struct TempsDirError; pub struct OutDirError; #[derive(Diagnostic)] -#[diag(interface_rustc_error_fatal)] -pub struct RustcErrorFatal { - #[primary_span] - pub span: Span, -} - -#[derive(Diagnostic)] -#[diag(interface_rustc_error_unexpected_annotation)] -pub struct RustcErrorUnexpectedAnnotation { - #[primary_span] - pub span: Span, -} - -#[derive(Diagnostic)] #[diag(interface_failed_writing_file)] pub struct FailedWritingFile<'a> { pub path: &'a Path, diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 2440f0639c8..93013c8b3f6 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -1067,48 +1067,18 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) { }); } -/// Check for the `#[rustc_error]` annotation, which forces an error in codegen. This is used -/// to write UI tests that actually test that compilation succeeds without reporting -/// an error. -fn check_for_rustc_errors_attr(tcx: TyCtxt<'_>) { - let Some((def_id, _)) = tcx.entry_fn(()) else { return }; - for attr in tcx.get_attrs(def_id, sym::rustc_error) { - match attr.meta_item_list() { - // Check if there is a `#[rustc_error(delayed_bug_from_inside_query)]`. - Some(list) - if list.iter().any(|list_item| { - matches!( - list_item.ident().map(|i| i.name), - Some(sym::delayed_bug_from_inside_query) - ) - }) => - { - tcx.ensure_ok().trigger_delayed_bug(def_id); - } - - // Bare `#[rustc_error]`. - None => { - tcx.dcx().emit_fatal(errors::RustcErrorFatal { span: tcx.def_span(def_id) }); - } - - // Some other attribute. - Some(_) => { - tcx.dcx().emit_warn(errors::RustcErrorUnexpectedAnnotation { - span: tcx.def_span(def_id), - }); - } - } - } -} - /// Runs the codegen backend, after which the AST and analysis can /// be discarded. pub(crate) fn start_codegen<'tcx>( codegen_backend: &dyn CodegenBackend, tcx: TyCtxt<'tcx>, ) -> Box<dyn Any> { - // Hook for UI tests. - check_for_rustc_errors_attr(tcx); + // Hook for tests. + if let Some((def_id, _)) = tcx.entry_fn(()) + && tcx.has_attr(def_id, sym::rustc_delayed_bug_from_inside_query) + { + tcx.ensure_ok().trigger_delayed_bug(def_id); + } // Don't run this test assertions when not doing codegen. Compiletest tries to build // build-fail tests in check mode first and expects it to not give an error in that case. |
