Skip to content

Commit 189dee6

Browse files
committed
Update E0393 to new error format
1 parent 86dde9b commit 189dee6

File tree

5 files changed

+26
-13
lines changed

5 files changed

+26
-13
lines changed

src/librustc_typeck/astconv.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -515,12 +515,13 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
515515
// defaults. This will lead to an ICE if we are not
516516
// careful!
517517
if default_needs_object_self(def) {
518-
span_err!(tcx.sess, span, E0393,
519-
"the type parameter `{}` must be explicitly specified \
520-
in an object type because its default value `{}` references \
521-
the type `Self`",
522-
def.name,
523-
default);
518+
struct_span_err!(tcx.sess, span, E0393,
519+
"the type parameter `{}` must be explicitly specified",
520+
def.name)
521+
.span_label(span, &format!("missing reference to `{}`", def.name))
522+
.note(&format!("because of the default `Self` reference, \
523+
type parameters must be specified on object types"))
524+
.emit();
524525
tcx.types.err
525526
} else {
526527
// This is a default type parameter.

src/test/compile-fail/E0393.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010

1111
trait A<T=Self> {}
1212

13-
fn together_we_will_rule_the_galaxy(son: &A) {} //~ ERROR E0393
13+
fn together_we_will_rule_the_galaxy(son: &A) {}
14+
//~^ ERROR E0393
15+
//~| NOTE missing reference to `T`
16+
//~| NOTE because of the default `Self` reference, type parameters must be specified on object types
1417

1518
fn main() {
1619
}

src/test/compile-fail/issue-21950.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ use std::ops::Add;
1515
fn main() {
1616
let x = &10 as
1717
&Add;
18-
//~^ ERROR the type parameter `RHS` must be explicitly specified in an object type because its default value `Self` references the type `Self`
19-
//~| ERROR the value of the associated type `Output` (from the trait `std::ops::Add`) must be specified
18+
//~^ ERROR E0393
19+
//~| NOTE missing reference to `RHS`
20+
//~| NOTE because of the default `Self` reference, type parameters must be specified on object types
21+
//~| ERROR E0191
22+
//~| NOTE missing associated type `Output` value
2023
}

src/test/compile-fail/issue-22370.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
trait A<T=Self> {}
1414

1515
fn f(a: &A) {}
16-
//~^ ERROR the type parameter `T` must be explicitly specified in an object type because its default value `Self` references the type `Self`
16+
//~^ ERROR E0393
17+
//~| NOTE missing reference to `T`
18+
//~| NOTE because of the default `Self` reference, type parameters must be specified on object types
1719

1820
fn main() {}

src/test/compile-fail/issue-22560.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@
1313
use std::ops::{Add, Sub};
1414

1515
type Test = Add +
16-
//~^ ERROR the type parameter `RHS` must be explicitly specified in an object type because its default value `Self` references the type `Self`
17-
//~^^ ERROR the value of the associated type `Output` (from the trait `std::ops::Add`) must be specified [E0191]
16+
//~^ ERROR E0393
17+
//~| NOTE missing reference to `RHS`
18+
//~| NOTE because of the default `Self` reference, type parameters must be specified on object types
19+
//~| ERROR E0191
20+
//~| NOTE missing associated type `Output` value
1821
Sub;
19-
//~^ ERROR only the builtin traits can be used as closure or object bounds
22+
//~^ ERROR E0225
23+
//~| NOTE non-builtin trait used as bounds
2024

2125
fn main() { }

0 commit comments

Comments
 (0)