Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dcf3db4
commit d6772cb
Showing
3 changed files
with
93 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/test/compile-fail/nll/where_clauses_in_repeat_rvalue.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// 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. | ||
|
||
// compile-flags: -Z borrowck=mir -Z nll | ||
|
||
#![allow(warnings)] | ||
|
||
struct Foo<T> { | ||
t: T, | ||
} | ||
|
||
impl<T: 'static + Copy> Copy for Foo<T> {} | ||
impl<T: 'static + Copy> Clone for Foo<T> { | ||
fn clone(&self) -> Self { | ||
*self | ||
} | ||
} | ||
|
||
fn main() { | ||
let mut x = 22; | ||
|
||
{ | ||
let p = &x; //~ ERROR borrowed value does not live long enough | ||
let w = Foo { t: p }; | ||
|
||
let v = [w; 22]; | ||
} | ||
|
||
x += 1; | ||
//~^ ERROR cannot assign to `x` because it is borrowed [E0506] | ||
} | ||
//~^ ERROR borrowed value does not live long enough [E0597] |