File tree 3 files changed +34
-5
lines changed
librustc/middle/borrowck/gather_loans
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> {
70
70
mc:: cat_arg( local_id) => {
71
71
// R-Variable, locally declared
72
72
let lp = Rc :: new ( LpVar ( local_id) ) ;
73
- SafeIf ( lp. clone ( ) , vec ! ( lp ) )
73
+ SafeIf ( lp. clone ( ) , vec ! [ lp ] )
74
74
}
75
75
76
76
mc:: cat_upvar( upvar_id, _) => {
77
77
// R-Variable, captured into closure
78
78
let lp = Rc :: new ( LpUpvar ( upvar_id) ) ;
79
- SafeIf ( lp. clone ( ) , vec ! ( lp ) )
79
+ SafeIf ( lp. clone ( ) , vec ! [ lp ] )
80
80
}
81
81
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] )
85
86
}
86
87
87
88
mc:: cat_downcast( cmt_base) => {
Original file line number Diff line number Diff line change @@ -12,4 +12,8 @@ fn main() {
12
12
let x = 1 i;
13
13
proc ( ) { x = 2 ; } ;
14
14
//~^ 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
15
19
}
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