diff options
| author | Noratrieb <48135649+Noratrieb@users.noreply.github.com> | 2025-03-22 22:29:23 +0100 |
|---|---|---|
| committer | Noratrieb <48135649+Noratrieb@users.noreply.github.com> | 2025-03-24 20:07:35 +0100 |
| commit | 1aed58ceb6fc2bdbd4d323fb18fd6d7c9ee21630 (patch) | |
| tree | 96cbcb607f015cf8222084fb1148d9bfd54fe230 /compiler/rustc_middle/src/mir | |
| parent | 81d8edc2000aa38b08ad09fce22d90f1990b6459 (diff) | |
| download | rust-1aed58ceb6fc2bdbd4d323fb18fd6d7c9ee21630.tar.gz rust-1aed58ceb6fc2bdbd4d323fb18fd6d7c9ee21630.zip | |
Emit `unused_attributes` for `#[inline]` on exported functions
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.
Diffstat (limited to 'compiler/rustc_middle/src/mir')
| -rw-r--r-- | compiler/rustc_middle/src/mir/mono.rs | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/mir/mono.rs b/compiler/rustc_middle/src/mir/mono.rs index 58d5c94d033..2aa31761178 100644 --- a/compiler/rustc_middle/src/mir/mono.rs +++ b/compiler/rustc_middle/src/mir/mono.rs @@ -117,6 +117,7 @@ impl<'tcx> MonoItem<'tcx> { // If the function is #[naked] or contains any other attribute that requires exactly-once // instantiation: + // We emit an unused_attributes lint for this case, which should be kept in sync if possible. let codegen_fn_attrs = tcx.codegen_fn_attrs(instance.def_id()); if codegen_fn_attrs.contains_extern_indicator() || codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED) |
