2014-10-27 15:37:07 -07:00
|
|
|
#![allow(unused_variables)]
|
2014-03-21 18:05:05 -07:00
|
|
|
#![allow(non_camel_case_types)]
|
2020-06-28 10:11:04 +10:00
|
|
|
#![allow(clashing_extern_declarations)]
|
2014-03-21 18:05:05 -07:00
|
|
|
#![deny(dead_code)]
|
2013-12-08 02:55:27 -05:00
|
|
|
|
2014-03-21 18:05:05 -07:00
|
|
|
#![crate_type="lib"]
|
2013-12-08 02:55:27 -05:00
|
|
|
|
2014-02-26 12:58:41 -05:00
|
|
|
|
2014-08-12 19:25:05 -07:00
|
|
|
pub use extern_foo as x;
|
2020-09-01 17:12:52 -04:00
|
|
|
extern "C" {
|
2015-03-16 09:00:41 +13:00
|
|
|
pub fn extern_foo();
|
2014-07-20 22:11:43 -07:00
|
|
|
}
|
|
|
|
|
2022-06-10 12:14:24 +09:00
|
|
|
struct Foo; //~ ERROR: struct `Foo` is never constructed
|
2013-12-08 02:55:27 -05:00
|
|
|
impl Foo {
|
2023-02-21 14:11:08 -07:00
|
|
|
fn foo(&self) { //~ ERROR: method `foo` is never used
|
2013-12-08 02:55:27 -05:00
|
|
|
bar()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-10 12:14:24 +09:00
|
|
|
fn bar() { //~ ERROR: function `bar` is never used
|
2015-11-07 22:07:13 +00:00
|
|
|
fn baz() {}
|
2013-12-08 02:55:27 -05:00
|
|
|
|
|
|
|
Foo.foo();
|
|
|
|
baz();
|
|
|
|
}
|
|
|
|
|
|
|
|
// no warning
|
|
|
|
struct Foo2;
|
|
|
|
impl Foo2 { fn foo2(&self) { bar2() } }
|
|
|
|
fn bar2() {
|
|
|
|
fn baz2() {}
|
|
|
|
|
|
|
|
Foo2.foo2();
|
|
|
|
baz2();
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn pub_fn() {
|
|
|
|
let foo2_struct = Foo2;
|
|
|
|
foo2_struct.foo2();
|
2013-12-14 00:08:26 -05:00
|
|
|
|
|
|
|
blah::baz();
|
2013-12-08 02:55:27 -05:00
|
|
|
}
|
|
|
|
|
2013-12-14 00:08:26 -05:00
|
|
|
mod blah {
|
|
|
|
// not warned because it's used in the parameter of `free` and return of
|
|
|
|
// `malloc` below, which are also used.
|
|
|
|
enum c_void {}
|
|
|
|
|
2020-09-01 17:12:52 -04:00
|
|
|
extern "C" {
|
2014-06-25 12:47:34 -07:00
|
|
|
fn free(p: *const c_void);
|
2017-11-26 10:39:16 -08:00
|
|
|
fn malloc(size: usize) -> *const c_void;
|
2013-12-14 00:08:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn baz() {
|
|
|
|
unsafe { free(malloc(4)); }
|
|
|
|
}
|
|
|
|
}
|
2013-12-08 02:55:27 -05:00
|
|
|
|
2022-06-10 12:14:24 +09:00
|
|
|
enum c_void {} //~ ERROR: enum `c_void` is never used
|
2020-09-01 17:12:52 -04:00
|
|
|
extern "C" {
|
2022-06-10 12:14:24 +09:00
|
|
|
fn free(p: *const c_void); //~ ERROR: function `free` is never used
|
2013-12-08 02:55:27 -05:00
|
|
|
}
|
2013-12-31 16:19:57 -05:00
|
|
|
|
|
|
|
// Check provided method
|
|
|
|
mod inner {
|
|
|
|
pub trait Trait {
|
|
|
|
fn f(&self) { f(); }
|
|
|
|
}
|
|
|
|
|
2015-01-08 21:54:35 +11:00
|
|
|
impl Trait for isize {}
|
2013-12-31 16:19:57 -05:00
|
|
|
|
|
|
|
fn f() {}
|
|
|
|
}
|
|
|
|
|
2022-06-19 18:52:06 +02:00
|
|
|
fn anon_const() -> [(); {
|
|
|
|
fn blah() {} //~ ERROR: function `blah` is never used
|
|
|
|
1
|
|
|
|
}] {
|
|
|
|
[(); {
|
|
|
|
fn blah() {} //~ ERROR: function `blah` is never used
|
|
|
|
1
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
|
2013-12-31 16:19:57 -05:00
|
|
|
pub fn foo() {
|
2019-05-28 14:46:13 -04:00
|
|
|
let a: &dyn inner::Trait = &1_isize;
|
2013-12-31 16:19:57 -05:00
|
|
|
a.f();
|
2022-06-19 18:52:06 +02:00
|
|
|
anon_const();
|
2013-12-31 16:19:57 -05:00
|
|
|
}
|