-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Error code explanation extra check #71350
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
Inherent associated types were part of [RFC 195] but are not yet implemented. | ||
See [the tracking issue][iss8995] for the status of this implementation. | ||
|
||
Erroneous code example: | ||
|
||
```compile_fail,E0202 | ||
struct Foo; | ||
|
||
impl Foo { | ||
type Bar = isize; // error! | ||
} | ||
``` | ||
|
||
[RFC 195]: https://github.com/rust-lang/rfcs/blob/master/text/0195-associated-items.md | ||
[iss8995]: https://github.com/rust-lang/rust/issues/8995 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,11 @@ message for when a particular trait isn't implemented on a type placed in a | |
position that needs that trait. For example, when the following code is | ||
compiled: | ||
|
||
```compile_fail | ||
```compile_fail,E0232 | ||
#![feature(rustc_attrs)] | ||
|
||
fn foo<T: Index<u8>>(x: T){} | ||
|
||
#[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"] | ||
trait Index<Idx> { /* ... */ } | ||
|
||
foo(true); // `bool` does not implement `Index<u8>` | ||
#[rustc_on_unimplemented(lorem="")] // error! | ||
trait BadAnnotation {} | ||
``` | ||
|
||
there will be an error about `bool` not implementing `Index<u8>`, followed by a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this still has the wrong explanation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes but it has to be fixed in another PR. ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, can you open an issue about it? |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
Example of erroneous code: | ||
|
||
```compile_fail | ||
```compile_fail,E0590 | ||
while break {} | ||
``` | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,19 @@ | ||
A `#[marker]` trait contained an associated item. | ||
|
||
Erroneous code example: | ||
|
||
```compile_fail,E0714 | ||
#![feature(marker_trait_attr)] | ||
#![feature(associated_type_defaults)] | ||
|
||
#[marker] | ||
trait MarkerConst { | ||
const N: usize; // error! | ||
} | ||
|
||
fn main() {} | ||
``` | ||
|
||
The items of marker traits cannot be overridden, so there's no need to have them | ||
when they cannot be changed per-type anyway. If you wanted them for ergonomic | ||
reasons, consider making an extension trait instead. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,24 @@ | ||
An `impl` for a `#[marker]` trait tried to override an associated item. | ||
|
||
Erroneous code example: | ||
|
||
```compile_fail,E0715 | ||
#![feature(marker_trait_attr)] | ||
|
||
#[marker] | ||
trait Marker { | ||
const N: usize = 0; | ||
fn do_something() {} | ||
} | ||
|
||
struct OverrideConst; | ||
impl Marker for OverrideConst { // error! | ||
const N: usize = 1; | ||
} | ||
|
||
fn main() {} | ||
``` | ||
|
||
Because marker traits are allowed to have multiple implementations for the same | ||
type, it's not allowed to override anything in those implementations, as it | ||
would be ambiguous which override should actually be used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is a major change to the previous one and doesn't reflect what the text around it says
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll need to be updated I guess. But before, it wasn't throwing the correct error code.