Skip to content
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

Add long error explanation for E0493 #64377

Merged
merged 2 commits into from Oct 1, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -1128,6 +1128,51 @@ Remember this solution is unsafe! You will have to ensure that accesses to the
cell are synchronized.
"##,

E0493: r##"
A type with a `Drop` implementation was destructured when trying to initialize
a static item.
Erroneous code example:
```compile_fail,E0493
enum DropType {
A,
}
impl Drop for DropType {
fn drop(&mut self) {}
}
struct Foo {
field1: DropType,
}
static FOO: Foo = Foo { ..Foo { field1: DropType::A } }; // error!
```
The problem here is that if the given type or one of its fields implements the
`Drop` trait, this `Drop` implementation cannot be called during the static
type initialization which might cause a memory leak. To prevent this issue,
you need to instantiate all the static type's fields by hand.
```
enum DropType {
A,
}
impl Drop for DropType {
fn drop(&mut self) {}
}
struct Foo {
field1: DropType,
}
static FOO: Foo = Foo { field1: DropType::A }; // We initialize all fields
// by hand.
```
"##,

E0499: r##"
A variable was borrowed as mutable more than once. Erroneous code example:
@@ -2391,7 +2436,6 @@ There are some known bugs that trigger this message.
// E0299, // mismatched types between arms
// E0471, // constant evaluation error (in pattern)
// E0385, // {} in an aliasable location
E0493, // destructors cannot be evaluated at compile-time
E0521, // borrowed data escapes outside of closure
E0524, // two closures require unique access to `..` at the same time
E0526, // shuffle indices are not constant
@@ -108,5 +108,5 @@ LL | let y = { static x: Box<isize> = box 3; x };

error: aborting due to 17 previous errors

Some errors have detailed explanations: E0010, E0015, E0019, E0507.
Some errors have detailed explanations: E0010, E0015, E0019, E0493, E0507.
For more information about an error, try `rustc --explain E0010`.
@@ -24,3 +24,4 @@ LL | const Z2: () = { let mut x; x = None; x = Some(FakeNeedsDrop); };

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0493`.
@@ -328,5 +328,5 @@ LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo }

error: aborting due to 36 previous errors

Some errors have detailed explanations: E0515, E0723.
For more information about an error, try `rustc --explain E0515`.
Some errors have detailed explanations: E0493, E0515, E0723.
For more information about an error, try `rustc --explain E0493`.
@@ -14,3 +14,4 @@ LL | const X: Vec<u32> = Vec::new();

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0493`.
@@ -6,3 +6,4 @@ LL | const F : Foo = (Foo { a : 0 }, Foo { a : 1 }).1;

error: aborting due to previous error

For more information about this error, try `rustc --explain E0493`.
@@ -68,4 +68,5 @@ LL | const EARLY_DROP_C_OPTION_CONSTANT: i32 = (HELPER, 0).1;

error: aborting due to 10 previous errors

For more information about this error, try `rustc --explain E0716`.
Some errors have detailed explanations: E0493, E0716.
For more information about an error, try `rustc --explain E0493`.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.