Skip to content

Commit

Permalink
Add diagnostics for E0172, fix inline error message for E0139
Browse files Browse the repository at this point in the history
  • Loading branch information
AlisdairO committed Jul 20, 2015
1 parent 6c88aed commit 686d326
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/librustc/middle/intrinsicck.rs
Expand Up @@ -165,7 +165,7 @@ impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> {
if from_tc.interior_param() || to_tc.interior_param() {
span_err!(self.tcx.sess, span, E0139,
"cannot transmute to or from a type that contains \
type parameters in its interior");
unsubstituted type parameters");
return;
}

Expand Down
28 changes: 27 additions & 1 deletion src/librustc_typeck/diagnostics.rs
Expand Up @@ -1476,6 +1476,33 @@ return, for example with a `loop` that never breaks or a call to another
diverging function (such as `panic!()`).
"##,

E0172: r##"
This error means that an attempt was made to specify the type of a variable with
a combination of a concrete type and a trait. Consider the following example:
```
fn foo(bar: i32+std::fmt::Display) {}
```
The code is trying to specify that we want to receive a signed 32-bit integer
which also implements `Display`. This doesn't make sense: when we pass `i32`, a
concrete type, it implicitly includes all of the traits that it implements.
This includes `Display`, `Debug`, `Clone`, and a host of others.
If `i32` implements the trait we desire, there's no need to specify the trait
separately. If it does not, then we need to `impl` the trait for `i32` before
passing it into `foo`. Either way, a fixed definition for `foo` will look like
the following:
```
fn foo(bar: i32) {}
```
To learn more about traits, take a look at the Book:
https://doc.rust-lang.org/book/traits.html
"##,

E0178: r##"
In types, the `+` type operator has low precedence, so it is often necessary
to use parentheses.
Expand Down Expand Up @@ -2196,7 +2223,6 @@ register_diagnostics! {
E0164,
E0167,
E0168,
E0172,
E0173, // manual implementations of unboxed closure traits are experimental
E0174, // explicit use of unboxed closure methods are experimental
E0182,
Expand Down

0 comments on commit 686d326

Please sign in to comment.