Remove unused error_codes.rs files
This commit is contained in:
parent
798e389e57
commit
4963116e59
File diff suppressed because it is too large
Load Diff
@ -1,71 +0,0 @@
|
||||
syntax::register_diagnostics! {
|
||||
|
||||
E0511: r##"
|
||||
Invalid monomorphization of an intrinsic function was used. Erroneous code
|
||||
example:
|
||||
|
||||
```ignore (error-emitted-at-codegen-which-cannot-be-handled-by-compile_fail)
|
||||
#![feature(platform_intrinsics)]
|
||||
|
||||
extern "platform-intrinsic" {
|
||||
fn simd_add<T>(a: T, b: T) -> T;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
unsafe { simd_add(0, 1); }
|
||||
// error: invalid monomorphization of `simd_add` intrinsic
|
||||
}
|
||||
```
|
||||
|
||||
The generic type has to be a SIMD type. Example:
|
||||
|
||||
```
|
||||
#![feature(repr_simd)]
|
||||
#![feature(platform_intrinsics)]
|
||||
|
||||
#[repr(simd)]
|
||||
#[derive(Copy, Clone)]
|
||||
struct i32x2(i32, i32);
|
||||
|
||||
extern "platform-intrinsic" {
|
||||
fn simd_add<T>(a: T, b: T) -> T;
|
||||
}
|
||||
|
||||
unsafe { simd_add(i32x2(0, 0), i32x2(1, 2)); } // ok!
|
||||
```
|
||||
"##,
|
||||
|
||||
E0668: r##"
|
||||
Malformed inline assembly rejected by LLVM.
|
||||
|
||||
LLVM checks the validity of the constraints and the assembly string passed to
|
||||
it. This error implies that LLVM seems something wrong with the inline
|
||||
assembly call.
|
||||
|
||||
In particular, it can happen if you forgot the closing bracket of a register
|
||||
constraint (see issue #51430):
|
||||
```ignore (error-emitted-at-codegen-which-cannot-be-handled-by-compile_fail)
|
||||
#![feature(asm)]
|
||||
|
||||
fn main() {
|
||||
let rax: u64;
|
||||
unsafe {
|
||||
asm!("" :"={rax"(rax));
|
||||
println!("Accumulator is: {}", rax);
|
||||
}
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0669: r##"
|
||||
Cannot convert inline assembly operand to a single LLVM value.
|
||||
|
||||
This error usually happens when trying to pass in a value to an input inline
|
||||
assembly operand that is actually a pair of values. In particular, this can
|
||||
happen when trying to pass in a slice, for instance a `&str`. In Rust, these
|
||||
values are represented internally as a pair of values, the pointer and its
|
||||
length. When passed as an input operand, this pair of values can not be
|
||||
coerced into a register and thus we must fail with an error.
|
||||
"##,
|
||||
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
syntax::register_diagnostics! {
|
||||
;
|
||||
// E0721, // `await` keyword
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
syntax::register_diagnostics! {
|
||||
E0454: r##"
|
||||
A link name was given with an empty name. Erroneous code example:
|
||||
|
||||
```ignore (cannot-test-this-because-rustdoc-stops-compile-fail-before-codegen)
|
||||
#[link(name = "")] extern {}
|
||||
// error: `#[link(name = "")]` given with empty name
|
||||
```
|
||||
|
||||
The rust compiler cannot link to an external library if you don't give it its
|
||||
name. Example:
|
||||
|
||||
```no_run
|
||||
#[link(name = "some_lib")] extern {} // ok!
|
||||
```
|
||||
"##,
|
||||
|
||||
E0455: r##"
|
||||
Linking with `kind=framework` is only supported when targeting macOS,
|
||||
as frameworks are specific to that operating system.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```ignore (should-compile_fail-but-cannot-doctest-conditionally-without-macos)
|
||||
#[link(name = "FooCoreServices", kind = "framework")] extern {}
|
||||
// OS used to compile is Linux for example
|
||||
```
|
||||
|
||||
To solve this error you can use conditional compilation:
|
||||
|
||||
```
|
||||
#[cfg_attr(target="macos", link(name = "FooCoreServices", kind = "framework"))]
|
||||
extern {}
|
||||
```
|
||||
|
||||
See more:
|
||||
https://doc.rust-lang.org/reference/attributes.html#conditional-compilation
|
||||
"##,
|
||||
|
||||
E0458: r##"
|
||||
An unknown "kind" was specified for a link attribute. Erroneous code example:
|
||||
|
||||
```ignore (cannot-test-this-because-rustdoc-stops-compile-fail-before-codegen)
|
||||
#[link(kind = "wonderful_unicorn")] extern {}
|
||||
// error: unknown kind: `wonderful_unicorn`
|
||||
```
|
||||
|
||||
Please specify a valid "kind" value, from one of the following:
|
||||
|
||||
* static
|
||||
* dylib
|
||||
* framework
|
||||
|
||||
"##,
|
||||
|
||||
E0459: r##"
|
||||
A link was used without a name parameter. Erroneous code example:
|
||||
|
||||
```ignore (cannot-test-this-because-rustdoc-stops-compile-fail-before-codegen)
|
||||
#[link(kind = "dylib")] extern {}
|
||||
// error: `#[link(...)]` specified without `name = "foo"`
|
||||
```
|
||||
|
||||
Please add the name parameter to allow the rust compiler to find the library
|
||||
you want. Example:
|
||||
|
||||
```no_run
|
||||
#[link(kind = "dylib", name = "some_lib")] extern {} // ok!
|
||||
```
|
||||
"##,
|
||||
|
||||
E0463: r##"
|
||||
A plugin/crate was declared but cannot be found. Erroneous code example:
|
||||
|
||||
```compile_fail,E0463
|
||||
#![feature(plugin)]
|
||||
#![plugin(cookie_monster)] // error: can't find crate for `cookie_monster`
|
||||
extern crate cake_is_a_lie; // error: can't find crate for `cake_is_a_lie`
|
||||
```
|
||||
|
||||
You need to link your code to the relevant crate in order to be able to use it
|
||||
(through Cargo or the `-L` option of rustc example). Plugins are crates as
|
||||
well, and you link to them the same way.
|
||||
"##,
|
||||
;
|
||||
E0456, // plugin `..` is not available for triple `..`
|
||||
E0457, // plugin `..` only found in rlib format, but must be available...
|
||||
E0514, // metadata version mismatch
|
||||
E0460, // found possibly newer version of crate `..`
|
||||
E0461, // couldn't find crate `..` with expected target triple ..
|
||||
E0462, // found staticlib `..` instead of rlib or dylib
|
||||
E0464, // multiple matching crates for `..`
|
||||
E0465, // multiple .. candidates for `..` found
|
||||
E0519, // local crate and dependency have same (crate-name, disambiguator)
|
||||
// two dependencies have same (crate-name, disambiguator) but different SVH
|
||||
E0523,
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,174 +0,0 @@
|
||||
// Error messages for EXXXX errors.
|
||||
// Each message should start and end with a new line, and be wrapped to 80
|
||||
// characters. In vim you can `:set tw=80` and use `gq` to wrap paragraphs. Use
|
||||
// `:set tw=0` to disable.
|
||||
syntax::register_diagnostics! {
|
||||
|
||||
E0178: r##"
|
||||
In types, the `+` type operator has low precedence, so it is often necessary
|
||||
to use parentheses.
|
||||
|
||||
For example:
|
||||
|
||||
```compile_fail,E0178
|
||||
trait Foo {}
|
||||
|
||||
struct Bar<'a> {
|
||||
w: &'a Foo + Copy, // error, use &'a (Foo + Copy)
|
||||
x: &'a Foo + 'a, // error, use &'a (Foo + 'a)
|
||||
y: &'a mut Foo + 'a, // error, use &'a mut (Foo + 'a)
|
||||
z: fn() -> Foo + 'a, // error, use fn() -> (Foo + 'a)
|
||||
}
|
||||
```
|
||||
|
||||
More details can be found in [RFC 438].
|
||||
|
||||
[RFC 438]: https://github.com/rust-lang/rfcs/pull/438
|
||||
"##,
|
||||
|
||||
E0583: r##"
|
||||
A file wasn't found for an out-of-line module.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```ignore (compile_fail not working here; see Issue #43707)
|
||||
mod file_that_doesnt_exist; // error: file not found for module
|
||||
|
||||
fn main() {}
|
||||
```
|
||||
|
||||
Please be sure that a file corresponding to the module exists. If you
|
||||
want to use a module named `file_that_doesnt_exist`, you need to have a file
|
||||
named `file_that_doesnt_exist.rs` or `file_that_doesnt_exist/mod.rs` in the
|
||||
same directory.
|
||||
"##,
|
||||
|
||||
E0584: r##"
|
||||
A doc comment that is not attached to anything has been encountered.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0584
|
||||
trait Island {
|
||||
fn lost();
|
||||
|
||||
/// I'm lost!
|
||||
}
|
||||
```
|
||||
|
||||
A little reminder: a doc comment has to be placed before the item it's supposed
|
||||
to document. So if you want to document the `Island` trait, you need to put a
|
||||
doc comment before it, not inside it. Same goes for the `lost` method: the doc
|
||||
comment needs to be before it:
|
||||
|
||||
```
|
||||
/// I'm THE island!
|
||||
trait Island {
|
||||
/// I'm lost!
|
||||
fn lost();
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0585: r##"
|
||||
A documentation comment that doesn't document anything was found.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0585
|
||||
fn main() {
|
||||
// The following doc comment will fail:
|
||||
/// This is a useless doc comment!
|
||||
}
|
||||
```
|
||||
|
||||
Documentation comments need to be followed by items, including functions,
|
||||
types, modules, etc. Examples:
|
||||
|
||||
```
|
||||
/// I'm documenting the following struct:
|
||||
struct Foo;
|
||||
|
||||
/// I'm documenting the following function:
|
||||
fn foo() {}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0586: r##"
|
||||
An inclusive range was used with no end.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0586
|
||||
fn main() {
|
||||
let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
|
||||
let x = &tmp[1..=]; // error: inclusive range was used with no end
|
||||
}
|
||||
```
|
||||
|
||||
An inclusive range needs an end in order to *include* it. If you just need a
|
||||
start and no end, use a non-inclusive range (with `..`):
|
||||
|
||||
```
|
||||
fn main() {
|
||||
let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
|
||||
let x = &tmp[1..]; // ok!
|
||||
}
|
||||
```
|
||||
|
||||
Or put an end to your inclusive range:
|
||||
|
||||
```
|
||||
fn main() {
|
||||
let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
|
||||
let x = &tmp[1..=3]; // ok!
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0704: r##"
|
||||
This error indicates that a incorrect visibility restriction was specified.
|
||||
|
||||
Example of erroneous code:
|
||||
|
||||
```compile_fail,E0704
|
||||
mod foo {
|
||||
pub(foo) struct Bar {
|
||||
x: i32
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To make struct `Bar` only visible in module `foo` the `in` keyword should be
|
||||
used:
|
||||
```
|
||||
mod foo {
|
||||
pub(in crate::foo) struct Bar {
|
||||
x: i32
|
||||
}
|
||||
}
|
||||
# fn main() {}
|
||||
```
|
||||
|
||||
For more information see the Rust Reference on [Visibility].
|
||||
|
||||
[Visibility]: https://doc.rust-lang.org/reference/visibility-and-privacy.html
|
||||
"##,
|
||||
|
||||
E0743: r##"
|
||||
C-variadic has been used on a non-foreign function.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0743
|
||||
fn foo2(x: u8, ...) {} // error!
|
||||
```
|
||||
|
||||
Only foreign functions can use C-variadic (`...`). It is used to give an
|
||||
undefined number of parameters to a given function (like `printf` in C). The
|
||||
equivalent in Rust would be to use macros directly.
|
||||
"##,
|
||||
|
||||
;
|
||||
|
||||
}
|
@ -1,657 +0,0 @@
|
||||
syntax::register_diagnostics! {
|
||||
E0014: r##"
|
||||
#### Note: this error code is no longer emitted by the compiler.
|
||||
|
||||
Constants can only be initialized by a constant value or, in a future
|
||||
version of Rust, a call to a const function. This error indicates the use
|
||||
of a path (like a::b, or x) denoting something other than one of these
|
||||
allowed items.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```
|
||||
const FOO: i32 = { let x = 0; x }; // 'x' isn't a constant nor a function!
|
||||
```
|
||||
|
||||
To avoid it, you have to replace the non-constant value:
|
||||
|
||||
```
|
||||
const FOO: i32 = { const X : i32 = 0; X };
|
||||
// or even:
|
||||
const FOO2: i32 = { 0 }; // but brackets are useless here
|
||||
```
|
||||
"##,
|
||||
|
||||
E0130: r##"
|
||||
You declared a pattern as an argument in a foreign function declaration.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail
|
||||
extern {
|
||||
fn foo((a, b): (u32, u32)); // error: patterns aren't allowed in foreign
|
||||
// function declarations
|
||||
}
|
||||
```
|
||||
|
||||
Please replace the pattern argument with a regular one. Example:
|
||||
|
||||
```
|
||||
struct SomeStruct {
|
||||
a: u32,
|
||||
b: u32,
|
||||
}
|
||||
|
||||
extern {
|
||||
fn foo(s: SomeStruct); // ok!
|
||||
}
|
||||
```
|
||||
|
||||
Or:
|
||||
|
||||
```
|
||||
extern {
|
||||
fn foo(a: (u32, u32)); // ok!
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
// This shouldn't really ever trigger since the repeated value error comes first
|
||||
E0136: r##"
|
||||
A binary can only have one entry point, and by default that entry point is the
|
||||
function `main()`. If there are multiple such functions, please rename one.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0136
|
||||
fn main() {
|
||||
// ...
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
fn main() { // error!
|
||||
// ...
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0137: r##"
|
||||
More than one function was declared with the `#[main]` attribute.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0137
|
||||
#![feature(main)]
|
||||
|
||||
#[main]
|
||||
fn foo() {}
|
||||
|
||||
#[main]
|
||||
fn f() {} // error: multiple functions with a `#[main]` attribute
|
||||
```
|
||||
|
||||
This error indicates that the compiler found multiple functions with the
|
||||
`#[main]` attribute. This is an error because there must be a unique entry
|
||||
point into a Rust program. Example:
|
||||
|
||||
```
|
||||
#![feature(main)]
|
||||
|
||||
#[main]
|
||||
fn f() {} // ok!
|
||||
```
|
||||
"##,
|
||||
|
||||
E0138: r##"
|
||||
More than one function was declared with the `#[start]` attribute.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0138
|
||||
#![feature(start)]
|
||||
|
||||
#[start]
|
||||
fn foo(argc: isize, argv: *const *const u8) -> isize {}
|
||||
|
||||
#[start]
|
||||
fn f(argc: isize, argv: *const *const u8) -> isize {}
|
||||
// error: multiple 'start' functions
|
||||
```
|
||||
|
||||
This error indicates that the compiler found multiple functions with the
|
||||
`#[start]` attribute. This is an error because there must be a unique entry
|
||||
point into a Rust program. Example:
|
||||
|
||||
```
|
||||
#![feature(start)]
|
||||
|
||||
#[start]
|
||||
fn foo(argc: isize, argv: *const *const u8) -> isize { 0 } // ok!
|
||||
```
|
||||
"##,
|
||||
|
||||
E0197: r##"
|
||||
Inherent implementations (one that do not implement a trait but provide
|
||||
methods associated with a type) are always safe because they are not
|
||||
implementing an unsafe trait. Removing the `unsafe` keyword from the inherent
|
||||
implementation will resolve this error.
|
||||
|
||||
```compile_fail,E0197
|
||||
struct Foo;
|
||||
|
||||
// this will cause this error
|
||||
unsafe impl Foo { }
|
||||
// converting it to this will fix it
|
||||
impl Foo { }
|
||||
```
|
||||
"##,
|
||||
|
||||
E0198: r##"
|
||||
A negative implementation is one that excludes a type from implementing a
|
||||
particular trait. Not being able to use a trait is always a safe operation,
|
||||
so negative implementations are always safe and never need to be marked as
|
||||
unsafe.
|
||||
|
||||
```compile_fail
|
||||
#![feature(optin_builtin_traits)]
|
||||
|
||||
struct Foo;
|
||||
|
||||
// unsafe is unnecessary
|
||||
unsafe impl !Clone for Foo { }
|
||||
```
|
||||
|
||||
This will compile:
|
||||
|
||||
```ignore (ignore auto_trait future compatibility warning)
|
||||
#![feature(optin_builtin_traits)]
|
||||
|
||||
struct Foo;
|
||||
|
||||
auto trait Enterprise {}
|
||||
|
||||
impl !Enterprise for Foo { }
|
||||
```
|
||||
|
||||
Please note that negative impls are only allowed for auto traits.
|
||||
"##,
|
||||
|
||||
E0267: r##"
|
||||
This error indicates the use of a loop keyword (`break` or `continue`) inside a
|
||||
closure but outside of any loop. Erroneous code example:
|
||||
|
||||
```compile_fail,E0267
|
||||
let w = || { break; }; // error: `break` inside of a closure
|
||||
```
|
||||
|
||||
`break` and `continue` keywords can be used as normal inside closures as long as
|
||||
they are also contained within a loop. To halt the execution of a closure you
|
||||
should instead use a return statement. Example:
|
||||
|
||||
```
|
||||
let w = || {
|
||||
for _ in 0..10 {
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
w();
|
||||
```
|
||||
"##,
|
||||
|
||||
E0268: r##"
|
||||
This error indicates the use of a loop keyword (`break` or `continue`) outside
|
||||
of a loop. Without a loop to break out of or continue in, no sensible action can
|
||||
be taken. Erroneous code example:
|
||||
|
||||
```compile_fail,E0268
|
||||
fn some_func() {
|
||||
break; // error: `break` outside of a loop
|
||||
}
|
||||
```
|
||||
|
||||
Please verify that you are using `break` and `continue` only in loops. Example:
|
||||
|
||||
```
|
||||
fn some_func() {
|
||||
for _ in 0..10 {
|
||||
break; // ok!
|
||||
}
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0379: r##"
|
||||
Trait methods cannot be declared `const` by design. For more information, see
|
||||
[RFC 911].
|
||||
|
||||
[RFC 911]: https://github.com/rust-lang/rfcs/pull/911
|
||||
"##,
|
||||
|
||||
E0380: r##"
|
||||
Auto traits cannot have methods or associated items.
|
||||
For more information see the [opt-in builtin traits RFC][RFC 19].
|
||||
|
||||
[RFC 19]: https://github.com/rust-lang/rfcs/blob/master/text/0019-opt-in-builtin-traits.md
|
||||
"##,
|
||||
|
||||
E0449: r##"
|
||||
A visibility qualifier was used when it was unnecessary. Erroneous code
|
||||
examples:
|
||||
|
||||
```compile_fail,E0449
|
||||
struct Bar;
|
||||
|
||||
trait Foo {
|
||||
fn foo();
|
||||
}
|
||||
|
||||
pub impl Bar {} // error: unnecessary visibility qualifier
|
||||
|
||||
pub impl Foo for Bar { // error: unnecessary visibility qualifier
|
||||
pub fn foo() {} // error: unnecessary visibility qualifier
|
||||
}
|
||||
```
|
||||
|
||||
To fix this error, please remove the visibility qualifier when it is not
|
||||
required. Example:
|
||||
|
||||
```
|
||||
struct Bar;
|
||||
|
||||
trait Foo {
|
||||
fn foo();
|
||||
}
|
||||
|
||||
// Directly implemented methods share the visibility of the type itself,
|
||||
// so `pub` is unnecessary here
|
||||
impl Bar {}
|
||||
|
||||
// Trait methods share the visibility of the trait, so `pub` is
|
||||
// unnecessary in either case
|
||||
impl Foo for Bar {
|
||||
fn foo() {}
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0512: r##"
|
||||
Transmute with two differently sized types was attempted. Erroneous code
|
||||
example:
|
||||
|
||||
```compile_fail,E0512
|
||||
fn takes_u8(_: u8) {}
|
||||
|
||||
fn main() {
|
||||
unsafe { takes_u8(::std::mem::transmute(0u16)); }
|
||||
// error: cannot transmute between types of different sizes,
|
||||
// or dependently-sized types
|
||||
}
|
||||
```
|
||||
|
||||
Please use types with same size or use the expected type directly. Example:
|
||||
|
||||
```
|
||||
fn takes_u8(_: u8) {}
|
||||
|
||||
fn main() {
|
||||
unsafe { takes_u8(::std::mem::transmute(0i8)); } // ok!
|
||||
// or:
|
||||
unsafe { takes_u8(0u8); } // ok!
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0561: r##"
|
||||
A non-ident or non-wildcard pattern has been used as a parameter of a function
|
||||
pointer type.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0561
|
||||
type A1 = fn(mut param: u8); // error!
|
||||
type A2 = fn(¶m: u32); // error!
|
||||
```
|
||||
|
||||
When using an alias over a function type, you cannot e.g. denote a parameter as
|
||||
being mutable.
|
||||
|
||||
To fix the issue, remove patterns (`_` is allowed though). Example:
|
||||
|
||||
```
|
||||
type A1 = fn(param: u8); // ok!
|
||||
type A2 = fn(_: u32); // ok!
|
||||
```
|
||||
|
||||
You can also omit the parameter name:
|
||||
|
||||
```
|
||||
type A3 = fn(i16); // ok!
|
||||
```
|
||||
"##,
|
||||
|
||||
E0567: r##"
|
||||
Generics have been used on an auto trait.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0567
|
||||
#![feature(optin_builtin_traits)]
|
||||
|
||||
auto trait Generic<T> {} // error!
|
||||
|
||||
fn main() {}
|
||||
```
|
||||
|
||||
Since an auto trait is implemented on all existing types, the
|
||||
compiler would not be able to infer the types of the trait's generic
|
||||
parameters.
|
||||
|
||||
To fix this issue, just remove the generics:
|
||||
|
||||
```
|
||||
#![feature(optin_builtin_traits)]
|
||||
|
||||
auto trait Generic {} // ok!
|
||||
|
||||
fn main() {}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0568: r##"
|
||||
A super trait has been added to an auto trait.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0568
|
||||
#![feature(optin_builtin_traits)]
|
||||
|
||||
auto trait Bound : Copy {} // error!
|
||||
|
||||
fn main() {}
|
||||
```
|
||||
|
||||
Since an auto trait is implemented on all existing types, adding a super trait
|
||||
would filter out a lot of those types. In the current example, almost none of
|
||||
all the existing types could implement `Bound` because very few of them have the
|
||||
`Copy` trait.
|
||||
|
||||
To fix this issue, just remove the super trait:
|
||||
|
||||
```
|
||||
#![feature(optin_builtin_traits)]
|
||||
|
||||
auto trait Bound {} // ok!
|
||||
|
||||
fn main() {}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0571: r##"
|
||||
A `break` statement with an argument appeared in a non-`loop` loop.
|
||||
|
||||
Example of erroneous code:
|
||||
|
||||
```compile_fail,E0571
|
||||
# let mut i = 1;
|
||||
# fn satisfied(n: usize) -> bool { n % 23 == 0 }
|
||||
let result = while true {
|
||||
if satisfied(i) {
|
||||
break 2*i; // error: `break` with value from a `while` loop
|
||||
}
|
||||
i += 1;
|
||||
};
|
||||
```
|
||||
|
||||
The `break` statement can take an argument (which will be the value of the loop
|
||||
expression if the `break` statement is executed) in `loop` loops, but not
|
||||
`for`, `while`, or `while let` loops.
|
||||
|
||||
Make sure `break value;` statements only occur in `loop` loops:
|
||||
|
||||
```
|
||||
# let mut i = 1;
|
||||
# fn satisfied(n: usize) -> bool { n % 23 == 0 }
|
||||
let result = loop { // ok!
|
||||
if satisfied(i) {
|
||||
break 2*i;
|
||||
}
|
||||
i += 1;
|
||||
};
|
||||
```
|
||||
"##,
|
||||
|
||||
E0590: r##"
|
||||
`break` or `continue` must include a label when used in the condition of a
|
||||
`while` loop.
|
||||
|
||||
Example of erroneous code:
|
||||
|
||||
```compile_fail
|
||||
while break {}
|
||||
```
|
||||
|
||||
To fix this, add a label specifying which loop is being broken out of:
|
||||
```
|
||||
'foo: while break 'foo {}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0591: r##"
|
||||
Per [RFC 401][rfc401], if you have a function declaration `foo`:
|
||||
|
||||
```
|
||||
// For the purposes of this explanation, all of these
|
||||
// different kinds of `fn` declarations are equivalent:
|
||||
struct S;
|
||||
fn foo(x: S) { /* ... */ }
|
||||
# #[cfg(for_demonstration_only)]
|
||||
extern "C" { fn foo(x: S); }
|
||||
# #[cfg(for_demonstration_only)]
|
||||
impl S { fn foo(self) { /* ... */ } }
|
||||
```
|
||||
|
||||
the type of `foo` is **not** `fn(S)`, as one might expect.
|
||||
Rather, it is a unique, zero-sized marker type written here as `typeof(foo)`.
|
||||
However, `typeof(foo)` can be _coerced_ to a function pointer `fn(S)`,
|
||||
so you rarely notice this:
|
||||
|
||||
```
|
||||
# struct S;
|
||||
# fn foo(_: S) {}
|
||||
let x: fn(S) = foo; // OK, coerces
|
||||
```
|
||||
|
||||
The reason that this matter is that the type `fn(S)` is not specific to
|
||||
any particular function: it's a function _pointer_. So calling `x()` results
|
||||
in a virtual call, whereas `foo()` is statically dispatched, because the type
|
||||
of `foo` tells us precisely what function is being called.
|
||||
|
||||
As noted above, coercions mean that most code doesn't have to be
|
||||
concerned with this distinction. However, you can tell the difference
|
||||
when using **transmute** to convert a fn item into a fn pointer.
|
||||
|
||||
This is sometimes done as part of an FFI:
|
||||
|
||||
```compile_fail,E0591
|
||||
extern "C" fn foo(userdata: Box<i32>) {
|
||||
/* ... */
|
||||
}
|
||||
|
||||
# fn callback(_: extern "C" fn(*mut i32)) {}
|
||||
# use std::mem::transmute;
|
||||
# unsafe {
|
||||
let f: extern "C" fn(*mut i32) = transmute(foo);
|
||||
callback(f);
|
||||
# }
|
||||
```
|
||||
|
||||
Here, transmute is being used to convert the types of the fn arguments.
|
||||
This pattern is incorrect because, because the type of `foo` is a function
|
||||
**item** (`typeof(foo)`), which is zero-sized, and the target type (`fn()`)
|
||||
is a function pointer, which is not zero-sized.
|
||||
This pattern should be rewritten. There are a few possible ways to do this:
|
||||
|
||||
- change the original fn declaration to match the expected signature,
|
||||
and do the cast in the fn body (the preferred option)
|
||||
- cast the fn item fo a fn pointer before calling transmute, as shown here:
|
||||
|
||||
```
|
||||
# extern "C" fn foo(_: Box<i32>) {}
|
||||
# use std::mem::transmute;
|
||||
# unsafe {
|
||||
let f: extern "C" fn(*mut i32) = transmute(foo as extern "C" fn(_));
|
||||
let f: extern "C" fn(*mut i32) = transmute(foo as usize); // works too
|
||||
# }
|
||||
```
|
||||
|
||||
The same applies to transmutes to `*mut fn()`, which were observed in practice.
|
||||
Note though that use of this type is generally incorrect.
|
||||
The intention is typically to describe a function pointer, but just `fn()`
|
||||
alone suffices for that. `*mut fn()` is a pointer to a fn pointer.
|
||||
(Since these values are typically just passed to C code, however, this rarely
|
||||
makes a difference in practice.)
|
||||
|
||||
[rfc401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md
|
||||
"##,
|
||||
|
||||
E0601: r##"
|
||||
No `main` function was found in a binary crate. To fix this error, add a
|
||||
`main` function. For example:
|
||||
|
||||
```
|
||||
fn main() {
|
||||
// Your program will start here.
|
||||
println!("Hello world!");
|
||||
}
|
||||
```
|
||||
|
||||
If you don't know the basics of Rust, you can go look to the Rust Book to get
|
||||
started: https://doc.rust-lang.org/book/
|
||||
"##,
|
||||
|
||||
E0642: r##"
|
||||
Trait methods currently cannot take patterns as arguments.
|
||||
|
||||
Example of erroneous code:
|
||||
|
||||
```compile_fail,E0642
|
||||
trait Foo {
|
||||
fn foo((x, y): (i32, i32)); // error: patterns aren't allowed
|
||||
// in trait methods
|
||||
}
|
||||
```
|
||||
|
||||
You can instead use a single name for the argument:
|
||||
|
||||
```
|
||||
trait Foo {
|
||||
fn foo(x_and_y: (i32, i32)); // ok!
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0666: r##"
|
||||
`impl Trait` types cannot appear nested in the
|
||||
generic arguments of other `impl Trait` types.
|
||||
|
||||
Example of erroneous code:
|
||||
|
||||
```compile_fail,E0666
|
||||
trait MyGenericTrait<T> {}
|
||||
trait MyInnerTrait {}
|
||||
|
||||
fn foo(bar: impl MyGenericTrait<impl MyInnerTrait>) {}
|
||||
```
|
||||
|
||||
Type parameters for `impl Trait` types must be
|
||||
explicitly defined as named generic parameters:
|
||||
|
||||
```
|
||||
trait MyGenericTrait<T> {}
|
||||
trait MyInnerTrait {}
|
||||
|
||||
fn foo<T: MyInnerTrait>(bar: impl MyGenericTrait<T>) {}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0695: r##"
|
||||
A `break` statement without a label appeared inside a labeled block.
|
||||
|
||||
Example of erroneous code:
|
||||
|
||||
```compile_fail,E0695
|
||||
# #![feature(label_break_value)]
|
||||
loop {
|
||||
'a: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Make sure to always label the `break`:
|
||||
|
||||
```
|
||||
# #![feature(label_break_value)]
|
||||
'l: loop {
|
||||
'a: {
|
||||
break 'l;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Or if you want to `break` the labeled block:
|
||||
|
||||
```
|
||||
# #![feature(label_break_value)]
|
||||
loop {
|
||||
'a: {
|
||||
break 'a;
|
||||
}
|
||||
break;
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0670: r##"
|
||||
Rust 2015 does not permit the use of `async fn`.
|
||||
|
||||
Example of erroneous code:
|
||||
|
||||
```compile_fail,E0670
|
||||
async fn foo() {}
|
||||
```
|
||||
|
||||
Switch to the Rust 2018 edition to use `async fn`.
|
||||
"##,
|
||||
|
||||
E0744: r##"
|
||||
Control-flow expressions are not allowed inside a const context.
|
||||
|
||||
At the moment, `if` and `match`, as well as the looping constructs `for`,
|
||||
`while`, and `loop`, are forbidden inside a `const`, `static`, or `const fn`.
|
||||
|
||||
```compile_fail,E0744
|
||||
const _: i32 = {
|
||||
let mut x = 0;
|
||||
loop {
|
||||
x += 1;
|
||||
if x == 4 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
x
|
||||
};
|
||||
```
|
||||
|
||||
"##,
|
||||
|
||||
;
|
||||
E0226, // only a single explicit lifetime bound is permitted
|
||||
E0472, // asm! is unsupported on this target
|
||||
E0667, // `impl Trait` in projections
|
||||
E0696, // `continue` pointing to a labeled block
|
||||
E0706, // `async fn` in trait
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
syntax::register_diagnostics! {
|
||||
;
|
||||
E0498, // malformed plugin attribute
|
||||
}
|
@ -1,169 +0,0 @@
|
||||
syntax::register_diagnostics! {
|
||||
|
||||
E0445: r##"
|
||||
A private trait was used on a public type parameter bound.
|
||||
|
||||
Erroneous code examples:
|
||||
|
||||
```compile_fail,E0445
|
||||
#![deny(private_in_public)]
|
||||
|
||||
trait Foo {
|
||||
fn dummy(&self) { }
|
||||
}
|
||||
|
||||
pub trait Bar : Foo {} // error: private trait in public interface
|
||||
pub struct Bar2<T: Foo>(pub T); // same error
|
||||
pub fn foo<T: Foo> (t: T) {} // same error
|
||||
```
|
||||
|
||||
To solve this error, please ensure that the trait is also public. The trait
|
||||
can be made inaccessible if necessary by placing it into a private inner
|
||||
module, but it still has to be marked with `pub`. Example:
|
||||
|
||||
```
|
||||
pub trait Foo { // we set the Foo trait public
|
||||
fn dummy(&self) { }
|
||||
}
|
||||
|
||||
pub trait Bar : Foo {} // ok!
|
||||
pub struct Bar2<T: Foo>(pub T); // ok!
|
||||
pub fn foo<T: Foo> (t: T) {} // ok!
|
||||
```
|
||||
"##,
|
||||
|
||||
E0446: r##"
|
||||
A private type was used in a public type signature.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0446
|
||||
#![deny(private_in_public)]
|
||||
|
||||
mod Foo {
|
||||
struct Bar(u32);
|
||||
|
||||
pub fn bar() -> Bar { // error: private type in public interface
|
||||
Bar(0)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To solve this error, please ensure that the type is also public. The type
|
||||
can be made inaccessible if necessary by placing it into a private inner
|
||||
module, but it still has to be marked with `pub`.
|
||||
Example:
|
||||
|
||||
```
|
||||
mod Foo {
|
||||
pub struct Bar(u32); // we set the Bar type public
|
||||
|
||||
pub fn bar() -> Bar { // ok!
|
||||
Bar(0)
|
||||
}
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0447: r##"
|
||||
#### Note: this error code is no longer emitted by the compiler.
|
||||
|
||||
The `pub` keyword was used inside a function.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```
|
||||
fn foo() {
|
||||
pub struct Bar; // error: visibility has no effect inside functions
|
||||
}
|
||||
```
|
||||
|
||||
Since we cannot access items defined inside a function, the visibility of its
|
||||
items does not impact outer code. So using the `pub` keyword in this context
|
||||
is invalid.
|
||||
"##,
|
||||
|
||||
E0448: r##"
|
||||
#### Note: this error code is no longer emitted by the compiler.
|
||||
|
||||
The `pub` keyword was used inside a public enum.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail
|
||||
pub enum Foo {
|
||||
pub Bar, // error: unnecessary `pub` visibility
|
||||
}
|
||||
```
|
||||
|
||||
Since the enum is already public, adding `pub` on one its elements is
|
||||
unnecessary. Example:
|
||||
|
||||
```compile_fail
|
||||
enum Foo {
|
||||
pub Bar, // not ok!
|
||||
}
|
||||
```
|
||||
|
||||
This is the correct syntax:
|
||||
|
||||
```
|
||||
pub enum Foo {
|
||||
Bar, // ok!
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0451: r##"
|
||||
A struct constructor with private fields was invoked.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0451
|
||||
mod Bar {
|
||||
pub struct Foo {
|
||||
pub a: isize,
|
||||
b: isize,
|
||||
}
|
||||
}
|
||||
|
||||
let f = Bar::Foo{ a: 0, b: 0 }; // error: field `b` of struct `Bar::Foo`
|
||||
// is private
|
||||
```
|
||||
|
||||
To fix this error, please ensure that all the fields of the struct are public,
|
||||
or implement a function for easy instantiation. Examples:
|
||||
|
||||
```
|
||||
mod Bar {
|
||||
pub struct Foo {
|
||||
pub a: isize,
|
||||
pub b: isize, // we set `b` field public
|
||||
}
|
||||
}
|
||||
|
||||
let f = Bar::Foo{ a: 0, b: 0 }; // ok!
|
||||
```
|
||||
|
||||
Or:
|
||||
|
||||
```
|
||||
mod Bar {
|
||||
pub struct Foo {
|
||||
pub a: isize,
|
||||
b: isize, // still private
|
||||
}
|
||||
|
||||
impl Foo {
|
||||
pub fn new() -> Foo { // we create a method to instantiate `Foo`
|
||||
Foo { a: 0, b: 0 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let f = Bar::Foo::new(); // ok!
|
||||
```
|
||||
"##,
|
||||
|
||||
// E0450, moved into resolve
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,379 +0,0 @@
|
||||
// Error messages for EXXXX errors.
|
||||
// Each message should start and end with a new line, and be wrapped to 80
|
||||
// characters. In vim you can `:set tw=80` and use `gq` to wrap paragraphs. Use
|
||||
// `:set tw=0` to disable.
|
||||
register_diagnostics! {
|
||||
|
||||
E0536: r##"
|
||||
The `not` cfg-predicate was malformed.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0536
|
||||
#[cfg(not())] // error: expected 1 cfg-pattern
|
||||
pub fn something() {}
|
||||
|
||||
pub fn main() {}
|
||||
```
|
||||
|
||||
The `not` predicate expects one cfg-pattern. Example:
|
||||
|
||||
```
|
||||
#[cfg(not(target_os = "linux"))] // ok!
|
||||
pub fn something() {}
|
||||
|
||||
pub fn main() {}
|
||||
```
|
||||
|
||||
For more information about the cfg attribute, read:
|
||||
https://doc.rust-lang.org/reference.html#conditional-compilation
|
||||
"##,
|
||||
|
||||
E0537: r##"
|
||||
An unknown predicate was used inside the `cfg` attribute.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0537
|
||||
#[cfg(unknown())] // error: invalid predicate `unknown`
|
||||
pub fn something() {}
|
||||
|
||||
pub fn main() {}
|
||||
```
|
||||
|
||||
The `cfg` attribute supports only three kinds of predicates:
|
||||
|
||||
* any
|
||||
* all
|
||||
* not
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
#[cfg(not(target_os = "linux"))] // ok!
|
||||
pub fn something() {}
|
||||
|
||||
pub fn main() {}
|
||||
```
|
||||
|
||||
For more information about the cfg attribute, read:
|
||||
https://doc.rust-lang.org/reference.html#conditional-compilation
|
||||
"##,
|
||||
|
||||
E0538: r##"
|
||||
Attribute contains same meta item more than once.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0538
|
||||
#[deprecated(
|
||||
since="1.0.0",
|
||||
note="First deprecation note.",
|
||||
note="Second deprecation note." // error: multiple same meta item
|
||||
)]
|
||||
fn deprecated_function() {}
|
||||
```
|
||||
|
||||
Meta items are the key-value pairs inside of an attribute. Each key may only be
|
||||
used once in each attribute.
|
||||
|
||||
To fix the problem, remove all but one of the meta items with the same key.
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
#[deprecated(
|
||||
since="1.0.0",
|
||||
note="First deprecation note."
|
||||
)]
|
||||
fn deprecated_function() {}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0541: r##"
|
||||
An unknown meta item was used.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0541
|
||||
#[deprecated(
|
||||
since="1.0.0",
|
||||
// error: unknown meta item
|
||||
reason="Example invalid meta item. Should be 'note'")
|
||||
]
|
||||
fn deprecated_function() {}
|
||||
```
|
||||
|
||||
Meta items are the key-value pairs inside of an attribute. The keys provided
|
||||
must be one of the valid keys for the specified attribute.
|
||||
|
||||
To fix the problem, either remove the unknown meta item, or rename it if you
|
||||
provided the wrong name.
|
||||
|
||||
In the erroneous code example above, the wrong name was provided, so changing
|
||||
to a correct one it will fix the error. Example:
|
||||
|
||||
```
|
||||
#[deprecated(
|
||||
since="1.0.0",
|
||||
note="This is a valid meta item for the deprecated attribute."
|
||||
)]
|
||||
fn deprecated_function() {}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0550: r##"
|
||||
More than one `deprecated` attribute has been put on an item.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0550
|
||||
#[deprecated(note = "because why not?")]
|
||||
#[deprecated(note = "right?")] // error!
|
||||
fn the_banished() {}
|
||||
```
|
||||
|
||||
The `deprecated` attribute can only be present **once** on an item.
|
||||
|
||||
```
|
||||
#[deprecated(note = "because why not, right?")]
|
||||
fn the_banished() {} // ok!
|
||||
```
|
||||
"##,
|
||||
|
||||
E0551: r##"
|
||||
An invalid meta-item was used inside an attribute.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0551
|
||||
#[deprecated(note)] // error!
|
||||
fn i_am_deprecated() {}
|
||||
```
|
||||
|
||||
Meta items are the key-value pairs inside of an attribute. To fix this issue,
|
||||
you need to give a value to the `note` key. Example:
|
||||
|
||||
```
|
||||
#[deprecated(note = "because")] // ok!
|
||||
fn i_am_deprecated() {}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0552: r##"
|
||||
A unrecognized representation attribute was used.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0552
|
||||
#[repr(D)] // error: unrecognized representation hint
|
||||
struct MyStruct {
|
||||
my_field: usize
|
||||
}
|
||||
```
|
||||
|
||||
You can use a `repr` attribute to tell the compiler how you want a struct or
|
||||
enum to be laid out in memory.
|
||||
|
||||
Make sure you're using one of the supported options:
|
||||
|
||||
```
|
||||
#[repr(C)] // ok!
|
||||
struct MyStruct {
|
||||
my_field: usize
|
||||
}
|
||||
```
|
||||
|
||||
For more information about specifying representations, see the ["Alternative
|
||||
Representations" section] of the Rustonomicon.
|
||||
|
||||
["Alternative Representations" section]: https://doc.rust-lang.org/nomicon/other-reprs.html
|
||||
"##,
|
||||
|
||||
E0554: r##"
|
||||
Feature attributes are only allowed on the nightly release channel. Stable or
|
||||
beta compilers will not comply.
|
||||
|
||||
Example of erroneous code (on a stable compiler):
|
||||
|
||||
```ignore (depends on release channel)
|
||||
#![feature(non_ascii_idents)] // error: `#![feature]` may not be used on the
|
||||
// stable release channel
|
||||
```
|
||||
|
||||
If you need the feature, make sure to use a nightly release of the compiler
|
||||
(but be warned that the feature may be removed or altered in the future).
|
||||
"##,
|
||||
|
||||
E0556: r##"
|
||||
The `feature` attribute was badly formed.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0556
|
||||
#![feature(foo_bar_baz, foo(bar), foo = "baz", foo)] // error!
|
||||
#![feature] // error!
|
||||
#![feature = "foo"] // error!
|
||||
```
|
||||
|
||||
The `feature` attribute only accept a "feature flag" and can only be used on
|
||||
nightly. Example:
|
||||
|
||||
```ignore (only works in nightly)
|
||||
#![feature(flag)]
|
||||
```
|
||||
"##,
|
||||
|
||||
E0557: r##"
|
||||
A feature attribute named a feature that has been removed.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0557
|
||||
#![feature(managed_boxes)] // error: feature has been removed
|
||||
```
|
||||
|
||||
Delete the offending feature attribute.
|
||||
"##,
|
||||
|
||||
E0565: r##"
|
||||
A literal was used in a built-in attribute that doesn't support literals.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```ignore (compile_fail not working here; see Issue #43707)
|
||||
#[inline("always")] // error: unsupported literal
|
||||
pub fn something() {}
|
||||
```
|
||||
|
||||
Literals in attributes are new and largely unsupported in built-in attributes.
|
||||
Work to support literals where appropriate is ongoing. Try using an unquoted
|
||||
name instead:
|
||||
|
||||
```
|
||||
#[inline(always)]
|
||||
pub fn something() {}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0589: r##"
|
||||
The value of `N` that was specified for `repr(align(N))` was not a power
|
||||
of two, or was greater than 2^29.
|
||||
|
||||
```compile_fail,E0589
|
||||
#[repr(align(15))] // error: invalid `repr(align)` attribute: not a power of two
|
||||
enum Foo {
|
||||
Bar(u64),
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0658: r##"
|
||||
An unstable feature was used.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E658
|
||||
#[repr(u128)] // error: use of unstable library feature 'repr128'
|
||||
enum Foo {
|
||||
Bar(u64),
|
||||
}
|
||||
```
|
||||
|
||||
If you're using a stable or a beta version of rustc, you won't be able to use
|
||||
any unstable features. In order to do so, please switch to a nightly version of
|
||||
rustc (by using rustup).
|
||||
|
||||
If you're using a nightly version of rustc, just add the corresponding feature
|
||||
to be able to use it:
|
||||
|
||||
```
|
||||
#![feature(repr128)]
|
||||
|
||||
#[repr(u128)] // ok!
|
||||
enum Foo {
|
||||
Bar(u64),
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0633: r##"
|
||||
The `unwind` attribute was malformed.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```ignore (compile_fail not working here; see Issue #43707)
|
||||
#[unwind()] // error: expected one argument
|
||||
pub extern fn something() {}
|
||||
|
||||
fn main() {}
|
||||
```
|
||||
|
||||
The `#[unwind]` attribute should be used as follows:
|
||||
|
||||
- `#[unwind(aborts)]` -- specifies that if a non-Rust ABI function
|
||||
should abort the process if it attempts to unwind. This is the safer
|
||||
and preferred option.
|
||||
|
||||
- `#[unwind(allowed)]` -- specifies that a non-Rust ABI function
|
||||
should be allowed to unwind. This can easily result in Undefined
|
||||
Behavior (UB), so be careful.
|
||||
|
||||
NB. The default behavior here is "allowed", but this is unspecified
|
||||
and likely to change in the future.
|
||||
|
||||
"##,
|
||||
|
||||
E0705: r##"
|
||||
A `#![feature]` attribute was declared for a feature that is stable in
|
||||
the current edition, but not in all editions.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```ignore (limited to a warning during 2018 edition development)
|
||||
#![feature(rust_2018_preview)]
|
||||
#![feature(test_2018_feature)] // error: the feature
|
||||
// `test_2018_feature` is
|
||||
// included in the Rust 2018 edition
|
||||
```
|
||||
"##,
|
||||
|
||||
E0725: r##"
|
||||
A feature attribute named a feature that was disallowed in the compiler
|
||||
command line flags.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```ignore (can't specify compiler flags from doctests)
|
||||
#![feature(never_type)] // error: the feature `never_type` is not in
|
||||
// the list of allowed features
|
||||
```
|
||||
|
||||
Delete the offending feature attribute, or add it to the list of allowed
|
||||
features in the `-Z allow_features` flag.
|
||||
"##,
|
||||
|
||||
;
|
||||
|
||||
E0539, // incorrect meta item
|
||||
E0540, // multiple rustc_deprecated attributes
|
||||
E0542, // missing 'since'
|
||||
E0543, // missing 'reason'
|
||||
E0544, // multiple stability levels
|
||||
E0545, // incorrect 'issue'
|
||||
E0546, // missing 'feature'
|
||||
E0547, // missing 'issue'
|
||||
// E0548, // replaced with a generic attribute input check
|
||||
// rustc_deprecated attribute must be paired with either stable or unstable
|
||||
// attribute
|
||||
E0549,
|
||||
E0553, // multiple rustc_const_unstable attributes
|
||||
// E0555, // replaced with a generic attribute input check
|
||||
E0629, // missing 'feature' (rustc_const_unstable)
|
||||
// rustc_const_unstable attribute must be paired with stable/unstable
|
||||
// attribute
|
||||
E0630,
|
||||
E0693, // incorrect `repr(align)` attribute format
|
||||
// E0694, // an unknown tool name found in scoped attributes
|
||||
E0717, // rustc_promotable without stability attribute
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
// Error messages for EXXXX errors.
|
||||
// Each message should start and end with a new line, and be wrapped to 80
|
||||
// characters. In vim you can `:set tw=80` and use `gq` to wrap paragraphs. Use
|
||||
// `:set tw=0` to disable.
|
||||
syntax::register_diagnostics! {
|
||||
E0660: r##"
|
||||
The argument to the `asm` macro is not well-formed.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0660
|
||||
asm!("nop" "nop");
|
||||
```
|
||||
|
||||
Considering that this would be a long explanation, we instead recommend you to
|
||||
take a look at the unstable book:
|
||||
https://doc.rust-lang.org/unstable-book/language-features/asm.html
|
||||
"##,
|
||||
|
||||
E0661: r##"
|
||||
An invalid syntax was passed to the second argument of an `asm` macro line.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0661
|
||||
let a;
|
||||
asm!("nop" : "r"(a));
|
||||
```
|
||||
|
||||
Considering that this would be a long explanation, we instead recommend you to
|
||||
take a look at the unstable book:
|
||||
https://doc.rust-lang.org/unstable-book/language-features/asm.html
|
||||
"##,
|
||||
|
||||
E0662: r##"
|
||||
An invalid input operand constraint was passed to the `asm` macro (third line).
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0662
|
||||
asm!("xor %eax, %eax"
|
||||
:
|
||||
: "=test"("a")
|
||||
);
|
||||
```
|
||||
|
||||
Considering that this would be a long explanation, we instead recommend you to
|
||||
take a look at the unstable book:
|
||||
https://doc.rust-lang.org/unstable-book/language-features/asm.html
|
||||
"##,
|
||||
|
||||
E0663: r##"
|
||||
An invalid input operand constraint was passed to the `asm` macro (third line).
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0663
|
||||
asm!("xor %eax, %eax"
|
||||
:
|
||||
: "+test"("a")
|
||||
);
|
||||
```
|
||||
|
||||
Considering that this would be a long explanation, we instead recommend you to
|
||||
take a look at the unstable book:
|
||||
https://doc.rust-lang.org/unstable-book/language-features/asm.html
|
||||
"##,
|
||||
|
||||
E0664: r##"
|
||||
A clobber was surrounded by braces in the `asm` macro.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0664
|
||||
asm!("mov $$0x200, %eax"
|
||||
:
|
||||
:
|
||||
: "{eax}"
|
||||
);
|
||||
```
|
||||
|
||||
Considering that this would be a long explanation, we instead recommend you to
|
||||
take a look at the unstable book:
|
||||
https://doc.rust-lang.org/unstable-book/language-features/asm.html
|
||||
"##,
|
||||
|
||||
E0665: r##"
|
||||
The `Default` trait was derived on an enum.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0665
|
||||
#[derive(Default)]
|
||||
enum Food {
|
||||
Sweet,
|
||||
Salty,
|
||||
}
|
||||
```
|
||||
|
||||
The `Default` cannot be derived on an enum for the simple reason that the
|
||||
compiler doesn't know which value to pick by default whereas it can for a
|
||||
struct as long as all its fields implement the `Default` trait as well.
|
||||
|
||||
If you still want to implement `Default` on your enum, you'll have to do it "by
|
||||
hand":
|
||||
|
||||
```
|
||||
enum Food {
|
||||
Sweet,
|
||||
Salty,
|
||||
}
|
||||
|
||||
impl Default for Food {
|
||||
fn default() -> Food {
|
||||
Food::Sweet
|
||||
}
|
||||
}
|
||||
```
|
||||
"##,
|
||||
}
|
Loading…
Reference in New Issue
Block a user