Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update E0393 to new error format #36114

Merged
merged 1 commit into from
Sep 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,12 +515,13 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
// defaults. This will lead to an ICE if we are not
// careful!
if default_needs_object_self(def) {
span_err!(tcx.sess, span, E0393,
"the type parameter `{}` must be explicitly specified \
in an object type because its default value `{}` references \
the type `Self`",
def.name,
default);
struct_span_err!(tcx.sess, span, E0393,
"the type parameter `{}` must be explicitly specified",
def.name)
.span_label(span, &format!("missing reference to `{}`", def.name))
.note(&format!("because of the default `Self` reference, \
type parameters must be specified on object types"))
.emit();
tcx.types.err
} else {
// This is a default type parameter.
Expand Down
5 changes: 4 additions & 1 deletion src/test/compile-fail/E0393.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@

trait A<T=Self> {}

fn together_we_will_rule_the_galaxy(son: &A) {} //~ ERROR E0393
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

fn main() {
}
7 changes: 5 additions & 2 deletions src/test/compile-fail/issue-21950.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ use std::ops::Add;
fn main() {
let x = &10 as
&Add;
//~^ ERROR the type parameter `RHS` must be explicitly specified in an object type because its default value `Self` references the type `Self`
//~| ERROR the value of the associated type `Output` (from the trait `std::ops::Add`) must be specified
//~^ ERROR E0393
//~| NOTE missing reference to `RHS`
//~| NOTE because of the default `Self` reference, type parameters must be specified on object types
//~| ERROR E0191
//~| NOTE missing associated type `Output` value
}
4 changes: 3 additions & 1 deletion src/test/compile-fail/issue-22370.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
trait A<T=Self> {}

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

fn main() {}
10 changes: 7 additions & 3 deletions src/test/compile-fail/issue-22560.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@
use std::ops::{Add, Sub};

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

fn main() { }