Remove attribute #[rustc_error]
This commit is contained in:
parent
d4812c8638
commit
2dfd2a2a24
47 changed files with 72 additions and 236 deletions
|
|
@ -1087,9 +1087,9 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
WarnFollowing, EncodeCrossCrate::No
|
||||
),
|
||||
rustc_attr!(
|
||||
TEST, rustc_error, Normal,
|
||||
template!(Word, List: "delayed_bug_from_inside_query"),
|
||||
WarnFollowingWordOnly, EncodeCrossCrate::Yes
|
||||
TEST, rustc_delayed_bug_from_inside_query, Normal,
|
||||
template!(Word),
|
||||
WarnFollowing, EncodeCrossCrate::No
|
||||
),
|
||||
rustc_attr!(
|
||||
TEST, rustc_dump_user_args, Normal, template!(Word),
|
||||
|
|
|
|||
|
|
@ -50,11 +50,5 @@ interface_out_dir_error =
|
|||
interface_proc_macro_crate_panic_abort =
|
||||
building proc macro crate with `panic=abort` may crash the compiler should the proc-macro panic
|
||||
|
||||
interface_rustc_error_fatal =
|
||||
fatal error triggered by #[rustc_error]
|
||||
|
||||
interface_rustc_error_unexpected_annotation =
|
||||
unexpected annotation used with `#[rustc_error(...)]`!
|
||||
|
||||
interface_temps_dir_error =
|
||||
failed to find or create the directory specified by `--temps-dir`
|
||||
|
|
|
|||
|
|
@ -73,20 +73,6 @@ pub struct TempsDirError;
|
|||
#[diag(interface_out_dir_error)]
|
||||
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> {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ fn opt_span_bug_fmt<S: Into<MultiSpan>>(
|
|||
pub fn trigger_delayed_bug(tcx: TyCtxt<'_>, key: rustc_hir::def_id::DefId) {
|
||||
tcx.dcx().span_delayed_bug(
|
||||
tcx.def_span(key),
|
||||
"delayed bug triggered by #[rustc_error(delayed_bug_from_inside_query)]",
|
||||
"delayed bug triggered by #[rustc_delayed_bug_from_inside_query]",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1771,6 +1771,7 @@ symbols! {
|
|||
rustc_deallocator,
|
||||
rustc_def_path,
|
||||
rustc_default_body_unstable,
|
||||
rustc_delayed_bug_from_inside_query,
|
||||
rustc_deny_explicit_impl,
|
||||
rustc_deprecated_safe_2024,
|
||||
rustc_diagnostic_item,
|
||||
|
|
@ -1787,7 +1788,6 @@ symbols! {
|
|||
rustc_dump_user_args,
|
||||
rustc_dump_vtable,
|
||||
rustc_effective_visibility,
|
||||
rustc_error,
|
||||
rustc_evaluate_where_clauses,
|
||||
rustc_expected_cgu_reuse,
|
||||
rustc_force_inline,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue