Skip to content

Commit

Permalink
feat: add witnesses for function_const_removed (#977)
Browse files Browse the repository at this point in the history
* feat: add const witnesses

* Apply suggestions from code review

---------

Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
  • Loading branch information
CommanderStorm and obi1kenobi authored Oct 18, 2024
1 parent 972a769 commit 3a51c65
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lints/function_const_removed.ron
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,9 @@ SemverQuery(
},
error_message: "A publicly-visible function is no longer `const` and can no longer be used in a `const` context.",
per_result_error_template: Some("function {{join \"::\" path}} in file {{span_filename}}:{{span_begin_line}}"),
witness: (
hint_template: r#"const fn witness() {
{{join "::" path}}(...);
}"#,
),
)
12 changes: 12 additions & 0 deletions test_outputs/witnesses/function_const_removed.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
source: src/query.rs
description: "Lint `function_const_removed` did not have the expected witness output.\nSee https://github.com/obi1kenobi/cargo-semver-checks/blob/main/CONTRIBUTING.md#testing-witnesses\nfor more information."
expression: "&actual_witnesses"
---
[["./test_crates/function_const_removed/"]]
filename = 'src/lib.rs'
begin_line = 1
hint = '''
const fn witness() {
function_const_removed::add(...);
}'''

0 comments on commit 3a51c65

Please # to comment.