Skip to content

Commit

Permalink
rewrote error messages for #[rustc_error]
Browse files Browse the repository at this point in the history
  • Loading branch information
traxys committed Nov 5, 2019
1 parent fff3c25 commit f0d2061
Show file tree
Hide file tree
Showing 26 changed files with 38 additions and 32 deletions.
10 changes: 8 additions & 2 deletions src/librustc_codegen_utils/lib.rs
Expand Up @@ -29,7 +29,10 @@ pub mod symbol_names_test;


pub fn trigger_delay_span_bug(tcx: TyCtxt<'_>, key: DefId) {
tcx.sess.delay_span_bug(tcx.def_span(key), "compilation successful");
tcx.sess.delay_span_bug(
tcx.def_span(key),
"delayed span bug triggered by #[rustc_error(delay_span_bug_from_inside_query)]"
);
}

/// check for the #[rustc_error] annotation, which forces an
Expand All @@ -53,7 +56,10 @@ pub fn check_for_rustc_errors_attr(tcx: TyCtxt<'_>) {
}
// bare #[rustc_error]
None => {
tcx.sess.span_fatal(tcx.def_span(def_id), "compilation successful");
tcx.sess.span_fatal(
tcx.def_span(def_id),
"fatal error triggered by #[rustc_error]"
);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/incremental/delayed_span_bug.rs
@@ -1,6 +1,6 @@
// revisions: cfail1 cfail2
// should-ice
// error-pattern: compilation successful
// error-pattern: fatal error triggered by #[rustc_error]

#![feature(rustc_attrs)]

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/associated-types/bound-lifetime-constrained.rs
Expand Up @@ -45,4 +45,4 @@ fn clause2<T>() where T: for<'a> Fn() -> <() as Foo<'a>>::Item {
}

#[rustc_error]
fn main() { } //[ok]~ ERROR compilation successful
fn main() { } //[ok]~ ERROR fatal error triggered by #[rustc_error]
@@ -1,4 +1,4 @@
error: compilation successful
error: fatal error triggered by #[rustc_error]
--> $DIR/bound-lifetime-in-binding-only.rs:71:1
|
LL | fn main() { }
Expand Down
Expand Up @@ -68,4 +68,4 @@ fn ok3<T>() where for<'a> Parameterized<'a>: Foo<Item=&'a i32> {
}

#[rustc_error]
fn main() { } //[ok]~ ERROR compilation successful
fn main() { } //[ok]~ ERROR fatal error triggered by #[rustc_error]
@@ -1,4 +1,4 @@
error: compilation successful
error: fatal error triggered by #[rustc_error]
--> $DIR/bound-lifetime-in-return-only.rs:49:1
|
LL | fn main() { }
Expand Down
Expand Up @@ -46,4 +46,4 @@ fn ok2(_: &dyn for<'a,'b> Fn<(&'b Parameterized<'a>,), Output=&'a i32>) {
}

#[rustc_error]
fn main() { } //[ok]~ ERROR compilation successful
fn main() { } //[ok]~ ERROR fatal error triggered by #[rustc_error]
@@ -1,4 +1,4 @@
error: compilation successful
error: fatal error triggered by #[rustc_error]
--> $DIR/project-fn-ret-contravariant.rs:50:1
|
LL | fn main() { }
Expand Down
@@ -1,4 +1,4 @@
error: compilation successful
error: fatal error triggered by #[rustc_error]
--> $DIR/project-fn-ret-contravariant.rs:50:1
|
LL | fn main() { }
Expand Down
Expand Up @@ -48,5 +48,5 @@ fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {

#[rustc_error]
fn main() { }
//[ok]~^ ERROR compilation successful
//[oneuse]~^^ ERROR compilation successful
//[ok]~^ ERROR fatal error triggered by #[rustc_error]
//[oneuse]~^^ ERROR fatal error triggered by #[rustc_error]
@@ -1,4 +1,4 @@
error: compilation successful
error: fatal error triggered by #[rustc_error]
--> $DIR/project-fn-ret-invariant.rs:59:1
|
LL | fn main() { }
Expand Down
Expand Up @@ -57,4 +57,4 @@ fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {

#[rustc_error]
fn main() { }
//[ok]~^ ERROR compilation successful
//[ok]~^ ERROR fatal error triggered by #[rustc_error]
@@ -1,4 +1,4 @@
error: compilation successful
error: fatal error triggered by #[rustc_error]
--> $DIR/higher-ranked-projection.rs:24:1
|
LL | / fn main() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/associated-types/higher-ranked-projection.rs
Expand Up @@ -21,7 +21,7 @@ fn foo<U, T>(_t: T)
{}

#[rustc_error]
fn main() { //[good]~ ERROR compilation successful
fn main() { //[good]~ ERROR fatal error triggered by #[rustc_error]
foo(());
//[bad]~^ ERROR type mismatch
}
@@ -1,4 +1,4 @@
error: compilation successful
error: fatal error triggered by #[rustc_error]
--> $DIR/hr-subtype.rs:100:1
|
LL | / fn main() {
Expand Down
@@ -1,4 +1,4 @@
error: compilation successful
error: fatal error triggered by #[rustc_error]
--> $DIR/hr-subtype.rs:100:1
|
LL | / fn main() {
Expand Down
@@ -1,4 +1,4 @@
error: compilation successful
error: fatal error triggered by #[rustc_error]
--> $DIR/hr-subtype.rs:100:1
|
LL | / fn main() {
Expand Down
@@ -1,4 +1,4 @@
error: compilation successful
error: fatal error triggered by #[rustc_error]
--> $DIR/hr-subtype.rs:100:1
|
LL | / fn main() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_x.stderr
@@ -1,4 +1,4 @@
error: compilation successful
error: fatal error triggered by #[rustc_error]
--> $DIR/hr-subtype.rs:100:1
|
LL | / fn main() {
Expand Down
10 changes: 5 additions & 5 deletions src/test/ui/hr-subtype/hr-subtype.rs
Expand Up @@ -98,9 +98,9 @@ check! { bound_a_b_ret_a_vs_bound_a_ret_a: (for<'a,'b> fn(&'a u32, &'b u32) -> &

#[rustc_error]
fn main() {
//[bound_a_vs_bound_a]~^ ERROR compilation successful
//[bound_a_vs_bound_b]~^^ ERROR compilation successful
//[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful
//[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful
//[free_x_vs_free_x]~^^^^^ ERROR compilation successful
//[bound_a_vs_bound_a]~^ ERROR fatal error triggered by #[rustc_error]
//[bound_a_vs_bound_b]~^^ ERROR fatal error triggered by #[rustc_error]
//[bound_inv_a_vs_bound_inv_b]~^^^ ERROR fatal error triggered by #[rustc_error]
//[bound_co_a_vs_bound_co_b]~^^^^ ERROR fatal error triggered by #[rustc_error]
//[free_x_vs_free_x]~^^^^^ ERROR fatal error triggered by #[rustc_error]
}
2 changes: 1 addition & 1 deletion src/test/ui/proc-macro/no-macro-use-attr.rs
Expand Up @@ -7,4 +7,4 @@ extern crate test_macros;
//~^ WARN unused extern crate

#[rustc_error]
fn main() {} //~ ERROR compilation successful
fn main() {} //~ ERROR fatal error triggered by #[rustc_error]
2 changes: 1 addition & 1 deletion src/test/ui/proc-macro/no-macro-use-attr.stderr
Expand Up @@ -10,7 +10,7 @@ note: lint level defined here
LL | #![warn(unused_extern_crates)]
| ^^^^^^^^^^^^^^^^^^^^

error: compilation successful
error: fatal error triggered by #[rustc_error]
--> $DIR/no-macro-use-attr.rs:10:1
|
LL | fn main() {}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/rfc1445/feature-gate.rs
Expand Up @@ -18,7 +18,7 @@ struct Foo {
const FOO: Foo = Foo { x: 0 };

#[rustc_error]
fn main() { //[with_gate]~ ERROR compilation successful
fn main() { //[with_gate]~ ERROR fatal error triggered by #[rustc_error]
let y = Foo { x: 1 };
match y {
FOO => { }
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/rfc1445/feature-gate.with_gate.stderr
@@ -1,4 +1,4 @@
error: compilation successful
error: fatal error triggered by #[rustc_error]
--> $DIR/feature-gate.rs:21:1
|
LL | / fn main() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/rustc-error.rs
Expand Up @@ -2,5 +2,5 @@

#[rustc_error]
fn main() {
//~^ ERROR compilation successful
//~^ ERROR fatal error triggered by #[rustc_error]
}
2 changes: 1 addition & 1 deletion src/test/ui/rustc-error.stderr
@@ -1,4 +1,4 @@
error: compilation successful
error: fatal error triggered by #[rustc_error]
--> $DIR/rustc-error.rs:4:1
|
LL | / fn main() {
Expand Down

0 comments on commit f0d2061

Please sign in to comment.