Skip to content

Commit 5dc779b

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#36114 - zjhmale:fix-E0393, r=jonathandturner
Update E0393 to new error format Fixes rust-lang#35632. Part of rust-lang#35233. r? @jonathandturner and a wired thing is that if i add another label ```rust .span_label(span, &format!("missing reference to `{}`", def.name)) .span_label(span, &format!("because of the default `Self` reference, type parameters must be specified on object types")) ``` and add a new note in the test case like ```rust trait A<T=Self> {} fn together_we_will_rule_the_galaxy(son: &A) {} //~^ ERROR E0393 //~| NOTE missing reference to `T` //~| NOTE because of the default `Self` reference, type parameters must be specified on object types ``` it will complain that ``` running 1 test test [compile-fail] compile-fail/E0393.rs ... FAILED failures: ---- [compile-fail] compile-fail/E0393.rs stdout ---- error: /Users/zjh/Documents/rustspace/rust/src/test/compile-fail/E0393.rs:13: unexpected "error": '13:43: 13:44: the type parameter `T` must be explicitly specified [E0393]' unexpected errors (from JSON output): [ Error { line_num: 13, kind: Some( Error ), msg: "13:43: 13:44: the type parameter `T` must be explicitly specified [E0393]" } ] ``` it is a little bit confusing and through the blog post we can use `//~^` and `//~|` to support multiple notes, @jonathandturner am i missing something here?
2 parents bbb2d1d + 189dee6 commit 5dc779b

File tree

5 files changed

+26
-13
lines changed

5 files changed

+26
-13
lines changed

src/librustc_typeck/astconv.rs

Lines changed: 7 additions & 6 deletions
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

Lines changed: 4 additions & 1 deletion
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

Lines changed: 5 additions & 2 deletions
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 7 additions & 3 deletions
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)