Descriptive variant name deprecation versions outside the standard library

This commit is contained in:
David Tolnay 2023-10-30 16:48:28 -07:00
parent e8868af75b
commit dccf10e989
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
4 changed files with 8 additions and 6 deletions

View file

@ -737,7 +737,7 @@ pub enum DeprecatedSince {
Future,
/// `feature(staged_api)` is off. Deprecation versions outside the standard
/// library are allowed to be arbitrary strings, for better or worse.
Symbol(Symbol),
NonStandard(Symbol),
/// Deprecation version is unspecified but optional.
Unspecified,
/// Failed to parse a deprecation version, or the deprecation version is
@ -754,7 +754,7 @@ impl Deprecation {
DeprecatedSince::RustcVersion(since) => since <= RustcVersion::CURRENT,
DeprecatedSince::Future => false,
// The `since` field doesn't have semantic purpose without `#![staged_api]`.
DeprecatedSince::Symbol(_) => true,
DeprecatedSince::NonStandard(_) => true,
// Assume deprecation is in effect if "since" field is absent or invalid.
DeprecatedSince::Unspecified | DeprecatedSince::Err => true,
}
@ -871,7 +871,7 @@ pub fn find_deprecation(
if since.as_str() == "TBD" {
DeprecatedSince::Future
} else if !is_rustc {
DeprecatedSince::Symbol(since)
DeprecatedSince::NonStandard(since)
} else if let Some(version) = parse_version(since) {
DeprecatedSince::RustcVersion(version)
} else {

View file

@ -162,7 +162,9 @@ fn deprecation_message(
DeprecatedSince::Future => {
format!("use of {kind} `{path}` that will be deprecated in a future Rust version")
}
DeprecatedSince::Symbol(_) | DeprecatedSince::Unspecified | DeprecatedSince::Err => {
DeprecatedSince::NonStandard(_)
| DeprecatedSince::Unspecified
| DeprecatedSince::Err => {
unreachable!("this deprecation is always in effect; {since:?}")
}
}

View file

@ -628,7 +628,7 @@ fn short_item_info(
}
}
DeprecatedSince::Future => String::from("Deprecating in a future Rust version"),
DeprecatedSince::Symbol(since) => {
DeprecatedSince::NonStandard(since) => {
format!("Deprecated since {}", Escape(since.as_str()))
}
DeprecatedSince::Unspecified | DeprecatedSince::Err => String::from("Deprecated"),

View file

@ -143,7 +143,7 @@ pub(crate) fn from_deprecation(deprecation: rustc_attr::Deprecation) -> Deprecat
let since = match since {
DeprecatedSince::RustcVersion(version) => Some(version.to_string()),
DeprecatedSince::Future => Some("TBD".to_owned()),
DeprecatedSince::Symbol(since) => Some(since.to_string()),
DeprecatedSince::NonStandard(since) => Some(since.to_string()),
DeprecatedSince::Unspecified | DeprecatedSince::Err => None,
};
Deprecation { since, note: note.map(|s| s.to_string()) }