Skip to content

Commit

Permalink
Descriptive variant name deprecation versions outside the standard li…
Browse files Browse the repository at this point in the history
…brary
  • Loading branch information
dtolnay committed Oct 31, 2023
1 parent e8868af commit dccf10e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
}
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_middle/src/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}")
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/json/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()) }
Expand Down

0 comments on commit dccf10e

Please sign in to comment.