@@ -7,31 +7,32 @@ source ci/_
7
7
# (benches, frozen abi...)
8
8
source ci/rust-version.sh nightly
9
9
10
- # There's a special common feature called `dev-utils` to
10
+ # There's a special common feature called `dev-context-only- utils` to
11
11
# overcome cargo's issue: https://github.com/rust-lang/cargo/issues/8379
12
12
# This feature is like `cfg(test)`, which works between crates.
13
13
#
14
14
# Unfortunately, this in turn needs some special checks to avoid common
15
- # pitfalls of `dev-utils` itself.
15
+ # pitfalls of `dev-context-only- utils` itself.
16
16
#
17
- # Firstly, detect any misuse of dev-utils as normal/build dependencies.
18
- # Also, allow some exceptions for special purpose crates. This white-listing
19
- # mechanism can be used for core-development-oriented crates like bench bins.
17
+ # Firstly, detect any misuse of dev-context-only-utils as normal/build
18
+ # dependencies. Also, allow some exceptions for special purpose crates. This
19
+ # white-listing mechanism can be used for core-development-oriented crates like
20
+ # bench bins.
20
21
#
21
- # Put differently, use of dev-utils is forbidden for non-dev dependencies in
22
- # general. However, allow its use for non-dev dependencies only if its use
23
- # is confined under a dep. subgraph with all nodes being marked as dev-utils.
22
+ # Put differently, use of dev-context-only-utils is forbidden for non-dev
23
+ # dependencies in general. However, allow its use for non-dev dependencies only
24
+ # if its use is confined under a dep. subgraph with all nodes being marked as
25
+ # dev-context-only-utils.
24
26
25
- # Add your troubled package which seems to want to use `dev-utils` as normal (not
26
- # dev) dependencies, only if you're sure that there's good reason to bend
27
- # dev-util's original intention and that listed package isn't part of released
28
- # binaries.
29
- declare -r dev_utils_feature=" dev-utils"
30
- declare dev_util_tainted_packages=(
27
+ # Add your troubled package which seems to want to use `dev-context-only-utils`
28
+ # as normal (not dev) dependencies, only if you're sure that there's good
29
+ # reason to bend dev-context-only-utils's original intention and that listed
30
+ # package isn't part of released binaries.
31
+ declare tainted_packages=(
31
32
)
32
33
33
34
# convert to comma separeted (ref: https://stackoverflow.com/a/53839433)
34
- printf -v allowed ' "%s",' " ${dev_util_tainted_packages [@]} "
35
+ printf -v allowed ' "%s",' " ${tainted_packages [@]} "
35
36
allowed=" ${allowed% ,} "
36
37
37
38
mode=${1:- full}
@@ -60,7 +61,7 @@ if [[ $mode = "tree" || $mode = "full" ]]; then
60
61
| flatten
61
62
| map(select(
62
63
(.dependencyFeatures
63
- | index("${dev_utils_feature} ")
64
+ | index("dev-context-only-utils ")
64
65
) and (.crate as \$ needle
65
66
| ([$allowed ] | index(\$ needle))
66
67
| not
@@ -71,10 +72,11 @@ if [[ $mode = "tree" || $mode = "full" ]]; then
71
72
EOF
72
73
)
73
74
74
- abusers=" $( _ cargo " +${rust_nightly} " metadata --format-version=1 | jq -r " $query " ) "
75
+ abusers=" $( _ cargo " +${rust_nightly} " metadata --format-version=1 |
76
+ jq -r " $query " ) "
75
77
if [[ -n " $abusers " ]]; then
76
78
cat << EOF 1>&2
77
- ${dev_utils_feature} must not be used as normal dependencies, but is by \
79
+ \` dev-context-only-utils\' must not be used as normal dependencies, but is by \
78
80
"([crate]: [dependency])":
79
81
$abusers
80
82
EOF
106
108
end)
107
109
| flatten
108
110
| map(select(
109
- (.crateFeatures | index("${dev_utils_feature} ")) | not
111
+ (.crateFeatures | index("dev-context-only-utils ")) | not
110
112
))
111
113
| map(.crate)
112
114
| join("\n ")
@@ -121,25 +123,27 @@ EOF
121
123
if [[ -n " $misconfigured_crates " ]]; then
122
124
cat << EOF 1>&2
123
125
All crates marked \` tainted\` , as well as their dependents, MUST declare the \
124
- \` $dev_utils_feature \` . The following crates are in violation:
126
+ \` dev-context-only-utils \` . The following crates are in violation:
125
127
$misconfigured_crates
126
128
EOF
127
129
exit 1
128
130
fi
129
131
fi
130
132
131
- # Detect possible compilation errors of problematic usage of `dev-utils`-gated code
132
- # without being explicitly declared as such in respective workspace member
133
- # `Cargo.toml`s. This cannot be detected with `--workspace --all-targets`, due
134
- # to unintentional `dev-utils` feature activation by cargo's feature
135
- # unification mechanism.
136
- # So, we use `cargo hack` to exhaustively build each individual workspace
137
- # members in isolation to work around.
133
+ # Detect possible compilation errors of problematic usage of
134
+ # `dev-context-only-utils`-gated code without being explicitly declared as such
135
+ # in respective workspace member `Cargo.toml`s. This cannot be detected with
136
+ # `--workspace --all-targets`, due to unintentional `dev-context-only- utils`
137
+ # feature activation by cargo's feature unification mechanism. So, we use
138
+ # `cargo hack` to exhaustively build each individual workspace members in
139
+ # isolation to work around.
138
140
#
139
- # 1. Check implicit usage of `dev-utils`-gated code in non-dev (= production) code by
140
- # building without dev dependencies (= tests/benches) for each crate
141
- # 2. Check implicit usage of `dev-utils`-gated code in dev (= test/benches) code by
142
- # building in isolation from other crates, which might happen to enable `dev-utils`
141
+ # 1. Check implicit usage of `dev-context-only-utils`-gated code in non-dev (=
142
+ # production) code by building without dev dependencies (= tests/benches) for
143
+ # each crate
144
+ # 2. Check implicit usage of `dev-context-only-utils`-gated code in dev (=
145
+ # test/benches) code by building in isolation from other crates, which might
146
+ # happen to enable `dev-context-only-utils`
143
147
if [[ $mode = " check-bins" || $mode = " full" ]]; then
144
148
_ cargo " +${rust_nightly} " hack check --bins
145
149
fi
0 commit comments