Skip to content

Cleanup err codes #67422

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

Merged
merged 4 commits into from
Dec 21, 2019
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
10 changes: 6 additions & 4 deletions src/librustc_error_codes/error_codes/E0120.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
An attempt was made to implement Drop on a trait, which is not allowed: only
structs and enums can implement Drop. An example causing this error:
Drop was implemented on a trait, which is not allowed: only structs and
enums can implement Drop.

Erroneous code example:

```compile_fail,E0120
trait MyTrait {}
Expand All @@ -10,7 +12,7 @@ impl Drop for MyTrait {
```

A workaround for this problem is to wrap the trait up in a struct, and implement
Drop on that. An example is shown below:
Drop on that:

```
trait MyTrait {}
Expand All @@ -22,7 +24,7 @@ impl <T: MyTrait> Drop for MyWrapper<T> {

```

Alternatively, wrapping trait objects requires something like the following:
Alternatively, wrapping trait objects requires something:

```
trait MyTrait {}
Expand Down
24 changes: 19 additions & 5 deletions src/librustc_error_codes/error_codes/E0121.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
In order to be consistent with Rust's lack of global type inference,
type and const placeholders are disallowed by design in item signatures.
The type placeholder `_` was used within a type on an item's signature.

Examples of this error include:
Erroneous code example:

```compile_fail,E0121
fn foo() -> _ { 5 } // error, explicitly write out the return type instead
fn foo() -> _ { 5 } // error

static BAR: _ = "test"; // error, explicitly write out the type instead
static BAR: _ = "test"; // error
```

In those cases, you need to provide the type explicitly:

```
fn foo() -> i32 { 5 } // ok!

static BAR: &str = "test"; // ok!
```

The type placeholder `_` can be used outside item's signature as follows:

```
let x = "a4a".split('4')
.collect::<Vec<_>>(); // No need to precise the Vec's generic type.
```