-
-
Save osyoyu/36d306f0366eba40b1acd7305e5dba11 to your computer and use it in GitHub Desktop.
associated function `new` is never used
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a/mymod.rs ではなく mymod.rs をむりやり使う | |
#[path="./mymod.rs"] | |
pub mod mymod; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// こっちも | |
#[path="./mymod.rs"] | |
pub mod mymod; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% cargo build | |
Compiling hello v0.1.0 (/home/osyoyu/Development/hello) | |
warning: struct `Foo` is never constructed | |
--> src/./mymod.rs:1:12 | |
| | |
1 | pub struct Foo {} | |
| ^^^ | |
| | |
= note: `#[warn(dead_code)]` on by default | |
warning: associated function `new` is never used | |
--> src/./mymod.rs:3:12 | |
| | |
2 | impl Foo { | |
| -------- associated function in this implementation | |
3 | pub fn new() { } | |
| ^^^ | |
warning: `hello` (bin "hello") generated 2 warnings | |
Finished dev [unoptimized + debuginfo] target(s) in 0.07s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mod a; | |
mod b; | |
fn main() { | |
let _ = a::mymod::Foo::new(); | |
println!("Hello, world!"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a::mymod::Foo と b::mymod::Foo の両方の実装になっていて、 | |
// b::mymod::Foo は呼び出されていないので warning になる | |
pub struct Foo {} | |
impl Foo { | |
pub fn new() { } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment