Auto merge of #27803 - Manishearth:rollup, r=Manishearth
- Successful merges: #27699, #27757 - Failed merges:
This commit is contained in:
commit
e9205a20a8
@ -138,6 +138,27 @@ fn main() {
|
||||
https://doc.rust-lang.org/book/ownership.html
|
||||
"##,
|
||||
|
||||
E0383: r##"
|
||||
This error occurs when an attempt is made to partially reinitialize a
|
||||
structure that is currently uninitialized.
|
||||
|
||||
For example, this can happen when a drop has taken place:
|
||||
|
||||
```
|
||||
let mut x = Foo { a: 1 };
|
||||
drop(x); // `x` is now uninitialized
|
||||
x.a = 2; // error, partial reinitialization of uninitialized structure `t`
|
||||
```
|
||||
|
||||
This error can be fixed by fully reinitializing the structure in question:
|
||||
|
||||
```
|
||||
let mut x = Foo { a: 1 };
|
||||
drop(x);
|
||||
x = Foo { a: 2 };
|
||||
```
|
||||
"##,
|
||||
|
||||
E0384: r##"
|
||||
This error occurs when an attempt is made to reassign an immutable variable.
|
||||
For example:
|
||||
@ -217,7 +238,6 @@ fn mutable() {
|
||||
}
|
||||
|
||||
register_diagnostics! {
|
||||
E0383, // partial reinitialization of uninitialized structure
|
||||
E0385, // {} in an aliasable location
|
||||
E0386, // {} in an immutable container
|
||||
E0388, // {} in a static location
|
||||
|
@ -2429,6 +2429,77 @@ fn main() {
|
||||
```
|
||||
"##,
|
||||
|
||||
E0366: r##"
|
||||
An attempt was made to implement `Drop` on a concrete specialization of a
|
||||
generic type. An example is shown below:
|
||||
|
||||
```
|
||||
struct Foo<T> {
|
||||
t: T
|
||||
}
|
||||
|
||||
impl Drop for Foo<u32> {
|
||||
fn drop(&mut self) {}
|
||||
}
|
||||
```
|
||||
|
||||
This code is not legal: it is not possible to specialize `Drop` to a subset of
|
||||
implementations of a generic type. One workaround for this is to wrap the
|
||||
generic type, as shown below:
|
||||
|
||||
```
|
||||
struct Foo<T> {
|
||||
t: T
|
||||
}
|
||||
|
||||
struct Bar {
|
||||
t: Foo<u32>
|
||||
}
|
||||
|
||||
impl Drop for Bar {
|
||||
fn drop(&mut self) {}
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0367: r##"
|
||||
An attempt was made to implement `Drop` on a specialization of a generic type.
|
||||
An example is shown below:
|
||||
|
||||
```
|
||||
trait Foo{}
|
||||
|
||||
struct MyStruct<T> {
|
||||
t: T
|
||||
}
|
||||
|
||||
impl<T: Foo> Drop for MyStruct<T> {
|
||||
fn drop(&mut self) {}
|
||||
}
|
||||
```
|
||||
|
||||
This code is not legal: it is not possible to specialize `Drop` to a subset of
|
||||
implementations of a generic type. In order for this code to work, `MyStruct`
|
||||
must also require that `T` implements `Foo`. Alternatively, another option is
|
||||
to wrap the generic type in another that specializes appropriately:
|
||||
|
||||
```
|
||||
trait Foo{}
|
||||
|
||||
struct MyStruct<T> {
|
||||
t: T
|
||||
}
|
||||
|
||||
struct MyStructWrapper<T: Foo> {
|
||||
t: MyStruct<T>
|
||||
}
|
||||
|
||||
impl <T: Foo> Drop for MyStructWrapper<T> {
|
||||
fn drop(&mut self) {}
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0368: r##"
|
||||
This error indicates that a binary assignment operator like `+=` or `^=` was
|
||||
applied to the wrong types. For example:
|
||||
@ -2659,8 +2730,6 @@ struct Foo<'a, T: 'a> {
|
||||
E0325, // implemented an associated type when another trait item expected
|
||||
E0328, // cannot implement Unsize explicitly
|
||||
E0329, // associated const depends on type parameter or Self.
|
||||
E0366, // dropck forbid specialization to concrete type or region
|
||||
E0367, // dropck forbid specialization to predicate not in struct/enum
|
||||
E0369, // binary operation `<op>` cannot be applied to types
|
||||
E0370, // discriminant overflow
|
||||
E0374, // the trait `CoerceUnsized` may only be implemented for a coercion
|
||||
|
Loading…
Reference in New Issue
Block a user