Skip to content

Commit ae53641

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 2eaa61d + 25c9097 commit ae53641

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
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
}

0 commit comments

Comments
 (0)