You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clarify warning for using features or default-features in patch
When attempting to substitute a local version of a dependency, since the
`patch` section uses syntax similar to a dependency (and the
documentation even says "The syntax is similar to the `[dependencies]`
section", it's natural to assume that other things from `[dependencies]`
also work, such as `features` or `default-features`. Attempting to use
them produces this warning:
> patch for `crate-name-here` uses the features mechanism.
> default-features and features will not take effect because the patch dependency does not support this mechanism
The phrasing "the patch dependency does not support this mechanism"
makes it seem at first glance like `patch` just doesn't support this at
all. But the actual problem is that the user needs to move the
`features`/`default-features` keys to an entry in `dependencies`
instead.
Modify the message, to make this more obvious.
Modify the corresponding warning for `replace` as well.
Update tests accordingly.
[WARNING] patch for `bar` uses the features mechanism. default-features and features will not take effect because the patch dependency does not support this mechanism
931
+
p.cargo("check")
932
+
.with_stderr_data(str![[r#"
933
+
[WARNING] unused field in patch for `bar`: `features`
934
+
[NOTE] configure `features` in the `dependencies` entry
933
935
[UPDATING] `dummy-registry` index
934
936
[LOCKING] 1 package to latest compatible version
935
937
[CHECKING] bar v0.1.0 ([ROOT]/foo/bar)
936
938
[CHECKING] foo v0.0.1 ([ROOT]/foo)
937
939
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
938
940
939
-
"#]]).run();
940
-
p.cargo("check").with_stderr_data(str![[r#"
941
-
[WARNING] patch for `bar` uses the features mechanism. default-features and features will not take effect because the patch dependency does not support this mechanism
941
+
"#]])
942
+
.run();
943
+
p.cargo("check")
944
+
.with_stderr_data(str![[r#"
945
+
[WARNING] unused field in patch for `bar`: `features`
946
+
[NOTE] configure `features` in the `dependencies` entry
942
947
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[WARNING] patch for `bar` uses the features mechanism. default-features and features will not take effect because the patch dependency does not support this mechanism
979
+
p.cargo("check")
980
+
.with_stderr_data(str![[r#"
981
+
[WARNING] unused field in patch for `bar`: `features`, `default-features`
982
+
[NOTE] configure `features`, `default-features` in the `dependencies` entry
975
983
[UPDATING] `dummy-registry` index
976
984
[LOCKING] 1 package to latest compatible version
977
985
[CHECKING] bar v0.1.0 ([ROOT]/foo/bar)
978
986
[CHECKING] foo v0.0.1 ([ROOT]/foo)
979
987
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
980
988
981
-
"#]]).run();
982
-
p.cargo("check").with_stderr_data(str![[r#"
983
-
[WARNING] patch for `bar` uses the features mechanism. default-features and features will not take effect because the patch dependency does not support this mechanism
989
+
"#]])
990
+
.run();
991
+
p.cargo("check")
992
+
.with_stderr_data(str![[r#"
993
+
[WARNING] unused field in patch for `bar`: `features`, `default-features`
994
+
[NOTE] configure `features`, `default-features` in the `dependencies` entry
984
995
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
Copy file name to clipboardExpand all lines: tests/testsuite/replace.rs
+12-6Lines changed: 12 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -89,16 +89,19 @@ fn override_with_features() {
89
89
)
90
90
.build();
91
91
92
-
p.cargo("check").with_stderr_data(str![[r#"
92
+
p.cargo("check")
93
+
.with_stderr_data(str![[r#"
93
94
[UPDATING] `dummy-registry` index
94
95
[UPDATING] git repository `[ROOTURL]/override`
95
96
[LOCKING] 2 packages to latest compatible versions
96
-
[WARNING] replacement for `bar` uses the features mechanism. default-features and features will not take effect because the replacement dependency does not support this mechanism
97
+
[WARNING] unused field in replacement for `bar`: `features`
98
+
[NOTE] configure `features` in the `dependencies` entry
97
99
[CHECKING] bar v0.1.0 ([ROOTURL]/override#[..])
98
100
[CHECKING] foo v0.0.1 ([ROOT]/foo)
99
101
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[LOCKING] 2 packages to latest compatible versions
143
-
[WARNING] replacement for `bar` uses the features mechanism. default-features and features will not take effect because the replacement dependency does not support this mechanism
147
+
[WARNING] unused field in replacement for `bar`: `features`, `default-features`
148
+
[NOTE] configure `features`, `default-features` in the `dependencies` entry
144
149
[CHECKING] bar v0.1.0 ([ROOTURL]/override#[..])
145
150
[CHECKING] foo v0.0.1 ([ROOT]/foo)
146
151
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
0 commit comments