File tree Expand file tree Collapse file tree 3 files changed +34
-5
lines changed
librustc/middle/borrowck/gather_loans Expand file tree Collapse file tree 3 files changed +34
-5
lines changed Original file line number Diff line number Diff line change @@ -70,18 +70,19 @@ impl<'a> RestrictionsContext<'a> {
7070 mc:: cat_arg( local_id) => {
7171 // R-Variable, locally declared
7272 let lp = Rc :: new ( LpVar ( local_id) ) ;
73- SafeIf ( lp. clone ( ) , vec ! ( lp ) )
73+ SafeIf ( lp. clone ( ) , vec ! [ lp ] )
7474 }
7575
7676 mc:: cat_upvar( upvar_id, _) => {
7777 // R-Variable, captured into closure
7878 let lp = Rc :: new ( LpUpvar ( upvar_id) ) ;
79- SafeIf ( lp. clone ( ) , vec ! ( lp ) )
79+ SafeIf ( lp. clone ( ) , vec ! [ lp ] )
8080 }
8181
82- mc:: cat_copied_upvar( ..) => {
83- // FIXME(#2152) allow mutation of upvars
84- Safe
82+ mc:: cat_copied_upvar( mc:: CopiedUpvar { upvar_id, .. } ) => {
83+ // R-Variable, copied/moved into closure
84+ let lp = Rc :: new ( LpVar ( upvar_id) ) ;
85+ SafeIf ( lp. clone ( ) , vec ! [ lp] )
8586 }
8687
8788 mc:: cat_downcast( cmt_base) => {
Original file line number Diff line number Diff line change @@ -12,4 +12,8 @@ fn main() {
1212 let x = 1 i;
1313 proc ( ) { x = 2 ; } ;
1414 //~^ ERROR: cannot assign to immutable captured outer variable in a proc `x`
15+
16+ let s = std:: io:: stdin ( ) ;
17+ proc ( ) { s. lines ( ) ; } ;
18+ //~^ ERROR: cannot borrow immutable captured outer variable in a proc `s` as mutable
1519}
Original file line number Diff line number Diff line change 1+ // Copyright 2014 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+ #![ forbid( warnings) ]
12+
13+ // Pretty printing tests complain about `use std::predule::*`
14+ #![ allow( unused_imports) ]
15+
16+ // A var moved into a proc, that has a mutable loan path should
17+ // not trigger a misleading unused_mut warning.
18+
19+ pub fn main ( ) {
20+ let mut stdin = std:: io:: stdin ( ) ;
21+ spawn ( proc ( ) {
22+ let _ = stdin. lines ( ) ;
23+ } ) ;
24+ }
You can’t perform that action at this time.
0 commit comments