Skip to content

Commit 2025a08

Browse files
committed
Rollup merge of #49634 - lloydmeta:tests/issue-43058, r=nikomatsakis
Add a test for the fix to issue #43058 Followed the instructions laid out here #43058 (comment)
2 parents 391959f + f2cc501 commit 2025a08

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/test/ui/nll/issue-43058.rs

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// must-compile-successfully
12+
13+
#![feature(nll)]
14+
15+
use std::borrow::Cow;
16+
17+
#[derive(Clone, Debug)]
18+
struct S<'a> {
19+
name: Cow<'a, str>
20+
}
21+
22+
#[derive(Clone, Debug)]
23+
struct T<'a> {
24+
s: Cow<'a, [S<'a>]>
25+
}
26+
27+
fn main() {
28+
let s1 = [S { name: Cow::Borrowed("Test1") }, S { name: Cow::Borrowed("Test2") }];
29+
let b1 = T { s: Cow::Borrowed(&s1) };
30+
let s2 = [S { name: Cow::Borrowed("Test3") }, S { name: Cow::Borrowed("Test4") }];
31+
let b2 = T { s: Cow::Borrowed(&s2) };
32+
33+
let mut v = Vec::new();
34+
v.push(b1);
35+
v.push(b2);
36+
37+
println!("{:?}", v);
38+
}

0 commit comments

Comments
 (0)