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

Force explicit abi #13372

Open
maijun-sec opened this issue Sep 9, 2024 · 1 comment · May be fixed by #13404
Open

Force explicit abi #13372

maijun-sec opened this issue Sep 9, 2024 · 1 comment · May be fixed by #13404
Assignees
Labels
A-lint Area: New lints

Comments

@maijun-sec
Copy link

maijun-sec commented Sep 9, 2024

What it does

This is from a configuration of rustfmt force_explicit_abi.

When using extern to specify an external function, it's advised to explicitly specify C-ABI.

Although the default is C-ABI if extern is not specified, it is a convention for Rust to specify it explicitly.

Advantage

  • It is a convention for Rust to specify it explicitly when using extern to specify an external function;
  • Clippy can support to check such scenario that rustfmt can automatically format.

Drawbacks

No response

Example

bad case:

// Noncompliant
extern {
    pub static lorem: c_int;
}

good case:

// Compliant
extern "C" {
    pub static lorem: c_int;
}

extern "Rust" {
    type MyType;
    fn f(&self) -> usize;
}
@maijun-sec maijun-sec added the A-lint Area: New lints label Sep 9, 2024
@CBSpeir
Copy link
Contributor

CBSpeir commented Sep 14, 2024

@rustbot claim

@CBSpeir CBSpeir linked a pull request Sep 16, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants