You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know I was hoping for a lot there, and I know that #[inline(never)] is just a suggestion. That said, given that I didn't get a warning here I would have expected removing the ! to produce the same output. But
#[inline(never)]pubfnf(x:u64) -> u64{
x + 1}pubfng(x:u64) -> u64{f(x) + 1}
Many built-in attributes are not validated that they appear in correct locations, particularly for the codegen attributes. I don't think there is a single issue tracking this, but I think #55112 is probably the closest?
There are a number of other issues reporting similar confusion about attributes being ignored: #54044, #47725, #54584, #53901, #64734, #65128. The lint control attributes (allow/warn/deny) are particularly gnarly since they can go anywhere, but don't always do what people expect (#61552, #59144 among others).
#64734 is especially relevant because, as discussion there immediately identified, #[inline] is in the same boat as #[repr]: we already have a pretty comprehensive lint for these specific attributes being misapplied, it only forgets to check attribute of the root module specifically. As @varkor already said in that thread, we should really fix that.
It would occasionally be convenient to be able to say "inline nothing in this module", if that was easy to provide. I wrote #![inline(never)] on purpose in some code we were trying to debug / analyze.
Such a feature might not be hard to provide, but we need fix the bug in attribute checking anyway (since it affects other attributes too), and IMO we should do that first. I'd like at least one release where rustc highlights potential pre-existing typos such as
///! This is a simple crate with a few functions, one of which is `#[inline]`.#![some_crate_attribute]#![inline]// typo: a ! snuck infnfoo(){// ...}// ... other functions, which aren't intended to be #[inline]
Closing since #![inline] now results in an error (or warning in some cases) when used in the wrong position (via #73461 and #76329), and #80641/#80920 are plugging up the last few holes.
Activity
ehuss commentedon Feb 23, 2020
Many built-in attributes are not validated that they appear in correct locations, particularly for the codegen attributes. I don't think there is a single issue tracking this, but I think #55112 is probably the closest?
There are a number of other issues reporting similar confusion about attributes being ignored: #54044, #47725, #54584, #53901, #64734, #65128. The lint control attributes (allow/warn/deny) are particularly gnarly since they can go anywhere, but don't always do what people expect (#61552, #59144 among others).
hanna-kruppe commentedon Feb 23, 2020
#64734 is especially relevant because, as discussion there immediately identified,
#[inline]is in the same boat as#[repr]: we already have a pretty comprehensive lint for these specific attributes being misapplied, it only forgets to check attribute of the root module specifically. As @varkor already said in that thread, we should really fix that.BartMassey commentedon Feb 23, 2020
Thanks for the insights!
It would occasionally be convenient to be able to say "inline nothing in this module", if that was easy to provide. I wrote
#![inline(never)]on purpose in some code we were trying to debug / analyze.hanna-kruppe commentedon Feb 26, 2020
Such a feature might not be hard to provide, but we need fix the bug in attribute checking anyway (since it affects other attributes too), and IMO we should do that first. I'd like at least one release where rustc highlights potential pre-existing typos such as
Rollup merge of rust-lang#76329 - GuillaumeGomez:doc-alias-crate-leve…
ehuss commentedon Jan 25, 2021
Closing since
#![inline]now results in an error (or warning in some cases) when used in the wrong position (via #73461 and #76329), and #80641/#80920 are plugging up the last few holes.