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

New lint: add function_abi_no_longer_unwind lint #689

Merged
merged 8 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 51 additions & 0 deletions src/lints/function_abi_no_longer_unwind.ron
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
SemverQuery(
id: "function_abi_no_longer_unwind",
human_readable_name: "function abi no longer unwind",
description: "A pub fn changed from an unwind-capable ABI to the same-named ABI without unwind",
obi1kenobi marked this conversation as resolved.
Show resolved Hide resolved
required_update: Major,
reference_link: Some("https://rust-lang.github.io/rfcs/2945-c-unwind-abi.html"),
query: r#"
{
CrateDiff {
baseline {
item {
... on Function {
visibility_limit @filter(op: "=", value: ["$public"])

abi_: abi {
name @tag
raw_name @output
unwind @filter(op: "=", value: ["$true"])
}
}
}
}
current {
item {
... on Function {
visibility_limit @filter(op: "=", value: ["$public"])

name @output

new_abi_: abi {
name @filter(op: "=", value: ["%name"])
raw_name @output
unwind @filter(op: "!=", value: ["$true"])
}

span_: span @optional {
filename @output
begin_line @output
}
}
}
}
}
}"#,
arguments: {
"public": "public",
"true": true,
},
error_message: "A pub fn changed from an unwind-capable ABI to the same-named ABI without unwind",
obi1kenobi marked this conversation as resolved.
Show resolved Hide resolved
per_result_error_template: Some("pub fn {{name}} changed ABI from {{abi_raw_name}} to {{new_abi_raw_name}} in {{span_filename}}:{{span_begin_line}}"),
)
1 change: 1 addition & 0 deletions src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ macro_rules! add_lints {
}

add_lints!(
function_abi_no_longer_unwind,
enum_struct_variant_field_now_doc_hidden,
enum_tuple_variant_field_now_doc_hidden,
trait_method_now_doc_hidden,
Expand Down
7 changes: 7 additions & 0 deletions test_crates/function_abi_no_longer_unwind/new/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
publish = false
name = "function_abi_no_longer_unwind"
version = "0.1.0"
edition = "2021"

[dependencies]
1 change: 1 addition & 0 deletions test_crates/function_abi_no_longer_unwind/new/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub extern "C" fn unwind_function_becomes_non_unwind() {}
7 changes: 7 additions & 0 deletions test_crates/function_abi_no_longer_unwind/old/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
publish = false
name = "function_abi_no_longer_unwind"
version = "0.1.0"
edition = "2021"

[dependencies]
1 change: 1 addition & 0 deletions test_crates/function_abi_no_longer_unwind/old/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub extern "C-unwind" fn unwind_function_becomes_non_unwind() {}
11 changes: 11 additions & 0 deletions test_outputs/function_abi_no_longer_unwind.output.ron
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"./test_crates/function_abi_no_longer_unwind/": [
{
"abi_raw_name": String("C-unwind"),
"name": String("unwind_function_becomes_non_unwind"),
"new_abi_raw_name": String("C"),
"span_begin_line": Uint64(1),
"span_filename": String("src/lib.rs"),
},
],
}