diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
commit | 64d98f8ee037282c35007b64c2649055c56af1db (patch) | |
tree | 5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /src/test/ui/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs | |
parent | Adding debian version 1.67.1+dfsg1-1. (diff) | |
download | rustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs')
-rw-r--r-- | src/test/ui/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/src/test/ui/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs b/src/test/ui/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs deleted file mode 100644 index b1bdb813a..000000000 --- a/src/test/ui/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs +++ /dev/null @@ -1,57 +0,0 @@ -// run-pass -#![allow(dead_code)] -// Test that this fairly specialized, but also reasonable, pattern -// typechecks. The pattern involves regions bound in closures that -// wind up related to inference variables. -// -// NB. Changes to the region implementations have broken this pattern -// a few times, but it happens to be used in the compiler so those -// changes were caught. However, those uses in the compiler could -// easily get changed or refactored away in the future. - -struct Ctxt<'tcx> { - x: &'tcx Vec<isize> -} - -struct Foo<'a,'tcx:'a> { - cx: &'a Ctxt<'tcx>, -} - -impl<'a,'tcx> Foo<'a,'tcx> { - fn bother(&mut self) -> isize { - self.elaborate_bounds(Box::new(|this| { - // (*) Here: type of `this` is `&'f0 Foo<&'f1, '_2>`, - // where `'f0` and `'f1` are fresh, free regions that - // result from the bound regions on the closure, and `'2` - // is a region inference variable created by the call. Due - // to the constraints on the type, we find that `'_2 : 'f1 - // + 'f2` must hold (and can be assumed by the callee). - // Region inference has to do some clever stuff to avoid - // inferring `'_2` to be `'static` in this case, because - // it is created outside the closure but then related to - // regions bound by the closure itself. See the - // `region_constraints.rs` file (and the `givens` field, in - // particular) for more details. - this.foo() - })) - } - - fn foo(&mut self) -> isize { - 22 - } - - fn elaborate_bounds( - &mut self, - mut mk_cand: Box<dyn for<'b> FnMut(&mut Foo<'b, 'tcx>) -> isize>) - -> isize - { - mk_cand(self) - } -} - -fn main() { - let v = vec![]; - let cx = Ctxt { x: &v }; - let mut foo = Foo { cx: &cx }; - assert_eq!(foo.bother(), 22); // just so the code is not dead, basically -} |