-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add 8 more error explanations. #25398
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 2 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 |
---|---|---|
|
@@ -49,6 +49,88 @@ about what constitutes an Item declaration and what does not: | |
http://doc.rust-lang.org/reference.html#statements | ||
"##, | ||
|
||
E0251: r##" | ||
Two items of the same name cannot be imported without rebinding one of the | ||
items under a new local name. | ||
|
||
An example of this error: | ||
|
||
``` | ||
use foo::baz; | ||
use bar::*; // error, do `use foo::baz as quux` instead on the previous line | ||
|
||
fn main() {} | ||
|
||
mod foo { | ||
pub struct baz; | ||
} | ||
|
||
mod bar { | ||
pub mod baz {} | ||
} | ||
``` | ||
"##, | ||
|
||
E0252: r##" | ||
Two items of the same name cannot be imported without rebinding one of the | ||
items under a new local name. | ||
|
||
An example of this error: | ||
|
||
``` | ||
use foo::baz; | ||
use bar::baz; // error, do `use bar::baz as quux` instead | ||
|
||
fn main() {} | ||
|
||
mod foo { | ||
pub struct baz; | ||
} | ||
|
||
mod bar { | ||
pub mod baz {} | ||
} | ||
``` | ||
"##, | ||
|
||
E0255: r##" | ||
You can't import a value whose name is the same as another value defined in the | ||
module. | ||
|
||
An example of this error: | ||
|
||
``` | ||
use foo::FOO; // error, do `use foo::FOO as BAR` instead | ||
|
||
fn FOO() {} | ||
|
||
mod foo { | ||
pub const FOO: bool = true; | ||
} | ||
|
||
fn main() {} | ||
``` | ||
"##, | ||
|
||
E0256: r##" | ||
You can't import a type or module when the name of the item being imported is | ||
the same as another type or submodule defined in the module. | ||
|
||
An example of this error: | ||
|
||
``` | ||
use foo::Bar; // error | ||
|
||
struct Bar; | ||
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. unit structs put a name into both the value and type namespace. Since each of these examples seems to be trying to illustrate each specific conflict, it might be better to use an example that only inserts into the type namespace. A non-unit struct would work for that, but I think (But, just to be clear: No need to block landing this PR on this suggestion alone.) 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. Thanks, great point. |
||
|
||
mod foo { | ||
pub mod Bar { } | ||
} | ||
|
||
fn main() {} | ||
``` | ||
"##, | ||
|
||
E0259: r##" | ||
The name chosen for an external crate conflicts with another external crate that | ||
has been imported into the current module. | ||
|
@@ -122,14 +204,10 @@ http://doc.rust-lang.org/reference.html#types | |
register_diagnostics! { | ||
E0157, | ||
E0153, | ||
E0251, // a named type or value has already been imported in this module | ||
E0252, // a named type or value has already been imported in this module | ||
E0253, // not directly importable | ||
E0254, // import conflicts with imported crate in this module | ||
E0255, // import conflicts with value in this module | ||
E0256, // import conflicts with type in this module | ||
E0257, // inherent implementations are only allowed on types defined in the current module | ||
E0258, // import conflicts with existing submodule | ||
E0257, | ||
E0258, | ||
E0364, // item is private | ||
E0365 // item is private | ||
} |
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.
Maybe this could be something like
(I just find the upper-case
FOO
slightly strange.)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.
Thanks, that's a much better.