Skip to content

Commit 2afd21d

Browse files
Rollup merge of rust-lang#47609 - ritiek:test-mutating-references, r=nikomatsakis
NLL test for mutating &mut references As mentioned in rust-lang#46361. cc @nikomatsakis?
2 parents 147f5ce + 06d123d commit 2afd21d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/test/run-pass/borrowck/borrowck-nll-iterating-and-updating.rs renamed to src/test/run-pass/nll/mutating_references.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,17 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// compile-flags: -Z borrowck=mir -Z nll
12-
13-
// This example comes from the NLL RFC.
11+
#![feature(nll)]
1412

1513
struct List<T> {
1614
value: T,
1715
next: Option<Box<List<T>>>,
1816
}
1917

20-
fn to_refs<T>(list: &mut List<T>) -> Vec<&mut T> {
21-
let mut list = list;
18+
fn to_refs<T>(mut list: &mut List<T>) -> Vec<&mut T> {
2219
let mut result = vec![];
2320
loop {
2421
result.push(&mut list.value);
@@ -31,4 +28,7 @@ fn to_refs<T>(list: &mut List<T>) -> Vec<&mut T> {
3128
}
3229

3330
fn main() {
31+
let mut list = List { value: 1, next: None };
32+
let vec = to_refs(&mut list);
33+
assert_eq!(vec![&mut 1], vec);
3434
}

0 commit comments

Comments
 (0)