From 3627e43dc42446aef70997e9670811a1ae6bee42 Mon Sep 17 00:00:00 2001 From: lloydmeta Date: Wed, 4 Apr 2018 10:25:37 +0900 Subject: [PATCH 1/2] Add a test for the fix to issue #43058 Followed the instructions laid out here https://github.com/rust-lang/rust/issues/43058#issuecomment-378389971 --- src/test/ui/nll/issue-43058.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/test/ui/nll/issue-43058.rs diff --git a/src/test/ui/nll/issue-43058.rs b/src/test/ui/nll/issue-43058.rs new file mode 100644 index 0000000000000..ccea5279e072f --- /dev/null +++ b/src/test/ui/nll/issue-43058.rs @@ -0,0 +1,26 @@ +#![feature(nll)] + +use std::borrow::Cow; + +#[derive(Clone, Debug)] +struct S<'a> { + name: Cow<'a, str> +} + +#[derive(Clone, Debug)] +struct T<'a> { + s: Cow<'a, [S<'a>]> +} + +fn main() { + let s1 = [S { name: Cow::Borrowed("Test1") }, S { name: Cow::Borrowed("Test2") }]; + let b1 = T { s: Cow::Borrowed(&s1) }; + let s2 = [S { name: Cow::Borrowed("Test3") }, S { name: Cow::Borrowed("Test4") }]; + let b2 = T { s: Cow::Borrowed(&s2) }; + + let mut v = Vec::new(); + v.push(b1); + v.push(b2); + + println!("{:?}", v); +} \ No newline at end of file From f2cc501f5f982b18f3ecc4717820024d58065574 Mon Sep 17 00:00:00 2001 From: lloydmeta Date: Wed, 4 Apr 2018 10:33:52 +0900 Subject: [PATCH 2/2] Formatting --- src/test/ui/nll/issue-43058.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/test/ui/nll/issue-43058.rs b/src/test/ui/nll/issue-43058.rs index ccea5279e072f..91ac7e4004260 100644 --- a/src/test/ui/nll/issue-43058.rs +++ b/src/test/ui/nll/issue-43058.rs @@ -1,3 +1,15 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// must-compile-successfully + #![feature(nll)] use std::borrow::Cow; @@ -23,4 +35,4 @@ fn main() { v.push(b2); println!("{:?}", v); -} \ No newline at end of file +}