#[inline] on static

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.

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

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.

Thanks, everybody. I updated the pull request.

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

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

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.