File tree Expand file tree Collapse file tree 16 files changed +340
-0
lines changed Expand file tree Collapse file tree 16 files changed +340
-0
lines changed 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
+ #[ unsafe_no_drop_flag]
12
+ pub struct ZeroLengthThingWithDestructor ;
13
+ impl Drop for ZeroLengthThingWithDestructor {
14
+ fn drop ( & mut self ) { }
15
+ }
16
+ impl ZeroLengthThingWithDestructor {
17
+ pub fn new ( ) -> ZeroLengthThingWithDestructor {
18
+ ZeroLengthThingWithDestructor
19
+ }
20
+ }
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
+ pub struct Closed01 < F > ( F ) ;
12
+
13
+ pub trait Bar { fn new ( ) -> Self ; }
14
+
15
+ impl < T : Bar > Bar for Closed01 < T > {
16
+ fn new ( ) -> Closed01 < T > { Closed01 ( Bar :: new ( ) ) }
17
+ }
18
+ impl Bar for f32 { fn new ( ) -> f32 { 1.0 } }
19
+
20
+ pub fn random < T : Bar > ( ) -> T { Bar :: new ( ) }
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
+ pub struct A < ' a > ( & ' a int ) ;
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
+ pub struct V2 < T > ( T , T ) ;
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
+ fn main ( ) {
12
+ let mut a = "a" ;
13
+ a += { "b" } ;
14
+ //~^ ERROR: binary assignment operation `+=` cannot be applied
15
+ }
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
+ struct Foo {
12
+ x : int
13
+ }
14
+
15
+ impl Drop for Foo {
16
+ fn drop ( & mut self ) {
17
+ println ! ( "drop {}" , self . x) ;
18
+ }
19
+ }
20
+
21
+ fn main ( ) {
22
+ let mut ptr = ~Foo { x : 0 } ;
23
+ let test = |foo : & Foo | {
24
+ println ! ( "access {}" , foo. x) ;
25
+ ptr = ~Foo { x : ptr. x + 1 } ;
26
+ println ! ( "access {}" , foo. x) ;
27
+ } ;
28
+ test ( ptr) ;
29
+ //~^ ERROR: cannot borrow `*ptr` as immutable
30
+ }
31
+
Original file line number Diff line number Diff line change
1
+ // Copyright 2012-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
+ use std:: vec_ng:: Vec ;
12
+
13
+ fn main ( ) {
14
+ let mut v = vec ! ( 1 ) ;
15
+ let f = || v. push ( 2 ) ;
16
+ let _w = v; //~ ERROR: cannot move out of `v`
17
+
18
+ f ( ) ;
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
+ fn main ( ) {
12
+ let r = {
13
+ let x = ~42 ;
14
+ let f = proc ( ) & x; //~ ERROR: borrowed value does not live long enough
15
+ f ( )
16
+ } ;
17
+
18
+ drop ( r) ;
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
+ struct Foo < T > {
12
+ x : T ,
13
+ }
14
+ impl < T > Foo < T > {
15
+ fn add ( & mut self , v : Foo < T > ) {
16
+ self . x += v. x ;
17
+ //~^ ERROR: binary assignment operation `+=` cannot be applied
18
+ }
19
+ }
20
+ fn main ( ) { }
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
+ #[ feature( managed_boxes) ] ;
12
+
13
+ struct BarStruct ;
14
+
15
+ impl < ' a > BarStruct {
16
+ fn foo ( & ' a mut self ) -> @BarStruct { self }
17
+ //~^ ERROR: error: mismatched types: expected `@BarStruct` but found `&'a mut BarStruct
18
+ }
19
+
20
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments