File tree Expand file tree Collapse file tree 4 files changed +71
-3
lines changed
librustc/middle/typeck/check Expand file tree Collapse file tree 4 files changed +71
-3
lines changed Original file line number Diff line number Diff line change @@ -3054,7 +3054,8 @@ pub fn check_block_with_expected(fcx: @mut FnCtxt,
3054
3054
} ,
3055
3055
Some ( e) => {
3056
3056
if any_bot && !warned {
3057
- fcx. ccx . tcx . sess . span_warn ( e. span , "unreachable expression" ) ;
3057
+ fcx. ccx . tcx . sess . add_lint ( unreachable_code, e. id , e. span ,
3058
+ ~"unreachable expression") ;
3058
3059
}
3059
3060
check_expr_with_opt_hint ( fcx, e, expected) ;
3060
3061
let ety = fcx. expr_ty ( e) ;
Original file line number Diff line number Diff line change @@ -16,8 +16,7 @@ impl<A> vec_monad<A> for ~[A] {
16
16
fn bind < B > ( & self , f : & fn ( A ) -> ~[ B ] ) {
17
17
let mut r = fail2 ! ( ) ;
18
18
for elt in self . iter ( ) { r = r + f ( * elt) ; }
19
- //~^ WARNING unreachable expression
20
- //~^^ ERROR the type of this value must be known
19
+ //~^ ERROR the type of this value must be known
21
20
}
22
21
}
23
22
fn main ( ) {
Original file line number Diff line number Diff line change
1
+ // Copyright 2013 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
+ #[ deny( unreachable_code) ] ;
12
+ use std:: ptr;
13
+ pub unsafe fn g ( ) {
14
+ return ;
15
+ if * ptr:: null ( ) { } ; //~ ERROR unreachable
16
+ }
17
+
18
+ pub fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ // Copyright 2013 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
+
13
+ pub struct PkgId {
14
+ local_path : ~str ,
15
+ junk : ~str
16
+ }
17
+
18
+ impl PkgId {
19
+ fn new ( s : & str ) -> PkgId {
20
+ PkgId {
21
+ local_path : s. to_owned ( ) ,
22
+ junk : ~"wutevs"
23
+ }
24
+ }
25
+ }
26
+
27
+ pub fn remove_package_from_database ( ) {
28
+ let mut lines_to_use: ~[ & PkgId ] = ~[ ] ; //~ ERROR cannot infer an appropriate lifetime
29
+ let push_id = |installed_id : & PkgId | {
30
+ lines_to_use. push ( installed_id) ;
31
+ } ;
32
+ list_database ( push_id) ;
33
+
34
+ for l in lines_to_use. iter ( ) {
35
+ io:: stdout ( ) . write_line ( l. local_path ) ;
36
+ }
37
+
38
+ }
39
+
40
+ pub fn list_database ( f : & fn ( & PkgId ) ) {
41
+ let stuff = [ "foo" , "bar" ] ;
42
+
43
+ for l in stuff. iter ( ) {
44
+ f ( & PkgId :: new ( * l) ) ;
45
+ }
46
+ }
47
+
48
+ pub fn main ( ) {
49
+ remove_package_from_database ( ) ;
50
+ }
You can’t perform that action at this time.
0 commit comments