Skip to content

Commit

Permalink
Improve error message for inherent_method_const_removed lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
obi1kenobi committed Nov 8, 2023
1 parent 34b9636 commit c8e705b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/lints/inherent_method_const_removed.ron
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ SemverQuery(
method {
visibility_limit @filter(op: "one_of", value: ["$public_or_default"])
name @filter(op: "=", value: ["%method_name"])
unsafe @filter(op: "=", value: ["$true"])
const @filter(op: "!=", value: ["$true"])
non_matching_span_: span @optional {
filename @output
Expand All @@ -93,5 +93,5 @@ SemverQuery(
"true": true,
},
error_message: "A publicly-visible method or associated fn is no longer `const` and can no longer be used in a `const` context.",
per_result_error_template: Some("{{name}}::{{method_name}} in file {{span_filename}}:{{span_begin_line}}"),
per_result_error_template: Some("{{name}}::{{method_name}} in {{multiple_spans non_matching_span_filename non_matching_span_begin_line}}"),
)
16 changes: 12 additions & 4 deletions test_outputs/inherent_method_const_removed.output.ron
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
"method_name": String("associated_fn"),
"method_visibility": String("public"),
"name": String("Foo"),
"non_matching_span_begin_line": List([]),
"non_matching_span_filename": List([]),
"non_matching_span_begin_line": List([
Uint64(4),
]),
"non_matching_span_filename": List([
String("src/lib.rs"),
]),
"path": List([
String("inherent_method_const_removed"),
String("Foo"),
Expand All @@ -18,8 +22,12 @@
"method_name": String("method"),
"method_visibility": String("public"),
"name": String("Foo"),
"non_matching_span_begin_line": List([]),
"non_matching_span_filename": List([]),
"non_matching_span_begin_line": List([
Uint64(8),
]),
"non_matching_span_filename": List([
String("src/lib.rs"),
]),
"path": List([
String("inherent_method_const_removed"),
String("Foo"),
Expand Down

0 comments on commit c8e705b

Please sign in to comment.