You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a [borrow], [dereference][dereference expression], [field][field expression], or [tuple indexing expression] has an extended temporary scope, then so does its operand. If an [indexing expression] has an extended temporary scope, then the indexed expression also has an extended temporary scope.
The extended scope of the body expression of a [static][static item] or [constant item], and of the final expression of a [const block expression], is the entire program. This prevents destructors from being run.
517
535
518
536
```rust
519
-
const C: &Vec<i32> = &Vec::new();
520
-
// Usually this would be a dangling reference as the `Vec` would only
521
-
// exist inside the initializer expression of `C`, but instead the
522
-
// borrow gets lifetime-extended so it effectively has `'static` lifetime.
537
+
# #[derive(Debug)] struct PanicOnDrop;
538
+
# impl Drop for PanicOnDrop { fn drop(&mut self) { panic!() } }
0 commit comments