-
-
Notifications
You must be signed in to change notification settings - Fork 72
/
unit_struct_changed_kind.ron
62 lines (58 loc) · 2.59 KB
/
unit_struct_changed_kind.ron
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
SemverQuery(
id: "unit_struct_changed_kind",
human_readable_name: "unit struct changed kind",
description: "A struct changed from a unit struct to a plain struct.",
reference: Some("A public struct that was previously a unit struct is now a plain struct. The unit struct was not marked #[non_exhaustive], so it could be constructed outside of the defining crate. Plain structs cannot be constructed using the syntax allowed for unit structs, so this is a major breaking change for code that depends on it."),
required_update: Major,
lint_level: Deny,
// TODO: Change the reference link once this cargo docs PR merges:
// https://github.com/rust-lang/cargo/pull/10871
//
// Change to this link:
// https://doc.rust-lang.org/cargo/reference/semver.html#struct-unit-to-normal
reference_link: Some("https://github.com/rust-lang/cargo/pull/10871"),
query: r#"
{
CrateDiff {
baseline {
item {
... on Struct {
visibility_limit @filter(op: "=", value: ["$public"]) @output
struct_type @filter(op: "=", value: ["$unit"])
attrs @filter(op: "not_contains", value: ["$non_exhaustive"])
importable_path {
path @output @tag
public_api @filter(op: "=", value: ["$true"])
}
}
}
}
current {
item {
... on Struct {
visibility_limit @filter(op: "=", value: ["$public"])
name @output
struct_type @filter(op: "=", value: ["$plain"])
importable_path {
path @filter(op: "=", value: ["%path"])
public_api @filter(op: "=", value: ["$true"])
}
span_: span @optional {
filename @output
begin_line @output
}
}
}
}
}
}"#,
arguments: {
"public": "public",
"unit": "unit",
"plain": "plain",
"non_exhaustive": "#[non_exhaustive]",
"true": true,
},
error_message: "A public unit struct has been changed to a normal (curly-braces) struct, which cannot be constructed using the same struct literal syntax.",
per_result_error_template: Some("struct {{name}} in {{span_filename}}:{{span_begin_line}}"),
)