]>
Commit | Line | Data |
---|---|---|
c34b1796 AL |
1 | // Check that we check fns appearing in constant declarations. |
2 | // Issue #22382. | |
1a4d82fc | 3 | |
c34b1796 AL |
4 | // Returning local references? |
5 | struct DropString { | |
6 | inner: String | |
1a4d82fc | 7 | } |
c34b1796 | 8 | impl Drop for DropString { |
1a4d82fc | 9 | fn drop(&mut self) { |
c34b1796 AL |
10 | self.inner.clear(); |
11 | self.inner.push_str("dropped"); | |
1a4d82fc JJ |
12 | } |
13 | } | |
c34b1796 AL |
14 | const LOCAL_REF: fn() -> &'static str = { |
15 | fn broken() -> &'static str { | |
16 | let local = DropString { inner: format!("Some local string") }; | |
48663c56 | 17 | return &local.inner; //~ borrow may still be in use when destructor runs |
223e47cc | 18 | } |
c34b1796 AL |
19 | broken |
20 | }; | |
223e47cc | 21 | |
c34b1796 AL |
22 | fn main() { |
23 | } |