Closed
Description
Steps to reproduce:
- make an new crate, set crate type to
cdylib
- put a simple function in
src/lib.rs
:
#[no_mangle]
pub extern "C" fn rust_no_mangle() -> i32{
42
}
- build with
cargo build --verbose
- copy the
rustc
command line used from above step, and run it as-is
example:
$ cargo build --verbose
Compiling nm v0.1.0 (/tmp/nm)
Running `rustc --edition=2018 --crate-name nm src/lib.rs --color always --crate-type cdylib --emit=dep-info,link -C debuginfo=2 -C metadata=38c165a3ed3ed429 --out-dir /tmp/nm/target/debug/deps -C incremental=/tmp/nm/target/debug/incremental -L dependency=/tmp/nm/target/debug/deps`
Finished dev [unoptimized + debuginfo] target(s) in 0.22s
$ rustc --edition=2018 --crate-name nm src/lib.rs --color always --crate-type cdylib --emit=dep-info,link -C debuginfo=2 -C metadata=38c165a3ed3ed429 --out-dir /tmp/nm/target/debug/deps -C incremental=/tmp/nm/target/debug/incremental -L dependency=/tmp/nm/target/debug/deps
warning: unused attribute
--> src/lib.rs:1:1
|
1 | #[no_mangle]
| ^^^^^^^^^^^^
|
= note: #[warn(unused_attributes)] on by default
As you can see, the first time cargo build
in step 3) has no warnings, however, step 4) cause rustc
complains #[no_mangle]
is unused, which isn't true.
Step 4) can be replaced by:
- modify
src/lib.rs
, so that it cause rebuild - run
cargo build
again
rustc 1.35.0-nightly (70f1309 2019-04-16)