
I saw someone post a code sample that contained these two attributes, which immediately made me suspicious. My suspicions were confirmed when I did a small test and checked the compiler source code to confirm that in these cases, `#[inline]` is indeed ignored (because you can't exactly `LocalCopy`an unmangled symbol since that would lead to duplicate symbols, and doing a mix of an unmangled `GloballyShared` and mangled `LocalCopy` instantiation is too complicated for our current instatiation mode logic, which I don't want to change right now). So instead, emit the usual unused attribute lint with a message saying that the attribute is ignored in this position. I think this is not 100% true, since I expect LLVM `inlinehint` to still be applied to such a function, but that's not why people use this attribute, they use it for the `LocalCopy` instantiation mode, where it doesn't work.
30 lines
724 B
Rust
30 lines
724 B
Rust
//! Ensure the unused_attributes lint fires for externally exported functions with `#[inline]`,
|
|
//! because `#[inline]` is ignored for such functions.
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
#![feature(linkage)]
|
|
#![feature(naked_functions)]
|
|
#![deny(unused_attributes)]
|
|
|
|
#[inline]
|
|
//~^ ERROR: `#[inline]` is ignored on externally exported functions
|
|
#[no_mangle]
|
|
fn no_mangle() {}
|
|
|
|
#[inline]
|
|
//~^ ERROR: `#[inline]` is ignored on externally exported functions
|
|
#[export_name = "export_name"]
|
|
fn export_name() {}
|
|
|
|
#[inline]
|
|
//~^ ERROR: `#[inline]` is ignored on externally exported functions
|
|
#[linkage = "external"]
|
|
fn external_linkage() {}
|
|
|
|
#[inline]
|
|
fn normal() {}
|
|
|
|
#[inline]
|
|
#[linkage = "internal"] // not exported
|
|
fn internal_linkage() {}
|