diff options
| author | David Tolnay <dtolnay@gmail.com> | 2023-10-30 09:00:13 -0700 |
|---|---|---|
| committer | David Tolnay <dtolnay@gmail.com> | 2023-10-30 09:02:32 -0700 |
| commit | 1e10fe9eb67fabb97729c3faf4852121f1f608da (patch) | |
| tree | 604c3c46447c05249f905a5feb9be5105a9d680e /compiler/rustc_attr/src | |
| parent | 8afb40b3a8083ebb73204cac12a057fea531dacc (diff) | |
| download | rust-1e10fe9eb67fabb97729c3faf4852121f1f608da.tar.gz rust-1e10fe9eb67fabb97729c3faf4852121f1f608da.zip | |
Move deprecation_in_effect to inherent method on Deprecation
Diffstat (limited to 'compiler/rustc_attr/src')
| -rw-r--r-- | compiler/rustc_attr/src/builtin.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index 62709ef4db9..49c6b84a4a5 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -744,6 +744,22 @@ pub enum DeprecatedSince { Symbol(Symbol), } +impl Deprecation { + /// Whether an item marked with #[deprecated(since = "X")] is currently + /// deprecated (i.e., whether X is not greater than the current rustc + /// version). + pub fn is_in_effect(&self) -> bool { + match self.since { + Some(DeprecatedSince::RustcVersion(since)) => since <= RustcVersion::CURRENT, + Some(DeprecatedSince::Future) => false, + // The `since` field doesn't have semantic purpose without `#![staged_api]`. + Some(DeprecatedSince::Symbol(_)) => true, + // Assume deprecation is in effect if "since" field is missing. + None => true, + } + } +} + impl Display for DeprecatedSince { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { match self { |
