]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-fn-in-const-c.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / borrowck-fn-in-const-c.rs
1 // Check that we check fns appearing in constant declarations.
2 // Issue #22382.
3
4 // Returning local references?
5 struct DropString {
6     inner: String
7 }
8 impl Drop for DropString {
9     fn drop(&mut self) {
10         self.inner.clear();
11         self.inner.push_str("dropped");
12     }
13 }
14 const LOCAL_REF: fn() -> &'static str = {
15     fn broken() -> &'static str {
16         let local = DropString { inner: format!("Some local string") };
17         return &local.inner; //~ borrow may still be in use when destructor runs
18     }
19     broken
20 };
21
22 fn main() {
23 }