File tree Expand file tree Collapse file tree 10 files changed +216
-0
lines changed Expand file tree Collapse file tree 10 files changed +216
-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+ use std:: io;
12+ use std:: vec;
13+
14+ pub struct Container < ' a > {
15+ reader : & ' a mut Reader //~ ERROR explicit lifetime bound required
16+ }
17+
18+ impl < ' a > Container < ' a > {
19+ pub fn wrap < ' s > ( reader : & ' s mut Reader ) -> Container < ' s > {
20+ Container { reader : reader }
21+ }
22+
23+ pub fn read_to ( & mut self , vec : & mut [ u8 ] ) {
24+ self . reader . read ( vec) ;
25+ }
26+ }
27+
28+ pub fn for_stdin < ' a > ( ) -> Container < ' a > {
29+ let mut r = io:: stdin ( ) ;
30+ Container :: wrap ( & mut r as & mut Reader )
31+ }
32+
33+ fn main ( ) {
34+ let mut c = for_stdin ( ) ;
35+ let mut v = vec:: Vec :: from_elem ( 10 , 0u8 ) ;
36+ c. read_to ( v. as_mut_slice ( ) ) ;
37+ }
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 blah ( ) -> int { //~ ERROR not all control paths return a value
12+ 1 i
13+
14+ ; //~ NOTE consider removing this semicolon:
15+ }
16+
17+ 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( struct_variant) ]
12+
13+ mod a {
14+ pub enum Enum {
15+ EnumStructVariant { x : u8 , y : u8 , z : u8 }
16+ }
17+
18+ pub fn get_enum_struct_variant ( ) -> ( ) {
19+ EnumStructVariant { x : 1 , y : 2 , z : 3 }
20+ //~^ ERROR mismatched types: expected `()`, found `a::Enum` (expected (), found enum a::Enum)
21+ }
22+ }
23+
24+ mod b {
25+ mod test {
26+ use a;
27+
28+ fn test_enum_struct_variant ( ) {
29+ let enum_struct_variant = :: a:: get_enum_struct_variant ( ) ;
30+ match enum_struct_variant {
31+ a:: EnumStructVariant { x, y, z } => {
32+ //~^ ERROR error: mismatched types: expected `()`, found a structure pattern
33+ }
34+ }
35+ }
36+ }
37+ }
38+
39+ 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+ fn main ( ) {
12+ let mut array = [ 1 , 2 , 3 ] ;
13+ //~^ ERROR cannot determine a type for this local variable: cannot determine the type of this integ
14+ let pie_slice = array. slice ( 1 , 2 ) ;
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+ pub fn foo ( params : Option < & [ & str ] > ) -> uint {
12+ params. unwrap ( ) . head ( ) . unwrap ( ) . len ( )
13+ }
14+
15+ fn main ( ) {
16+ let name = "Foo" ;
17+ let msg = foo ( Some ( & [ name. as_slice ( ) ] ) ) ;
18+ //~^ ERROR mismatched types: expected `core::option::Option<&[&str]>`
19+ assert_eq ! ( msg, 3 ) ;
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+ fn main ( ) {
12+ let v = & [ ] ; //~ ERROR cannot determine a type for this local variable: unconstrained type
13+ let it = v. iter ( ) ;
14+ }
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+ // error-pattern:explicit failure
12+
13+ pub fn main ( ) {
14+ fail ! ( ) ; println ! ( "{}" , 1 i) ;
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+ // error-pattern:bad input
12+
13+ fn main ( ) {
14+ Some ( "foo" ) . unwrap_or ( fail ! ( "bad input" ) ) . to_string ( ) ;
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+ pub mod two_tuple {
12+ trait T { }
13+ struct P < ' a > ( & ' a T + ' a , & ' a T + ' a ) ;
14+ pub fn f < ' a > ( car : & ' a T , cdr : & ' a T ) -> P < ' a > {
15+ P ( car, cdr)
16+ }
17+ }
18+
19+ pub mod two_fields {
20+ trait T { }
21+ struct P < ' a > { car : & ' a T + ' a , cdr : & ' a T + ' a }
22+ pub fn f < ' a > ( car : & ' a T , cdr : & ' a T ) -> P < ' a > {
23+ P { car : car, cdr : cdr }
24+ }
25+ }
26+
27+ 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+ fn main ( ) {
12+ if true {
13+ proc ( _) { }
14+ } else {
15+ proc ( _: & mut ( ) ) { }
16+ } ;
17+ }
You can’t perform that action at this time.
0 commit comments