File tree Expand file tree Collapse file tree 10 files changed +259
-0
lines changed Expand file tree Collapse file tree 10 files changed +259
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright 2015 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( never_type) ]
12
+
13
+ fn foo ( x : !) -> ! {
14
+ x
15
+ }
16
+
17
+ fn main ( ) {
18
+ foo ( "wow" ) ; //~ ERROR mismatched types
19
+ }
20
+
Original file line number Diff line number Diff line change
1
+ // Copyright 2015 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( never_type) ]
12
+ #![ deny( unused, unreachable_code) ]
13
+
14
+ fn main ( ) {
15
+ let x: ! = panic ! ( "aah" ) ; //~ ERROR unused
16
+ drop ( x) ; //~ ERROR unreachable
17
+ }
18
+
Original file line number Diff line number Diff line change
1
+ // Copyright 2015 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( never_type) ]
12
+
13
+ fn main ( ) {
14
+ let x: ! = "hello" ; //~ ERROR mismatched types
15
+ }
16
+
17
+
Original file line number Diff line number Diff line change
1
+ // Copyright 2012 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
+ trait Foo {
12
+ type Wub ;
13
+ }
14
+
15
+ type Ma = ( u32 , !, i32 ) ; //~ ERROR type is experimental
16
+ type Meeshka = Vec < !> ; //~ ERROR type is experimental
17
+ type Mow = & fn ( !) -> !; //~ ERROR type is experimental
18
+ type Skwoz = & mut !; //~ ERROR type is experimental
19
+
20
+ impl Foo for Meeshka {
21
+ type Wub = !; //~ ERROR type is experimental
22
+ }
23
+
24
+ fn main ( ) {
25
+ }
26
+
Original file line number Diff line number Diff line change
1
+ // Copyright 2015 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( never_type) ]
12
+
13
+ trait Balls : Sized {
14
+ fn smeg ( ) -> Result < Self , ( ) > ;
15
+ }
16
+
17
+ impl Balls for ( ) {
18
+ fn smeg ( ) -> Result < ( ) , ( ) > { Ok ( ( ) ) }
19
+ }
20
+
21
+ struct Flah ;
22
+
23
+ impl Flah {
24
+ fn flah < T : Balls > ( & self ) -> Result < T , ( ) > {
25
+ T :: smeg ( )
26
+ }
27
+ }
28
+
29
+ fn doit ( ) -> Result < ( ) , ( ) > {
30
+ let _ = try!( Flah . flah ( ) ) ; //~ ERROR the trait bound
31
+ Ok ( ( ) )
32
+ }
33
+
34
+ fn main ( ) {
35
+ let _ = doit ( ) ;
36
+ }
37
+
Original file line number Diff line number Diff line change
1
+ // Copyright 2012 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:wowzers!
12
+
13
+ #![ feature( never_type) ]
14
+ #![ allow( unreachable_code) ]
15
+
16
+ fn foo ( x : !) -> ! {
17
+ x
18
+ }
19
+
20
+ fn main ( ) {
21
+ foo ( panic ! ( "wowzers!" ) )
22
+ }
23
+
Original file line number Diff line number Diff line change
1
+ // Copyright 2012 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( never_type) ]
12
+
13
+ // error-pattern:kapow!
14
+
15
+ trait Foo {
16
+ type Wow ;
17
+
18
+ fn smeg ( & self ) -> Self :: Wow ;
19
+ }
20
+
21
+ struct Blah ;
22
+ impl Foo for Blah {
23
+ type Wow = !;
24
+ fn smeg ( & self ) -> ! {
25
+ panic ! ( "kapow!" ) ;
26
+ }
27
+ }
28
+
29
+ fn main ( ) {
30
+ Blah . smeg ( ) ;
31
+ }
32
+
Original file line number Diff line number Diff line change
1
+ // Copyright 2012 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:oh no!
12
+
13
+ #![ feature( never_type) ]
14
+
15
+ struct Wub ;
16
+
17
+ impl PartialEq < !> for Wub {
18
+ fn eq ( & self , other : & !) -> bool {
19
+ * other
20
+ }
21
+ }
22
+
23
+ fn main ( ) {
24
+ let _ = Wub == panic ! ( "oh no!" ) ;
25
+ }
26
+
Original file line number Diff line number Diff line change
1
+ // Copyright 2015 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( never_type) ]
12
+
13
+ fn main ( ) {
14
+ let x: Result < u32 , !> = Ok ( 123 ) ;
15
+ match x {
16
+ Ok ( z) => ( ) ,
17
+ Err ( y) => {
18
+ let q: u32 = y;
19
+ let w: i32 = y;
20
+ let e: String = y;
21
+ y
22
+ } ,
23
+ }
24
+ }
25
+
Original file line number Diff line number Diff line change
1
+ // Copyright 2015 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
+ trait Balls : Sized {
12
+ fn smeg ( ) -> Result < Self , ( ) > ;
13
+ }
14
+
15
+ impl Balls for ( ) {
16
+ fn smeg ( ) -> Result < ( ) , ( ) > { Ok ( ( ) ) }
17
+ }
18
+
19
+ struct Flah ;
20
+
21
+ impl Flah {
22
+ fn flah < T : Balls > ( & self ) -> Result < T , ( ) > {
23
+ T :: smeg ( )
24
+ }
25
+ }
26
+
27
+ fn doit ( ) -> Result < ( ) , ( ) > {
28
+ let _ = try!( Flah . flah ( ) ) ;
29
+ Ok ( ( ) )
30
+ }
31
+
32
+ fn main ( ) {
33
+ let _ = doit ( ) ;
34
+ }
35
+
You can’t perform that action at this time.
0 commit comments