diff options
| author | bors <bors@rust-lang.org> | 2013-12-14 10:41:24 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-12-14 10:41:24 -0800 |
| commit | 3d3a663d2530dd49fee235667e98f2767dfd1b57 (patch) | |
| tree | 1e6a43693425e4f74f162c236417f49890d46d24 /src/test | |
| parent | f73c9c9bbcaf1595f766ad8bb01e21c78fcba84b (diff) | |
| parent | a67b8863c2d2e31f834e7a2b39b0afa6f8be7492 (diff) | |
| download | rust-3d3a663d2530dd49fee235667e98f2767dfd1b57.tar.gz rust-3d3a663d2530dd49fee235667e98f2767dfd1b57.zip | |
auto merge of #10870 : ktt3ja/rust/issue-10865, r=alexcrichton
Fix #10865 and #10939.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/lint-dead-code-1.rs | 34 | ||||
| -rw-r--r-- | src/test/compile-fail/lint-dead-code-3.rs | 22 | ||||
| -rw-r--r-- | src/test/compile-fail/warn-foreign-int-types.rs | 1 |
3 files changed, 40 insertions, 17 deletions
diff --git a/src/test/compile-fail/lint-dead-code-1.rs b/src/test/compile-fail/lint-dead-code-1.rs index 7d7cbce6e89..6086484772a 100644 --- a/src/test/compile-fail/lint-dead-code-1.rs +++ b/src/test/compile-fail/lint-dead-code-1.rs @@ -26,20 +26,7 @@ pub static pub_static: int = 0; static priv_static: int = 0; //~ ERROR: code is never used static used_static: int = 0; pub static used_static2: int = used_static; - -pub fn pub_fn() { - used_fn(); - let used_struct1 = UsedStruct1 { x: 1 }; - let used_struct2 = UsedStruct2(1); - let used_struct3 = UsedStruct3; - let e = foo3; - SemiUsedStruct::la_la_la(); - -} -fn priv_fn() { //~ ERROR: code is never used - let unused_struct = PrivStruct; -} -fn used_fn() {} +static USED_STATIC: int = 0; pub type typ = ~UsedStruct4; pub struct PubStruct(); @@ -59,6 +46,25 @@ pub enum pub_enum { foo1, bar1 } enum priv_enum { foo2, bar2 } //~ ERROR: code is never used enum used_enum { foo3, bar3 } +pub fn pub_fn() { + used_fn(); + let used_struct1 = UsedStruct1 { x: 1 }; + let used_struct2 = UsedStruct2(1); + let used_struct3 = UsedStruct3; + let e = foo3; + SemiUsedStruct::la_la_la(); + + let i = 1; + match i { + USED_STATIC => (), + _ => () + } +} +fn priv_fn() { //~ ERROR: code is never used + let unused_struct = PrivStruct; +} +fn used_fn() {} + fn foo() { //~ ERROR: code is never used bar(); let unused_enum = foo2; diff --git a/src/test/compile-fail/lint-dead-code-3.rs b/src/test/compile-fail/lint-dead-code-3.rs index 8a5f239ed05..29d77959997 100644 --- a/src/test/compile-fail/lint-dead-code-3.rs +++ b/src/test/compile-fail/lint-dead-code-3.rs @@ -40,11 +40,27 @@ fn bar2() { pub fn pub_fn() { let foo2_struct = Foo2; foo2_struct.foo2(); + + blah::baz(); } -// not warned because it's used in the parameter of `free` below -enum c_void {} +mod blah { + use std::libc::size_t; + // not warned because it's used in the parameter of `free` and return of + // `malloc` below, which are also used. + enum c_void {} + + extern { + fn free(p: *c_void); + fn malloc(size: size_t) -> *c_void; + } + + pub fn baz() { + unsafe { free(malloc(4)); } + } +} +enum c_void {} //~ ERROR: code is never used extern { - fn free(p: *c_void); + fn free(p: *c_void); //~ ERROR: code is never used } diff --git a/src/test/compile-fail/warn-foreign-int-types.rs b/src/test/compile-fail/warn-foreign-int-types.rs index be6871ae6ff..726d778c3bb 100644 --- a/src/test/compile-fail/warn-foreign-int-types.rs +++ b/src/test/compile-fail/warn-foreign-int-types.rs @@ -9,6 +9,7 @@ // except according to those terms. #[forbid(ctypes)]; +#[allow(dead_code)]; mod xx { extern { |
