Skip to content

Commit eb42422

Browse files
authored
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).
2 parents 1296a23 + 2dfd2a2 commit eb42422

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

+3-3
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

-6
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

-14
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

+6-36
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

+1-1
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

+1-1
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

-4
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

+2-2
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

-8
This file was deleted.

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

+2-3
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() { }

tests/ui/associated-types/bound-lifetime-in-binding-only.ok.stderr

-8
This file was deleted.

tests/ui/associated-types/bound-lifetime-in-binding-only.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ revisions: angle paren ok elision
2+
//@[ok] check-pass
23

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

77
trait Foo {
@@ -67,5 +67,4 @@ fn ok2<T: for<'a,'b> Fn<(&'b Parameterized<'a>,), Output=&'a i32>>() {
6767
fn ok3<T>() where for<'a> Parameterized<'a>: Foo<Item=&'a i32> {
6868
}
6969

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

tests/ui/associated-types/bound-lifetime-in-return-only.ok.stderr

-8
This file was deleted.

tests/ui/associated-types/bound-lifetime-in-return-only.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ revisions: sig local structure ok elision
2+
//@[ok] check-pass
23

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

77
trait Foo {
@@ -45,5 +45,4 @@ fn ok1(_: &dyn for<'a> Fn(&Parameterized<'a>) -> &'a i32) {
4545
fn ok2(_: &dyn for<'a,'b> Fn<(&'b Parameterized<'a>,), Output=&'a i32>) {
4646
}
4747

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

tests/ui/borrowck/borrowck-report-with-custom-diagnostic.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#![feature(rustc_attrs)]
21
#![allow(dead_code)]
3-
fn main() { #![rustc_error] // rust-lang/rust#49855
2+
fn main() {
43
// Original borrow ends at end of function
54
let mut x = 1;
65
let y = &mut x;

tests/ui/borrowck/borrowck-report-with-custom-diagnostic.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
2-
--> $DIR/borrowck-report-with-custom-diagnostic.rs:8:13
2+
--> $DIR/borrowck-report-with-custom-diagnostic.rs:7:13
33
|
44
LL | let y = &mut x;
55
| ------ mutable borrow occurs here
@@ -11,7 +11,7 @@ LL | y.use_mut();
1111
| - mutable borrow later used here
1212

1313
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
14-
--> $DIR/borrowck-report-with-custom-diagnostic.rs:21:21
14+
--> $DIR/borrowck-report-with-custom-diagnostic.rs:20:21
1515
|
1616
LL | let y = &x;
1717
| -- immutable borrow occurs here
@@ -23,7 +23,7 @@ LL | y.use_ref();
2323
| - immutable borrow later used here
2424

2525
error[E0499]: cannot borrow `x` as mutable more than once at a time
26-
--> $DIR/borrowck-report-with-custom-diagnostic.rs:36:17
26+
--> $DIR/borrowck-report-with-custom-diagnostic.rs:35:17
2727
|
2828
LL | let y = &mut x;
2929
| ------ first mutable borrow occurs here

tests/ui/borrowck/mut-borrow-outside-loop.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ensure borrowck messages are correct outside special case
2-
#![feature(rustc_attrs)]
3-
fn main() { #![rustc_error] // rust-lang/rust#49855
2+
3+
fn main() {
44
let mut void = ();
55

66
let first = &mut void;

tests/ui/codemap_tests/issue-11715.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#![feature(rustc_attrs)]
2-
fn main() { #![rustc_error] // rust-lang/rust#49855
1+
fn main() {
32
let mut x = "foo";
43
let y = &mut x;
54
let z = &mut x; //~ ERROR cannot borrow

tests/ui/codemap_tests/issue-11715.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0499]: cannot borrow `x` as mutable more than once at a time
2-
--> $DIR/issue-11715.rs:5:13
2+
--> $DIR/issue-11715.rs:4:13
33
|
44
LL | let y = &mut x;
55
| ------ first mutable borrow occurs here

tests/ui/consts/async-block.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
//@ edition:2018
44
//@ revisions: with_feature without_feature
5+
//@[with_feature] check-pass
56

6-
#![feature(rustc_attrs)]
77
#![cfg_attr(with_feature, feature(const_async_blocks))]
88

99
use std::future::Future;
@@ -15,5 +15,4 @@ const _: i32 = { core::mem::ManuallyDrop::new(async { 0 }); 4 };
1515
static _FUT: &(dyn Future<Output = ()> + Sync) = &async {};
1616
//[without_feature]~^ `async` block
1717

18-
#[rustc_error]
19-
fn main() {} //[with_feature]~ fatal error triggered by #[rustc_error]
18+
fn main() {}

tests/ui/consts/async-block.with_feature.stderr

-8
This file was deleted.

tests/ui/diagnostic-flags/allow-non-lint-warnings.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@
1313
//! - Original impl PR: <https://github.com/rust-lang/rust/pull/21248>.
1414
//! - RFC 507 "Release channels":
1515
//! <https://github.com/rust-lang/rfcs/blob/c017755b9bfa0421570d92ba38082302e0f3ad4f/text/0507-release-channels.md>.
16-
#![feature(rustc_attrs)]
1716
1817
//@ revisions: without_flag with_flag
1918

19+
//@ check-pass
20+
//@ compile-flags: -Zunleash-the-miri-inside-of-you
2021
//@[with_flag] compile-flags: -Awarnings
2122

22-
//@ check-pass
23+
fn non_constant() {}
24+
const fn constant() { non_constant() }
2325

24-
#[rustc_error(warn)]
2526
fn main() {}
26-
//[without_flag]~^ WARN unexpected annotation used with `#[rustc_error(...)]`!
27+
28+
//[without_flag]~? WARN skipping const checks
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
warning: unexpected annotation used with `#[rustc_error(...)]`!
2-
--> $DIR/allow-non-lint-warnings.rs:25:1
1+
warning: skipping const checks
32
|
4-
LL | fn main() {}
5-
| ^^^^^^^^^
3+
help: skipping check that does not even have a feature gate
4+
--> $DIR/allow-non-lint-warnings.rs:24:23
5+
|
6+
LL | const fn constant() { non_constant() }
7+
| ^^^^^^^^^^^^^^
68

79
warning: 1 warning emitted
810

Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Test that `#[rustc_*]` attributes are gated by `rustc_attrs` feature gate.
22

33
#[rustc_variance] //~ ERROR the `#[rustc_variance]` attribute is just used for rustc unit tests and will never be stable
4-
#[rustc_error] //~ ERROR the `#[rustc_error]` attribute is just used for rustc unit tests and will never be stable
54
#[rustc_nonnull_optimization_guaranteed] //~ ERROR the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to document guaranteed niche optimizations in libcore and libstd and will never be stable
65

76
fn main() {}

tests/ui/feature-gates/feature-gate-rustc-attrs-1.stderr

+2-11
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,16 @@ LL | #[rustc_variance]
77
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
88
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
99

10-
error[E0658]: the `#[rustc_error]` attribute is just used for rustc unit tests and will never be stable
11-
--> $DIR/feature-gate-rustc-attrs-1.rs:4:1
12-
|
13-
LL | #[rustc_error]
14-
| ^^^^^^^^^^^^^^
15-
|
16-
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
17-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
18-
1910
error[E0658]: the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to document guaranteed niche optimizations in libcore and libstd and will never be stable
2011
(note that the compiler does not even check whether the type indeed is being non-null-optimized; it is your responsibility to ensure that the attribute is only used on types that are optimized)
21-
--> $DIR/feature-gate-rustc-attrs-1.rs:5:1
12+
--> $DIR/feature-gate-rustc-attrs-1.rs:4:1
2213
|
2314
LL | #[rustc_nonnull_optimization_guaranteed]
2415
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2516
|
2617
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
2718
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
2819

29-
error: aborting due to 3 previous errors
20+
error: aborting due to 2 previous errors
3021

3122
For more information about this error, try `rustc --explain E0658`.

tests/ui/mir/issue-75053.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
//@ check-pass
12
//@ compile-flags: -Z mir-opt-level=3
23

3-
#![feature(type_alias_impl_trait, rustc_attrs)]
4+
#![feature(type_alias_impl_trait)]
45

56
use std::marker::PhantomData;
67

@@ -43,8 +44,6 @@ impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<Phantom1<T>> for Scope<U> {
4344
}
4445
}
4546

46-
#[rustc_error]
4747
fn main() {
48-
//~^ ERROR
4948
let _pos: Phantom1<DummyT<()>> = Scope::new().my_index();
5049
}

0 commit comments

Comments
 (0)