1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
SemverQuery(
id: "inherent_method_const_generic_reordered",
human_readable_name: "inherent method const generics were reordered",
description: "An inherent method's signature now requires a generic type in the prior spot of a const generic.",
required_update: Major,
lint_level: Deny,
reference_link: Some("https://doc.rust-lang.org/reference/items/generics.html"),
query: r#"
{
CrateDiff {
baseline {
item {
... on ImplOwner {
visibility_limit @filter(op: "=", value: ["$public"])
importable_path {
path @tag @output
public_api @filter(op: "=", value: ["$true"])
}
inherent_impl {
method {
method_visibility: visibility_limit @filter(op: "=", value: ["$public"]) @output
method_name: name @output @tag
public_api_eligible @filter(op: "=", value: ["$true"])
# The method takes the same number of const generic
# and generic type parameters as before.
# Otherwise other lints will trigger instead:
# - `method_requires_different_const_generic_params`
# - `method_requires_different_generic_type_params`
generic_parameter @fold
@transform(op: "count")
@tag(name: "required_const_count")
@output(name: "required_const_count") {
... on GenericConstParameter {
name
}
}
generic_parameter @fold
@transform(op: "count")
@tag(name: "required_type_count")
@output(name: "required_type_count") {
... on GenericTypeParameter {
name
}
}
# But a generic type parameter at a specific position in the signature
# has become a const generic instead. This is a breaking change.
generic_parameter {
... on GenericConstParameter {
const_name: name @output
position @tag @output
}
}
}
}
}
}
}
current {
item {
... on ImplOwner {
visibility_limit @filter(op: "=", value: ["$public"])
importable_path {
path @filter(op: "=", value: ["%path"])
public_api @filter(op: "=", value: ["$true"])
}
# We use "impl" instead of "inherent_impl" here because moving
# an inherently-implemented method to a trait is not necessarily
# a breaking change, but changing the generic parameter kinds is.
impl {
method {
visibility_limit @filter(op: "one_of", value: ["$public_or_default"])
name @filter(op: "=", value: ["%method_name"])
public_api_eligible @filter(op: "=", value: ["$true"])
generic_parameter @fold
@transform(op: "count")
@filter(op: "=", value: ["%required_const_count"]) {
... on GenericConstParameter {
name
}
}
generic_parameter @fold
@transform(op: "count")
@filter(op: "=", value: ["%required_type_count"]) {
... on GenericTypeParameter {
name
}
}
generic_parameter {
... on GenericTypeParameter {
type_name: name @output
position @filter(op: "=", value: ["%position"])
}
}
span_: span @optional {
filename @output
begin_line @output
end_line @output
}
}
}
}
}
}
}
}"#,
arguments: {
"public": "public",
"public_or_default": ["public", "default"],
"true": true,
},
error_message: "An inherent method's signature now requires a generic type parameter where a const generic previously stood. Uses of this method that supplied that const generic will be broken since a generic type is now required instead.",
per_result_error_template: Some("method {{join \"::\" path}}::{{method_name}} used to expect const {{const_name}} in the place of type {{type_name}} in {{span_filename}}:{{span_begin_line}}"),
witness: None,
)