-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add invalid doc comment help message #36964
Conversation
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
@@ -792,7 +792,7 @@ pub enum GateIssue { | |||
} | |||
|
|||
pub fn emit_feature_err(sess: &ParseSess, feature: &str, span: Span, issue: GateIssue, | |||
explain: &str) { | |||
explain: &str, help_note: Option<&str>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would instead make a version of this function (say, feature_err
) that returns the err
instead of calling err.emit()
, and have this function just do feature_err(...).emit()
. Then the existing callers of this function don't need to change for the None
argument, and the stmt_expr_attributes
one can do let err = feature_err(...); err.help(...); err.emit();
.
@@ -161,7 +161,8 @@ impl<'a> StripUnconfigured<'a> { | |||
"stmt_expr_attributes", | |||
attr.span, | |||
GateIssue::Language, | |||
EXPLAIN_STMT_ATTR_SYNTAX); | |||
EXPLAIN_STMT_ATTR_SYNTAX, | |||
Some("If you just want to comment your code, just use '//'")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say something like
`///` is for documentation comments. For a plain comment, use `//`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this help
trigger for all misplaced attributes? It should only trigger for misplaced doc
attributes.
☔ The latest upstream changes (presumably #36945) made this pull request unmergeable. Please resolve the merge conflicts. |
2da209d
to
aad86c0
Compare
Updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
We now need a reviewer. cc @jonathandturner :p |
attr.span, | ||
GateIssue::Language, | ||
EXPLAIN_STMT_ATTR_SYNTAX) | ||
.help("`///` is for documentation comments. For a plain comment, use `//`.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I forgot to bring this up again.
This help should only be generated for misplaced doc comments, but this will generate it for any misplaced attributes at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@solson - sounds like an interesting point. @GuillaumeGomez ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't think of testing in other cases. Good point! I'll check a bit later.
} | ||
|
||
pub fn feature_err<'a>(sess: &'a ParseSess, feature: &str, span: Span, issue: GateIssue, | ||
explain: &str) -> DiagnosticBuilder<'a> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: indentation is off here
aad86c0
to
93417fa
Compare
Updated. |
@bors r+ rollup |
📌 Commit 93417fa has been approved by |
…athandturner Add invalid doc comment help message Fixes rust-lang#36946. Any opinion on the message?
…athandturner Add invalid doc comment help message Fixes rust-lang#36946. Any opinion on the message?
Fixes #36946.
Any opinion on the message?