Skip to content

Commit 5a44f70

Browse files
committed
Rollup merge of rust-lang#27127 - AlisdairO:diagnostics172, r=Manishearth
As title :-) Part of rust-lang#24407. r? @Manishearth
2 parents bc4daf7 + 686d326 commit 5a44f70

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/librustc/middle/intrinsicck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> {
165165
if from_tc.interior_param() || to_tc.interior_param() {
166166
span_err!(self.tcx.sess, span, E0139,
167167
"cannot transmute to or from a type that contains \
168-
type parameters in its interior");
168+
unsubstituted type parameters");
169169
return;
170170
}
171171

src/librustc_typeck/diagnostics.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,33 @@ return, for example with a `loop` that never breaks or a call to another
14581458
diverging function (such as `panic!()`).
14591459
"##,
14601460

1461+
E0172: r##"
1462+
This error means that an attempt was made to specify the type of a variable with
1463+
a combination of a concrete type and a trait. Consider the following example:
1464+
1465+
```
1466+
fn foo(bar: i32+std::fmt::Display) {}
1467+
```
1468+
1469+
The code is trying to specify that we want to receive a signed 32-bit integer
1470+
which also implements `Display`. This doesn't make sense: when we pass `i32`, a
1471+
concrete type, it implicitly includes all of the traits that it implements.
1472+
This includes `Display`, `Debug`, `Clone`, and a host of others.
1473+
1474+
If `i32` implements the trait we desire, there's no need to specify the trait
1475+
separately. If it does not, then we need to `impl` the trait for `i32` before
1476+
passing it into `foo`. Either way, a fixed definition for `foo` will look like
1477+
the following:
1478+
1479+
```
1480+
fn foo(bar: i32) {}
1481+
```
1482+
1483+
To learn more about traits, take a look at the Book:
1484+
1485+
https://doc.rust-lang.org/book/traits.html
1486+
"##,
1487+
14611488
E0178: r##"
14621489
In types, the `+` type operator has low precedence, so it is often necessary
14631490
to use parentheses.
@@ -2178,7 +2205,6 @@ register_diagnostics! {
21782205
E0164,
21792206
E0167,
21802207
E0168,
2181-
E0172,
21822208
E0173, // manual implementations of unboxed closure traits are experimental
21832209
E0174, // explicit use of unboxed closure methods are experimental
21842210
E0182,

0 commit comments

Comments
 (0)