]> git.proxmox.com Git - rustc.git/blame - src/test/ui/borrowck/borrowck-fn-in-const-c.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / borrowck / borrowck-fn-in-const-c.rs
CommitLineData
c34b1796
AL
1// Check that we check fns appearing in constant declarations.
2// Issue #22382.
1a4d82fc 3
c34b1796
AL
4// Returning local references?
5struct DropString {
6 inner: String
1a4d82fc 7}
c34b1796 8impl 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
14const 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
22fn main() {
23}