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:
```
"##,
+E0524: r##"
+A variable which requires unique access is being used in more than one closure
+at the same time.
+
+Erroneous code example:
+
+```compile_fail,E0524
+fn set(x: &mut isize) {
+ *x += 4;
+}
+
+fn dragoooon(x: &mut isize) {
+ let mut c1 = || set(x);
+ let mut c2 = || set(x); // error!
+
+ c2();
+ c1();
+}
+```
+
+To solve this issue, multiple solutions are available. First, is it required
+for this variable to be used in more than one closure at a time? If it is the
+case, use reference counted types such as `Rc` (or `Arc` if it runs
+concurrently):
+
+```
+use std::rc::Rc;
+use std::cell::RefCell;
+
+fn set(x: &mut isize) {
+ *x += 4;
+}
+
+fn dragoooon(x: &mut isize) {
+ let x = Rc::new(RefCell::new(x));
+ let y = Rc::clone(&x);
+ let mut c1 = || { let mut x2 = x.borrow_mut(); set(&mut x2); };
+ let mut c2 = || { let mut x2 = y.borrow_mut(); set(&mut x2); }; // ok!
+
+ c2();
+ c1();
+}
+```
+
+If not, just run closures one at a time:
+
+```
+fn set(x: &mut isize) {
+ *x += 4;
+}
+
+fn dragoooon(x: &mut isize) {
+ { // This block isn't necessary since non-lexical lifetimes, it's just to
+ // make it more clear.
+ let mut c1 = || set(&mut *x);
+ c1();
+ } // `c1` has been dropped here so we're free to use `x` again!
+ let mut c2 = || set(&mut *x);
+ c2();
+}
+```
+"##,
+
E0595: r##"
#### Note: this error code is no longer emitted by the compiler.
// 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
E0594, // cannot assign to {}
// E0598, // lifetime of {} is too short to guarantee its contents can be...
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add `#![feature(const_fn)]` to the crate attributes to enable
-warning[E0515]: cannot return reference to temporary value
+error[E0515]: cannot return reference to temporary value
--> $DIR/min_const_fn.rs:137:63
|
LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
| ||
| |temporary value created here
| returns a reference to data owned by the current function
- |
- = warning: this error has been downgraded to a warning for backwards compatibility with previous releases
- = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
- = note: for more information, try `rustc --explain E0729`
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
- --> $DIR/min_const_fn.rs:145:41
+ --> $DIR/min_const_fn.rs:143:41
|
LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: function pointers in const fn are unstable
- --> $DIR/min_const_fn.rs:148:21
+ --> $DIR/min_const_fn.rs:146:21
|
LL | const fn no_fn_ptrs(_x: fn()) {}
| ^^
= help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: function pointers in const fn are unstable
- --> $DIR/min_const_fn.rs:150:27
+ --> $DIR/min_const_fn.rs:148:27
|
LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo }
| ^^^^
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add `#![feature(const_fn)]` to the crate attributes to enable
-error: aborting due to 36 previous errors
+error: aborting due to 37 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`.