Skip to content

Force explicit abi #13372

Closed
Closed
@maijun-sec

Description

@maijun-sec

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;
}

Metadata

Metadata

Assignees

Labels

A-lintArea: New lints

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions