Skip to content

Commit

Permalink
Preserve deprecation attribute even if 'since' version is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Oct 30, 2023
1 parent b106167 commit c523672
Show file tree
Hide file tree
Showing 3 changed files with 14 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 @@ -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
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ mod bogus_attribute_types_2 {

#[stable(feature = "a", since = "3.3.3")]
#[deprecated] //~ ERROR missing 'since'
//~^ ERROR missing 'note'
fn f5() { }

#[stable(feature = "a", since = "3.3.3")]
Expand Down
13 changes: 10 additions & 3 deletions tests/ui/stability-attribute/stability-attribute-sanity-4.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

0 comments on commit c523672

Please sign in to comment.