#[inline] on static


#1

I thought #[inline] can be applied to only functions, but it seems that it can be also applied to statics. What does it mean to apply #[inline] to statics?

See https://github.com/rust-lang/rust/pull/28650.


#2

AFAIK #[inline] static is the predecessor of const; see RFC246.


#3

It was used before the const/static split when everything was static and inline by default, but some statics had to be marked as #[inline(never)] to be non-inlinable and have stable address. Now all statics have stable address by definition, so the inline attribute is probably not needed anymore.


#4

Thanks, everybody. I updated the pull request.


#5

If it’s still accepted, we should probably fix that. Anyone know if there is an issue or anything?


#6

My pull request to check attribute usage was merged, so #[inline] on static is now rejected.