diff options
| author | bors <bors@rust-lang.org> | 2014-01-07 01:51:39 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-01-07 01:51:39 -0800 |
| commit | bc395bc71e02a7726565725ce026758f948b2d76 (patch) | |
| tree | 86576b45e6b489f635fdca29bc4687c7ebd3be96 /src/test | |
| parent | 777f1e8d24a5816a7ca1308ef4243201a6b81221 (diff) | |
| parent | 82365501043735dd8ec5eadaa5d30354cee19252 (diff) | |
| download | rust-bc395bc71e02a7726565725ce026758f948b2d76.tar.gz rust-bc395bc71e02a7726565725ce026758f948b2d76.zip | |
auto merge of #11329 : fhahn/rust/unused-cast-lint2, r=alexcrichton
Updates as mentioned in #11135
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/lint-unnecessary-casts.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/compile-fail/lint-unnecessary-casts.rs b/src/test/compile-fail/lint-unnecessary-casts.rs new file mode 100644 index 00000000000..9324bf11005 --- /dev/null +++ b/src/test/compile-fail/lint-unnecessary-casts.rs @@ -0,0 +1,24 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[forbid(unnecessary_typecast)]; + +fn foo_i32(_: i32) {} + +fn foo_u64(a: u64) { + let b: i32 = a as i32; + foo_i32(b as i32); //~ ERROR: unnecessary type cast +} + +fn main() { + let x: u64 = 1; + let y: u64 = x as u64; //~ ERROR: unnecessary type cast + foo_u64(y as u64); //~ ERROR: unnecessary type cast +} |
