Skip to content

Commit 5402271

Browse files
author
Ryan Senior
committed
Add an error explaination for E0182
1 parent e011175 commit 5402271

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

src/librustc_typeck/diagnostics.rs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1915,6 +1915,45 @@ More details can be found in [RFC 438].
19151915
[RFC 438]: https://github.com/rust-lang/rfcs/pull/438
19161916
"##,
19171917

1918+
E0182: r##"
1919+
You bound an associated type in an expression path which is not
1920+
allowed.
1921+
1922+
Erroneous code example:
1923+
1924+
```compile_fail,E0182
1925+
trait Foo {
1926+
type A;
1927+
fn bar() -> isize;
1928+
}
1929+
1930+
impl Foo for isize {
1931+
type A = usize;
1932+
fn bar() -> isize { 42 }
1933+
}
1934+
1935+
// error: unexpected binding of associated item in expression path
1936+
let x: isize = Foo::<A=usize>::bar();
1937+
```
1938+
1939+
To give a concrete type when using the Universal Function Call Syntax,
1940+
use "Type as Trait". Example:
1941+
1942+
```
1943+
trait Foo {
1944+
type A;
1945+
fn bar() -> isize;
1946+
}
1947+
1948+
impl Foo for isize {
1949+
type A = usize;
1950+
fn bar() -> isize { 42 }
1951+
}
1952+
1953+
let x: isize = <isize as Foo>::bar(); // ok!
1954+
```
1955+
"##,
1956+
19181957
E0184: r##"
19191958
Explicitly implementing both Drop and Copy for a type is currently disallowed.
19201959
This feature can make some sense in theory, but the current implementation is
@@ -4054,7 +4093,6 @@ register_diagnostics! {
40544093
// E0168,
40554094
// E0173, // manual implementations of unboxed closure traits are experimental
40564095
// E0174,
4057-
E0182,
40584096
E0183,
40594097
// E0187, // can't infer the kind of the closure
40604098
// E0188, // can not cast an immutable reference to a mutable pointer

0 commit comments

Comments
 (0)