Add error explanations for E0040, E0087, E0378, E0379, E0394.
This commit is contained in:
parent
f6074406db
commit
eb15030dc1
2 changed files with 81 additions and 6 deletions
|
|
@ -846,6 +846,40 @@ struct Foo<T: 'static> {
|
|||
foo: &'static T
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0378: r##"
|
||||
Method calls that aren't calls to inherent `const` methods are disallowed
|
||||
in statics, constants, and constant functions.
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
const BAZ: i32 = Foo(25).bar(); // error, `bar` isn't `const`
|
||||
|
||||
struct Foo(i32);
|
||||
|
||||
impl Foo {
|
||||
const fn foo(&self) -> i32 {
|
||||
self.bar() // error, `bar` isn't `const`
|
||||
}
|
||||
|
||||
fn bar(&self) -> i32 { self.0 }
|
||||
}
|
||||
```
|
||||
|
||||
For more information about `const fn`'s, see [RFC 911].
|
||||
|
||||
[RFC 911]: https://github.com/rust-lang/rfcs/pull/911
|
||||
"##,
|
||||
|
||||
E0394: r##"
|
||||
From [RFC 246]:
|
||||
|
||||
> It is illegal for a static to reference another static by value. It is
|
||||
> required that all references be borrowed.
|
||||
|
||||
[RFC 246]: https://github.com/rust-lang/rfcs/pull/246
|
||||
"##
|
||||
|
||||
}
|
||||
|
|
@ -895,9 +929,6 @@ register_diagnostics! {
|
|||
E0315, // cannot invoke closure outside of its lifetime
|
||||
E0316, // nested quantification of lifetimes
|
||||
E0370, // discriminant overflow
|
||||
E0378, // method calls limited to constant inherent methods
|
||||
E0394, // cannot refer to other statics by value, use the address-of
|
||||
// operator or a constant instead
|
||||
E0395, // pointer comparison in const-expr
|
||||
E0396 // pointer dereference in const-expr
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,6 +170,31 @@ Reference:
|
|||
http://doc.rust-lang.org/reference.html#trait-objects
|
||||
"##,
|
||||
|
||||
E0040: r##"
|
||||
It is not allowed to manually call destructors in Rust. It is also not
|
||||
necessary to do this since `drop` is called automatically whenever a value goes
|
||||
out of scope.
|
||||
|
||||
Here's an example of this error:
|
||||
|
||||
```
|
||||
struct Foo {
|
||||
x: i32,
|
||||
}
|
||||
|
||||
impl Drop for Foo {
|
||||
fn drop(&mut self) {
|
||||
println!("kaboom");
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut x = Foo { x: -7 };
|
||||
x.drop(); // error: explicit use of destructor method
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0046: r##"
|
||||
When trying to make some type implement a trait `Foo`, you must, at minimum,
|
||||
provide implementations for all of `Foo`'s required methods (meaning the
|
||||
|
|
@ -542,6 +567,21 @@ enum Empty {}
|
|||
```
|
||||
"##,
|
||||
|
||||
E0087: r##"
|
||||
Too many type parameters were supplied for a function. For example:
|
||||
|
||||
```
|
||||
fn foo<T>() {}
|
||||
|
||||
fn main() {
|
||||
foo::<f64, bool>(); // error, expected 1 parameter, found 2 parameters
|
||||
}
|
||||
```
|
||||
|
||||
The number of supplied parameters much exactly match the number of defined type
|
||||
parameters.
|
||||
"##,
|
||||
|
||||
E0089: r##"
|
||||
Not enough type parameters were supplied for a function. For example:
|
||||
|
||||
|
|
@ -1098,6 +1138,13 @@ Trait2 { ... }`) does not work if the trait is not object-safe. Please see the
|
|||
[RFC 255]: https://github.com/rust-lang/rfcs/pull/255
|
||||
"##,
|
||||
|
||||
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##"
|
||||
Default impls are only allowed for traits with no methods or associated items.
|
||||
For more information see the [opt-in builtin traits RFC](https://github.com/rust
|
||||
|
|
@ -1113,7 +1160,6 @@ register_diagnostics! {
|
|||
E0034, // multiple applicable methods in scope
|
||||
E0035, // does not take type parameters
|
||||
E0036, // incorrect number of type parameters given for this method
|
||||
E0040, // explicit use of destructor method
|
||||
E0044, // foreign items may not have type parameters
|
||||
E0045, // variadic function must have C calling convention
|
||||
E0057, // method has an incompatible type for trait
|
||||
|
|
@ -1128,7 +1174,6 @@ register_diagnostics! {
|
|||
E0077,
|
||||
E0085,
|
||||
E0086,
|
||||
E0087,
|
||||
E0088,
|
||||
E0090,
|
||||
E0091,
|
||||
|
|
@ -1235,7 +1280,6 @@ register_diagnostics! {
|
|||
// between structures
|
||||
E0377, // the trait `CoerceUnsized` may only be implemented for a coercion
|
||||
// between structures with the same definition
|
||||
E0379, // trait fns cannot be const
|
||||
E0390, // only a single inherent implementation marked with
|
||||
// `#[lang = \"{}\"]` is allowed for the `{}` primitive
|
||||
E0391, // unsupported cyclic reference between types/traits detected
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue