-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
function_abi_now_unwind
lint and fix `function_abi_no_longer_un…
…wind`. (#1061) The `function_abi_no_longer_unwind` lint had false-positives since it failed to connect the baseline and current functions by their import paths.
- Loading branch information
1 parent
f55dc22
commit 6172415
Showing
7 changed files
with
112 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
SemverQuery( | ||
id: "function_abi_now_unwind", | ||
human_readable_name: "function abi is now unwind-capable", | ||
description: "A pub fn changed from an non-unwind ABI to the same-named ABI with unwind ability. This change might not be compatible with callers of this function, since they may not expect unwinding to happen here.", | ||
required_update: Major, | ||
lint_level: Deny, | ||
reference_link: Some("https://rust-lang.github.io/rfcs/2945-c-unwind-abi.html"), | ||
query: r#" | ||
{ | ||
CrateDiff { | ||
current { | ||
item { | ||
... on Function { | ||
visibility_limit @filter(op: "=", value: ["$public"]) | ||
name @output | ||
new_abi_: abi { | ||
name @tag(name: "abi") | ||
raw_name @output | ||
unwind @filter(op: "=", value: ["$true"]) | ||
} | ||
importable_path { | ||
path @output @tag | ||
public_api @filter(op: "=", value: ["$true"]) | ||
} | ||
span_: span @optional { | ||
filename @output | ||
begin_line @output | ||
} | ||
} | ||
} | ||
} | ||
baseline { | ||
item { | ||
... on Function { | ||
visibility_limit @filter(op: "=", value: ["$public"]) | ||
abi_: abi { | ||
name @filter(op: "=", value: ["%abi"]) | ||
raw_name @output | ||
unwind @filter(op: "!=", value: ["$true"]) | ||
} | ||
importable_path { | ||
path @filter(op: "=", value: ["%path"]) | ||
public_api @filter(op: "=", value: ["$true"]) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}"#, | ||
arguments: { | ||
"public": "public", | ||
"true": true, | ||
}, | ||
error_message: "A pub fn changed from a non-unwind ABI to the same-named ABI with unwind ability. This change might not be compatible with callers of this function, since they may not expect unwinding to happen here.", | ||
per_result_error_template: Some("{{join \"::\" path}} changed ABI from {{abi_raw_name}} to {{new_abi_raw_name}} in {{span_filename}}:{{span_begin_line}}"), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
pub extern "C" fn unwind_function_becomes_non_unwind() {} | ||
|
||
pub extern "C-unwind" fn non_unwind_function_becomes_unwind() {} | ||
|
||
pub extern "C" fn non_unwind_function_unchanged() {} | ||
|
||
pub extern "C-unwind" fn unwind_function_unchanged() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
pub extern "C-unwind" fn unwind_function_becomes_non_unwind() {} | ||
|
||
pub extern "C" fn non_unwind_function_becomes_unwind() {} | ||
|
||
pub extern "C" fn non_unwind_function_unchanged() {} | ||
|
||
pub extern "C-unwind" fn unwind_function_unchanged() {} |
5 changes: 5 additions & 0 deletions
5
test_outputs/query_execution/function_abi_no_longer_unwind.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
source: src/query.rs | ||
expression: "&query_execution_results" | ||
snapshot_kind: text | ||
--- | ||
{ | ||
"./test_crates/function_abi_no_longer_unwind/": [ | ||
{ | ||
"abi_raw_name": String("C"), | ||
"name": String("non_unwind_function_becomes_unwind"), | ||
"new_abi_raw_name": String("C-unwind"), | ||
"path": List([ | ||
String("function_abi_no_longer_unwind"), | ||
String("non_unwind_function_becomes_unwind"), | ||
]), | ||
"span_begin_line": Uint64(3), | ||
"span_filename": String("src/lib.rs"), | ||
}, | ||
], | ||
} |