Skip to content

Commit 2dfd2a2

Browse files
committed
Remove attribute #[rustc_error]
1 parent d4812c8 commit 2dfd2a2

File tree

47 files changed

+72
-236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+72
-236
lines changed

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,9 +1087,9 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
10871087
WarnFollowing, EncodeCrossCrate::No
10881088
),
10891089
rustc_attr!(
1090-
TEST, rustc_error, Normal,
1091-
template!(Word, List: "delayed_bug_from_inside_query"),
1092-
WarnFollowingWordOnly, EncodeCrossCrate::Yes
1090+
TEST, rustc_delayed_bug_from_inside_query, Normal,
1091+
template!(Word),
1092+
WarnFollowing, EncodeCrossCrate::No
10931093
),
10941094
rustc_attr!(
10951095
TEST, rustc_dump_user_args, Normal, template!(Word),

compiler/rustc_interface/messages.ftl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,5 @@ interface_out_dir_error =
5050
interface_proc_macro_crate_panic_abort =
5151
building proc macro crate with `panic=abort` may crash the compiler should the proc-macro panic
5252
53-
interface_rustc_error_fatal =
54-
fatal error triggered by #[rustc_error]
55-
56-
interface_rustc_error_unexpected_annotation =
57-
unexpected annotation used with `#[rustc_error(...)]`!
58-
5953
interface_temps_dir_error =
6054
failed to find or create the directory specified by `--temps-dir`

compiler/rustc_interface/src/errors.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,6 @@ pub struct TempsDirError;
7373
#[diag(interface_out_dir_error)]
7474
pub struct OutDirError;
7575

76-
#[derive(Diagnostic)]
77-
#[diag(interface_rustc_error_fatal)]
78-
pub struct RustcErrorFatal {
79-
#[primary_span]
80-
pub span: Span,
81-
}
82-
83-
#[derive(Diagnostic)]
84-
#[diag(interface_rustc_error_unexpected_annotation)]
85-
pub struct RustcErrorUnexpectedAnnotation {
86-
#[primary_span]
87-
pub span: Span,
88-
}
89-
9076
#[derive(Diagnostic)]
9177
#[diag(interface_failed_writing_file)]
9278
pub struct FailedWritingFile<'a> {

compiler/rustc_interface/src/passes.rs

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
11061072
pub(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.

compiler/rustc_middle/src/util/bug.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fn opt_span_bug_fmt<S: Into<MultiSpan>>(
4949
pub fn trigger_delayed_bug(tcx: TyCtxt<'_>, key: rustc_hir::def_id::DefId) {
5050
tcx.dcx().span_delayed_bug(
5151
tcx.def_span(key),
52-
"delayed bug triggered by #[rustc_error(delayed_bug_from_inside_query)]",
52+
"delayed bug triggered by #[rustc_delayed_bug_from_inside_query]",
5353
);
5454
}
5555

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1771,6 +1771,7 @@ symbols! {
17711771
rustc_deallocator,
17721772
rustc_def_path,
17731773
rustc_default_body_unstable,
1774+
rustc_delayed_bug_from_inside_query,
17741775
rustc_deny_explicit_impl,
17751776
rustc_deprecated_safe_2024,
17761777
rustc_diagnostic_item,
@@ -1787,7 +1788,6 @@ symbols! {
17871788
rustc_dump_user_args,
17881789
rustc_dump_vtable,
17891790
rustc_effective_visibility,
1790-
rustc_error,
17911791
rustc_evaluate_where_clauses,
17921792
rustc_expected_cgu_reuse,
17931793
rustc_force_inline,

src/tools/rust-analyzer/crates/hir-expand/src/inert_attr_macro.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -665,10 +665,6 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
665665
rustc_attr!(TEST, rustc_layout, Normal, template!(List: "field1, field2, ..."), WarnFollowing),
666666
rustc_attr!(TEST, rustc_abi, Normal, template!(List: "field1, field2, ..."), WarnFollowing),
667667
rustc_attr!(TEST, rustc_regions, Normal, template!(Word), WarnFollowing),
668-
rustc_attr!(
669-
TEST, rustc_error, Normal,
670-
template!(Word, List: "delayed_bug_from_inside_query"), WarnFollowingWordOnly
671-
),
672668
rustc_attr!(TEST, rustc_dump_user_args, Normal, template!(Word), WarnFollowing),
673669
rustc_attr!(TEST, rustc_evaluate_where_clauses, Normal, template!(Word), WarnFollowing),
674670
rustc_attr!(

tests/incremental/delayed_span_bug.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//@ revisions: cfail1 cfail2
22
//@ should-ice
3-
//@ error-pattern: delayed bug triggered by #[rustc_error(delayed_bug_from_inside_query)]
3+
//@ error-pattern: delayed bug triggered by #[rustc_delayed_bug_from_inside_query]
44

55
#![feature(rustc_attrs)]
66

7-
#[rustc_error(delayed_bug_from_inside_query)]
7+
#[rustc_delayed_bug_from_inside_query]
88
fn main() {}

tests/ui/associated-types/bound-lifetime-constrained.ok.stderr

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/ui/associated-types/bound-lifetime-constrained.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ revisions: func object clause ok
2+
//@[ok] check-pass
23

34
#![allow(dead_code)]
4-
#![feature(rustc_attrs)]
55

66
trait Foo<'a> {
77
type Item;
@@ -44,5 +44,4 @@ fn clause2<T>() where T: for<'a> Fn() -> <() as Foo<'a>>::Item {
4444
//[clause]~^ ERROR `Output` references lifetime `'a`
4545
}
4646

47-
#[rustc_error]
48-
fn main() { } //[ok]~ ERROR fatal error triggered by #[rustc_error]
47+
fn main() { }

0 commit comments

Comments
 (0)