@@ -1067,48 +1067,18 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) {
10671067 } ) ;
10681068}
10691069
1070- /// Check for the `#[rustc_error]` annotation, which forces an error in codegen. This is used
1071- /// to write UI tests that actually test that compilation succeeds without reporting
1072- /// an error.
1073- fn check_for_rustc_errors_attr ( tcx : TyCtxt < ' _ > ) {
1074- let Some ( ( def_id, _) ) = tcx. entry_fn ( ( ) ) else { return } ;
1075- for attr in tcx. get_attrs ( def_id, sym:: rustc_error) {
1076- match attr. meta_item_list ( ) {
1077- // Check if there is a `#[rustc_error(delayed_bug_from_inside_query)]`.
1078- Some ( list)
1079- if list. iter ( ) . any ( |list_item| {
1080- matches ! (
1081- list_item. ident( ) . map( |i| i. name) ,
1082- Some ( sym:: delayed_bug_from_inside_query)
1083- )
1084- } ) =>
1085- {
1086- tcx. ensure_ok ( ) . trigger_delayed_bug ( def_id) ;
1087- }
1088-
1089- // Bare `#[rustc_error]`.
1090- None => {
1091- tcx. dcx ( ) . emit_fatal ( errors:: RustcErrorFatal { span : tcx. def_span ( def_id) } ) ;
1092- }
1093-
1094- // Some other attribute.
1095- Some ( _) => {
1096- tcx. dcx ( ) . emit_warn ( errors:: RustcErrorUnexpectedAnnotation {
1097- span : tcx. def_span ( def_id) ,
1098- } ) ;
1099- }
1100- }
1101- }
1102- }
1103-
11041070/// Runs the codegen backend, after which the AST and analysis can
11051071/// be discarded.
11061072pub ( crate ) fn start_codegen < ' tcx > (
11071073 codegen_backend : & dyn CodegenBackend ,
11081074 tcx : TyCtxt < ' tcx > ,
11091075) -> Box < dyn Any > {
1110- // Hook for UI tests.
1111- check_for_rustc_errors_attr ( tcx) ;
1076+ // Hook for tests.
1077+ if let Some ( ( def_id, _) ) = tcx. entry_fn ( ( ) )
1078+ && tcx. has_attr ( def_id, sym:: rustc_delayed_bug_from_inside_query)
1079+ {
1080+ tcx. ensure_ok ( ) . trigger_delayed_bug ( def_id) ;
1081+ }
11121082
11131083 // Don't run this test assertions when not doing codegen. Compiletest tries to build
11141084 // build-fail tests in check mode first and expects it to not give an error in that case.
0 commit comments