Skip to content

Commit

Permalink
Rollup merge of rust-lang#49634 - lloydmeta:tests/issue-43058, r=niko…
Browse files Browse the repository at this point in the history
…matsakis

Add a test for the fix to issue rust-lang#43058

Followed the instructions laid out here rust-lang#43058 (comment)
  • Loading branch information
kennytm committed Apr 4, 2018
2 parents 391959f + f2cc501 commit 2025a08
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/test/ui/nll/issue-43058.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// 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 <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.

// must-compile-successfully

#![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);
}

0 comments on commit 2025a08

Please sign in to comment.