diff options
| author | Matthew Jasper <mjjasper1@gmail.com> | 2018-04-27 20:41:30 +0100 |
|---|---|---|
| committer | Matthew Jasper <mjjasper1@gmail.com> | 2018-04-27 20:41:30 +0100 |
| commit | 902bc0fb1afb9eeb04c541787bcef37e67bfbcbe (patch) | |
| tree | e3babcc2eef702a67ddb8737ca175a02ec7aa711 /src/test/run-pass/nll | |
| parent | 3c43aa5677e17dfb9f5004522745a02e21a604a4 (diff) | |
| download | rust-902bc0fb1afb9eeb04c541787bcef37e67bfbcbe.tar.gz rust-902bc0fb1afb9eeb04c541787bcef37e67bfbcbe.zip | |
Access individual fields of tuples, closures and generators on drop.
Diffstat (limited to 'src/test/run-pass/nll')
| -rw-r--r-- | src/test/run-pass/nll/issue-48623-closure.rs | 24 | ||||
| -rw-r--r-- | src/test/run-pass/nll/issue-48623-generator.rs | 25 |
2 files changed, 49 insertions, 0 deletions
diff --git a/src/test/run-pass/nll/issue-48623-closure.rs b/src/test/run-pass/nll/issue-48623-closure.rs new file mode 100644 index 00000000000..08ff54a428e --- /dev/null +++ b/src/test/run-pass/nll/issue-48623-closure.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(nll)] + +struct WithDrop; + +impl Drop for WithDrop { + fn drop(&mut self) {} +} + +fn reborrow_from_closure(r: &mut ()) -> &mut () { + let d = WithDrop; + (move || { d; &mut *r })() +} + +fn main() {} diff --git a/src/test/run-pass/nll/issue-48623-generator.rs b/src/test/run-pass/nll/issue-48623-generator.rs new file mode 100644 index 00000000000..524837c4ba9 --- /dev/null +++ b/src/test/run-pass/nll/issue-48623-generator.rs @@ -0,0 +1,25 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(nll)] +#![feature(generators, generator_trait)] + +struct WithDrop; + +impl Drop for WithDrop { + fn drop(&mut self) {} +} + +fn reborrow_from_generator(r: &mut ()) { + let d = WithDrop; + move || { d; yield; &mut *r }; +} + +fn main() {} |
