Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using #[inline] on function prototype should emit a warning #51280

Closed
Havvy opened this issue Jun 1, 2018 · 3 comments · Fixed by #65294
Closed

Using #[inline] on function prototype should emit a warning #51280

Havvy opened this issue Jun 1, 2018 · 3 comments · Fixed by #65294
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-feature-request Category: A feature request, i.e: not implemented / a PR.

Comments

@Havvy
Copy link
Contributor

Havvy commented Jun 1, 2018

The following trait does not emit any warnings, although it should warn that the #[inline] hint is ignored on function prototypes.

trait Trait {
    #[inline]
    fn function();
}

Likewise for extern functions. E.g. should warn on

extern {
  #[inline] fn function();
}
@jonas-schievink
Copy link
Contributor

Your trait method is a default method - are inline hints actually ignored there, too (that sounds like a bug)? Perhaps you meant to declare it without a body.

@Havvy
Copy link
Contributor Author

Havvy commented Jun 1, 2018

Yes, meant to declare without a body. Example fixed.

@keringar
Copy link

keringar commented Jun 9, 2018

If anyone's interested in pushing for this by default, it can already be found in clippy. https://rust-lang-nursery.github.io/rust-clippy/master/index.html#inline_fn_without_body

@scottmcm scottmcm added A-diagnostics Area: Messages for errors, warnings, and lints C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Jul 31, 2018
@varkor varkor self-assigned this Oct 11, 2019
Centril added a commit to Centril/rust that referenced this issue Oct 29, 2019
…thewjasper

Lint ignored `#[inline]` on function prototypes

Fixes rust-lang#51280.

- Adds a `unused_attribute` lint for `#[inline]` on function prototypes.
- As a consequence, foreign items, impl items and trait items now have their attributes checked, which could cause some code to no longer compile (it was previously erroneously ignored).
Centril added a commit to Centril/rust that referenced this issue Oct 29, 2019
…thewjasper

Lint ignored `#[inline]` on function prototypes

Fixes rust-lang#51280.

- Adds a `unused_attribute` lint for `#[inline]` on function prototypes.
- As a consequence, foreign items, impl items and trait items now have their attributes checked, which could cause some code to no longer compile (it was previously erroneously ignored).
@bors bors closed this as completed in 42d4e26 Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-feature-request Category: A feature request, i.e: not implemented / a PR.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants