Skip to content

Commit

Permalink
Auto merge of #87836 - tsoutsman:master, r=petrochenkov
Browse files Browse the repository at this point in the history
Change proc_macro::Diagnostics docs

With Rust 1.54 attributes can invoke function-like macros. This allows functions generated by macros to have non-generic documentation. This pull request changes the documentation of `proc_macro::Diagnostics` to be more specific and include a link to the level.
## Example
Before:
```markdown
Adds a new child diagnostic message to `self` with the level
identified by this method’s name with the given `message`.
```
After:
```markdown
Adds a new child diagnostic message to self with the [`Level::Error`]
level, and the given `message`.
```
  • Loading branch information
bors committed Aug 8, 2021
2 parents c4c2986 + 26bf0ef commit e8c25f2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions library/proc_macro/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ pub struct Diagnostic {

macro_rules! diagnostic_child_methods {
($spanned:ident, $regular:ident, $level:expr) => {
/// Adds a new child diagnostic message to `self` with the level
/// identified by this method's name with the given `spans` and
/// `message`.
#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
#[doc = concat!("Adds a new child diagnostics message to `self` with the [`",
stringify!($level), "`] level, and the given `spans` and `message`.")]
pub fn $spanned<S, T>(mut self, spans: S, message: T) -> Diagnostic
where
S: MultiSpan,
Expand All @@ -69,9 +68,9 @@ macro_rules! diagnostic_child_methods {
self
}

/// Adds a new child diagnostic message to `self` with the level
/// identified by this method's name with the given `message`.
#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
#[doc = concat!("Adds a new child diagnostic message to `self` with the [`",
stringify!($level), "`] level, and the given `message`.")]
pub fn $regular<T: Into<String>>(mut self, message: T) -> Diagnostic {
self.children.push(Diagnostic::new($level, message));
self
Expand Down

0 comments on commit e8c25f2

Please sign in to comment.