Preserve deprecation attribute even if 'since' version is missing

This commit is contained in:
David Tolnay 2023-10-30 15:44:09 -07:00
parent b106167673
commit c52367276d
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
3 changed files with 14 additions and 6 deletions

View File

@ -876,10 +876,10 @@ pub fn find_deprecation(
sess.emit_err(session_diagnostics::InvalidSince { span: attr.span }); sess.emit_err(session_diagnostics::InvalidSince { span: attr.span });
Some(DeprecatedSince::Err) Some(DeprecatedSince::Err)
} }
} else if is_rustc {
sess.emit_err(session_diagnostics::MissingSince { span: attr.span });
continue;
} else { } else {
if is_rustc {
sess.emit_err(session_diagnostics::MissingSince { span: attr.span });
}
None None
}; };

View File

@ -19,6 +19,7 @@ fn f4() { }
#[stable(feature = "a", since = "3.3.3")] #[stable(feature = "a", since = "3.3.3")]
#[deprecated] //~ ERROR missing 'since' #[deprecated] //~ ERROR missing 'since'
//~^ ERROR missing 'note'
fn f5() { } fn f5() { }
#[stable(feature = "a", since = "3.3.3")] #[stable(feature = "a", since = "3.3.3")]

View File

@ -28,12 +28,19 @@ error[E0542]: missing 'since'
LL | #[deprecated] LL | #[deprecated]
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error[E0543]: missing 'note'
--> $DIR/stability-attribute-sanity-4.rs:21:5
|
LL | #[deprecated]
| ^^^^^^^^^^^^^
error[E0542]: missing 'since' error[E0542]: missing 'since'
--> $DIR/stability-attribute-sanity-4.rs:25:5 --> $DIR/stability-attribute-sanity-4.rs:26:5
| |
LL | #[deprecated = "a"] 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`.