From c52367276d01e15c5154ef4001017b73f0eb7cde Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 30 Oct 2023 15:44:09 -0700 Subject: [PATCH] Preserve deprecation attribute even if 'since' version is missing --- compiler/rustc_attr/src/builtin.rs | 6 +++--- .../stability-attribute-sanity-4.rs | 1 + .../stability-attribute-sanity-4.stderr | 13 ++++++++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index 8ffd322b93f..a9466d7df9d 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -876,10 +876,10 @@ pub fn find_deprecation( sess.emit_err(session_diagnostics::InvalidSince { span: attr.span }); Some(DeprecatedSince::Err) } - } else if is_rustc { - sess.emit_err(session_diagnostics::MissingSince { span: attr.span }); - continue; } else { + if is_rustc { + sess.emit_err(session_diagnostics::MissingSince { span: attr.span }); + } None }; diff --git a/tests/ui/stability-attribute/stability-attribute-sanity-4.rs b/tests/ui/stability-attribute/stability-attribute-sanity-4.rs index 4fe8e45fd04..01a46d15c8d 100644 --- a/tests/ui/stability-attribute/stability-attribute-sanity-4.rs +++ b/tests/ui/stability-attribute/stability-attribute-sanity-4.rs @@ -19,6 +19,7 @@ fn f4() { } #[stable(feature = "a", since = "3.3.3")] #[deprecated] //~ ERROR missing 'since' + //~^ ERROR missing 'note' fn f5() { } #[stable(feature = "a", since = "3.3.3")] diff --git a/tests/ui/stability-attribute/stability-attribute-sanity-4.stderr b/tests/ui/stability-attribute/stability-attribute-sanity-4.stderr index a76f5be1e3d..8ead943ffe3 100644 --- a/tests/ui/stability-attribute/stability-attribute-sanity-4.stderr +++ b/tests/ui/stability-attribute/stability-attribute-sanity-4.stderr @@ -28,12 +28,19 @@ error[E0542]: missing 'since' LL | #[deprecated] | ^^^^^^^^^^^^^ +error[E0543]: missing 'note' + --> $DIR/stability-attribute-sanity-4.rs:21:5 + | +LL | #[deprecated] + | ^^^^^^^^^^^^^ + error[E0542]: missing 'since' - --> $DIR/stability-attribute-sanity-4.rs:25:5 + --> $DIR/stability-attribute-sanity-4.rs:26:5 | LL | #[deprecated = "a"] | ^^^^^^^^^^^^^^^^^^^ -error: aborting due to 6 previous errors +error: aborting due to 7 previous errors -For more information about this error, try `rustc --explain E0542`. +Some errors have detailed explanations: E0542, E0543. +For more information about an error, try `rustc --explain E0542`.