fix lifetime inference regression

epel9
Josh Stone 7 years ago
parent 4488d60fcb
commit 029b46ca94

@ -0,0 +1,51 @@
From f629c7b7db163a919cdd6a353c3318b1d66d5fad Mon Sep 17 00:00:00 2001
From: Alexandre Bury <alexandre.bury@gmail.com>
Date: Wed, 10 Jan 2018 15:29:34 +0100
Subject: [PATCH] Fix tests
Lifetime inference does not work here, we need to define the lifetimes.
But we can't do that with closures [1] so we use a function instead.
[1]: https://github.com/rust-lang/rust/issues/22340
---
src/lib.rs | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/lib.rs b/src/lib.rs
index 21ed086..31dae97 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1262,8 +1262,15 @@ mod tests {
let foo = [413, 612];
let bar = &foo;
+ // FIXME: lifetime inference fails us, and we can't easily define a lifetime for a closure
+ // (see https://github.com/rust-lang/rust/issues/22340)
+ // So we use a function to identify the lifetimes instead.
+ fn borrow<'a>(a: &'a &[i32; 2]) -> &'a i32 {
+ &a[0]
+ }
+
let o: BoxRef<&[i32; 2]> = Box::new(bar).into();
- let o: BoxRef<&[i32; 2], i32> = o.map(|a: &&[i32; 2]| &a[0]);
+ let o: BoxRef<&[i32; 2], i32> = o.map(borrow);
let o: BoxRef<Erased, i32> = o.erase_owner();
assert_eq!(*o, 413);
@@ -1693,8 +1700,15 @@ mod tests {
let mut foo = [413, 612];
let bar = &mut foo;
+ // FIXME: lifetime inference fails us, and we can't easily define a lifetime for a closure
+ // (see https://github.com/rust-lang/rust/issues/22340)
+ // So we use a function to identify the lifetimes instead.
+ fn borrow<'a>(a: &'a mut &mut [i32; 2]) -> &'a mut i32 {
+ &mut a[0]
+ }
+
let o: BoxRefMut<&mut [i32; 2]> = Box::new(bar).into();
- let o: BoxRefMut<&mut [i32; 2], i32> = o.map_mut(|a: &mut &mut [i32; 2]| &mut a[0]);
+ let o: BoxRefMut<&mut [i32; 2], i32> = o.map_mut(borrow);
let o: BoxRefMut<Erased, i32> = o.erase_owner();
assert_eq!(*o, 413);

@ -6,12 +6,15 @@
Name: rust-%{crate} Name: rust-%{crate}
Version: 0.3.3 Version: 0.3.3
Release: 3%{?dist} Release: 4%{?dist}
Summary: Library for creating references that carry their owner with them Summary: Library for creating references that carry their owner with them
License: MIT License: MIT
URL: https://crates.io/crates/owning_ref URL: https://crates.io/crates/owning_ref
Source0: https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{crate}-%{version}.crate Source0: https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{crate}-%{version}.crate
# https://github.com/Kimundi/owning-ref-rs/pull/43
# see also https://github.com/rust-lang/rust/issues/47524
Patch1: owning_ref-pr43-fix-tests.patch
ExclusiveArch: %{rust_arches} ExclusiveArch: %{rust_arches}
@ -53,6 +56,9 @@ which use %{crate} from crates.io.
%{cargo_registry}/%{crate}-%{version}/ %{cargo_registry}/%{crate}-%{version}/
%changelog %changelog
* Sat Mar 10 2018 Josh Stone <jistone@redhat.com> - 0.3.3-4
- fix lifetime inference regression
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.3-3 * Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

Loading…
Cancel
Save