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
// Example use of the library that will safely work.
1188
+
1189
+
fn main() {
1190
+
updated_crate::foo(); // Warning: use of deprecated function
1191
+
}
1192
+
```
1193
+
1194
+
Beware that it may be possible for this to technically cause a project to fail if they have explicitly denied the warning, and the updated crate is a direct dependency.
1195
+
Denying warnings should be done with care and the understanding that new lints may be introduced over time.
1196
+
However, library authors should be cautious about introducing new warnings and may want to consider the potential impact on their users.
1197
+
1198
+
The following lints are examples of those that may be introduced when updating a dependency:
1199
+
1200
+
*[`deprecated`][deprecated-lint] — Introduced when a dependency adds the [`#[deprecated]` attribute][deprecated] to an item you are using.
1201
+
*[`unused_must_use`] — Introduced when a dependency adds the [`#[must_use]` attribute][must-use-attr] to an item where you are not consuming the result.
1202
+
*[`unused_unsafe`] — Introduced when a dependency *removes* the `unsafe` qualifier from a function, and that is the only unsafe function called in an unsafe block.
1203
+
1204
+
Additionally, updating `rustc` to a new version may introduce new lints.
1205
+
1206
+
Transitive dependencies which introduce new lints should not usually cause a failure because Cargo uses [`--cap-lints`](../../rustc/lints/levels.html#capping-lints) to suppress all lints in dependencies.
1207
+
1208
+
Mitigating strategies:
1209
+
* If you build with warnings denied, understand you may need to deal with resolving new warnings whenever you update your dependencies.
1210
+
If using RUSTFLAGS to pass `-Dwarnings`, also add the `-A` flag to allow lints that are likely to cause issues, such as `-Adeprecated`.
1211
+
* Introduce deprecations behind a [feature][Cargo features].
1212
+
For example `#[cfg_attr(feature = "deprecated", deprecated="use bar instead")]`.
1213
+
Then, when you plan to remove an item in a future SemVer breaking change, you can communicate with your users that they should enable the `deprecated` feature *before* updating to remove the use of the deprecated items.
1214
+
This allows users to choose when to respond to deprecations without needing to immediately respond to them.
1215
+
A downside is that it can be difficult to communicate to users that they need to take these manual steps to prepare for a major update.
0 commit comments