register_long_diagnostics! {
E0154: r##"
+## Note: this error code is no longer emitted by the compiler.
+
Imports (`use` statements) are not allowed after non-item statements, such as
variable declarations and expression statements.
"##,
E0251: r##"
+## Note: this error code is no longer emitted by the compiler.
+
Two items of the same name cannot be imported without rebinding one of the
items under a new local name.
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:
+Erroneous code example:
-```compile_fail
+```compile_fail,E0252
use foo::baz;
use bar::baz; // error, do `use bar::baz as quux` instead
pub struct baz;
}
+mod bar {
+ pub mod baz {}
+}
+```
+
+You can use aliases in order to fix this error. Example:
+
+```
+use foo::baz as foo_baz;
+use bar::baz; // ok!
+
+fn main() {}
+
+mod foo {
+ pub struct baz;
+}
+
+mod bar {
+ pub mod baz {}
+}
+```
+
+Or you can reference the item with its parent:
+
+```
+use bar::baz;
+
+fn main() {
+ let x = foo::baz; // ok!
+}
+
+mod foo {
+ pub struct baz;
+}
+
mod bar {
pub mod baz {}
}
E0253: r##"
Attempt was made to import an unimportable value. This can happen when trying
-to import a method from a trait. An example of this error:
+to import a method from a trait.
-```compile_fail
+Erroneous code example:
+
+```compile_fail,E0253
mod foo {
pub trait MyTrait {
fn do_something();
}
use foo::MyTrait::do_something;
+
+fn main() {}
```
It's invalid to directly import methods belonging to a trait or concrete type.
You can't import a value whose name is the same as another value defined in the
module.
-An example of this error:
+Erroneous code example:
-```compile_fail
-use bar::foo; // error, do `use bar::foo as baz` instead
+```compile_fail,E0255
+use bar::foo; // error: an item named `foo` is already in scope
fn foo() {}
fn main() {}
```
+
+You can use aliases in order to fix this error. Example:
+
+```
+use bar::foo as bar_foo; // ok!
+
+fn foo() {}
+
+mod bar {
+ pub fn foo() {}
+}
+
+fn main() {}
+```
+
+Or you can reference the item with its parent:
+
+```
+fn foo() {}
+
+mod bar {
+ pub fn foo() {}
+}
+
+fn main() {
+ bar::foo(); // we get the item by referring to its parent
+}
+```
"##,
E0256: r##"
+## Note: this error code is no longer emitted by the compiler.
+
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.
Erroneous code example:
-```compile_fail
-extern crate a;
-extern crate crate_a as a;
+```compile_fail,E0259
+extern crate std;
+extern crate libc as std;
+
+fn main() {}
```
The solution is to choose a different name that doesn't conflict with any
Correct example:
```ignore
-extern crate a;
-extern crate crate_a as other_name;
+extern crate std;
+extern crate libc as other_name;
```
"##,
E0260: r##"
The name for an item declaration conflicts with an external crate's name.
-For instance:
+Erroneous code example:
-```ignore
+```ignore,E0260
extern crate abc;
struct abc;
"##,
E0364: r##"
-Private items cannot be publicly re-exported. This error indicates that you
+Private items cannot be publicly re-exported. This error indicates that you
attempted to `pub use` a type or value that was not itself public.
-Here is an example that demonstrates the error:
+Erroneous code example:
```compile_fail
mod foo {
}
pub use foo::X;
+
+fn main() {}
```
The solution to this problem is to ensure that the items that you are
re-exporting are themselves marked with `pub`:
-```ignore
+```
mod foo {
pub const X: u32 = 1;
}
pub use foo::X;
+
+fn main() {}
```
See the 'Use Declarations' section of the reference for more information on
Private modules cannot be publicly re-exported. This error indicates that you
attempted to `pub use` a module that was not itself public.
-Here is an example that demonstrates the error:
+Erroneous code example:
-```compile_fail
+```compile_fail,E0365
mod foo {
pub const X: u32 = 1;
}
pub use foo as foo2;
+
+fn main() {}
```
The solution to this problem is to ensure that the module that you are
re-exporting is itself marked with `pub`:
-```ignore
+```
pub mod foo {
pub const X: u32 = 1;
}
pub use foo as foo2;
+
+fn main() {}
```
See the 'Use Declarations' section of the reference for more information
E0401: r##"
Inner items do not inherit type parameters from the functions they are embedded
-in. For example, this will not compile:
+in.
-```compile_fail
+Erroneous code example:
+
+```compile_fail,E0401
fn foo<T>(x: T) {
fn bar(y: T) { // T is defined in the "outer" function
// ..
Nor will this:
-```compile_fail
+```compile_fail,E0401
fn foo<T>(x: T) {
type MaybeT = Option<T>;
// ...
Or this:
-```compile_fail
+```compile_fail,E0401
fn foo<T>(x: T) {
struct Foo {
x: T,
"##,
E0403: r##"
-Some type parameters have the same name. Example of erroneous code:
+Some type parameters have the same name.
-```compile_fail
+Erroneous code example:
+
+```compile_fail,E0403
fn foo<T, T>(s: T, u: T) {} // error: the name `T` is already used for a type
// parameter in this type parameter list
```
"##,
E0404: r##"
-You tried to implement something which was not a trait on an object. Example of
-erroneous code:
+You tried to implement something which was not a trait on an object.
-```compile_fail
+Erroneous code example:
+
+```compile_fail,E0404
struct Foo;
struct Bar;
"##,
E0405: r##"
-The code refers to a trait that is not in scope. Example of erroneous code:
+The code refers to a trait that is not in scope.
-```compile_fail
+Erroneous code example:
+
+```compile_fail,E0405
struct Foo;
impl SomeTrait for Foo {} // error: trait `SomeTrait` is not in scope
E0407: r##"
A definition of a method not in the implemented trait was given in a trait
-implementation. Example of erroneous code:
+implementation.
-```compile_fail
+Erroneous code example:
+
+```compile_fail,E0407
trait Foo {
fn a();
}
An "or" pattern was used where the variable bindings are not consistently bound
across patterns.
-Example of erroneous code:
+Erroneous code example:
-```compile_fail
+```compile_fail,E0408
match x {
Some(y) | None => { /* use y */ } // error: variable `y` from pattern #1 is
// not bound in pattern #2
An "or" pattern was used where the variable bindings are not consistently bound
across patterns.
-Example of erroneous code:
+Erroneous code example:
-```compile_fail
+```compile_fail,E0409
let x = (0, 2);
match x {
(0, ref y) | (y, 0) => { /* use y */} // error: variable `y` is bound with
"##,
E0411: r##"
-The `Self` keyword was used outside an impl or a trait. Erroneous code example:
+The `Self` keyword was used outside an impl or a trait.
-```compile_fail
+Erroneous code example:
+
+```compile_fail,E0411
<Self>::foo; // error: use of `Self` outside of an impl or trait
```
"##,
E0412: r##"
-The type name used is not in scope. Example of erroneous codes:
+The type name used is not in scope.
-```compile_fail
+Erroneous code examples:
+
+```compile_fail,E0412
impl Something {} // error: type name `Something` is not in scope
// or:
"##,
E0415: r##"
-More than one function parameter have the same name. Example of erroneous code:
+More than one function parameter have the same name.
-```compile_fail
+Erroneous code example:
+
+```compile_fail,E0415
fn foo(f: i32, f: i32) {} // error: identifier `f` is bound more than
// once in this parameter list
```
"##,
E0416: r##"
-An identifier is bound more than once in a pattern. Example of erroneous code:
+An identifier is bound more than once in a pattern.
-```compile_fail
+Erroneous code example:
+
+```compile_fail,E0416
match (1, 2) {
(x, x) => {} // error: identifier `x` is bound more than once in the
// same pattern
E0422: r##"
You are trying to use an identifier that is either undefined or not a struct.
-For instance:
-``` compile_fail
+Erroneous code example:
+
+``` compile_fail,E0422
fn main () {
let x = Foo { x: 1, y: 2 };
}
In this case, `Foo` is undefined, so it inherently isn't anything, and
definitely not a struct.
-```compile_fail
+```compile_fail,E0422
fn main () {
let foo = 1;
let x = foo { x: 1, y: 2 };
"##,
E0423: r##"
-A `struct` variant name was used like a function name. Example of erroneous
-code:
+A `struct` variant name was used like a function name.
-```compile_fail
+Erroneous code example:
+
+```compile_fail,E0423
struct Foo { a: bool};
let f = Foo();
"##,
E0424: r##"
-The `self` keyword was used in a static method. Example of erroneous code:
+The `self` keyword was used in a static method.
-```compile_fail
+Erroneous code example:
+
+```compile_fail,E0424
struct Foo;
impl Foo {
"##,
E0425: r##"
-An unresolved name was used. Example of erroneous codes:
+An unresolved name was used.
-```compile_fail
+Erroneous code examples:
+
+```compile_fail,E0425
something_that_doesnt_exist::foo;
// error: unresolved name `something_that_doesnt_exist::foo`
"##,
E0426: r##"
-An undeclared label was used. Example of erroneous code:
+An undeclared label was used.
-```compile_fail
+Erroneous code example:
+
+```compile_fail,E0426
loop {
break 'a; // error: use of undeclared label `'a`
}
"##,
E0428: r##"
-A type or module has been defined more than once. Example of erroneous
-code:
+A type or module has been defined more than once.
-```compile_fail
+Erroneous code example:
+
+```compile_fail,E0428
struct Bar;
struct Bar; // error: duplicate definition of value `Bar`
```
The `self` keyword cannot appear alone as the last segment in a `use`
declaration.
-Example of erroneous code:
+Erroneous code example:
-```compile_fail
+```compile_fail,E0429
use std::fmt::self; // error: `self` imports are only allowed within a { } list
```
"##,
E0430: r##"
-The `self` import appears more than once in the list. Erroneous code example:
+The `self` import appears more than once in the list.
-```compile_fail
+Erroneous code example:
+
+```compile_fail,E0430
use something::{self, self}; // error: `self` import can only appear once in
// the list
```
"##,
E0431: r##"
-An invalid `self` import was made. Erroneous code example:
+An invalid `self` import was made.
-```compile_fail
+Erroneous code example:
+
+```compile_fail,E0431
use {self}; // error: `self` import can only appear in an import list with a
// non-empty prefix
```
"##,
E0432: r##"
-An import was unresolved. Erroneous code example:
+An import was unresolved.
-```compile_fail
+Erroneous code example:
+
+```compile_fail,E0432
use something::Foo; // error: unresolved import `something::Foo`.
```
"##,
E0433: r##"
-Invalid import. Example of erroneous code:
+An undeclared type or module was used.
-```compile_fail
-use something_which_doesnt_exist;
-// error: unresolved import `something_which_doesnt_exist`
+Erroneous code example:
+
+```compile_fail,E0433
+let map = HashMap::new();
+// error: failed to resolve. Use of undeclared type or module `HashMap`
```
-Please verify you didn't misspell the import's name.
+Please verify you didn't misspell the type/module's name or that you didn't
+forgot to import it:
+
+
+```
+use std::collections::HashMap; // HashMap has been imported.
+let map: HashMap<u32, u32> = HashMap::new(); // So it can be used!
+```
"##,
E0434: r##"
because the variable comes from a dynamic environment. Inner functions do not
have access to their containing environment.
-Example of erroneous code:
+Erroneous code example:
-```compile_fail
+```compile_fail,E0434
fn foo() {
let y = 5;
fn bar() -> u32 {
"##,
E0435: r##"
-A non-constant value was used to initialise a constant. Example of erroneous
-code:
+A non-constant value was used to initialise a constant.
-```compile_fail
+Erroneous code example:
+
+```compile_fail,E0435
let foo = 42u32;
const FOO : u32 = foo; // error: attempt to use a non-constant value in a
// constant
an associated type whose name does not match the name of any associated type
in the trait.
-Here is an example that demonstrates the error:
+Erroneous code example:
-```compile_fail
+```compile_fail,E0437
trait Foo {}
impl Foo for i32 {
attempted to implement an associated constant whose name does not
match the name of any associated constant in the trait.
-Here is an example that demonstrates the error:
+Erroneous code example:
-```compile_fail
+```compile_fail,E0438
#![feature(associated_consts)]
trait Foo {}