Add invalid doc comment help message
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use attr::HasAttrs;
|
use attr::HasAttrs;
|
||||||
use feature_gate::{emit_feature_err, EXPLAIN_STMT_ATTR_SYNTAX, Features, get_features, GateIssue};
|
use feature_gate::{feature_err, EXPLAIN_STMT_ATTR_SYNTAX, Features, get_features, GateIssue};
|
||||||
use {fold, attr};
|
use {fold, attr};
|
||||||
use ast;
|
use ast;
|
||||||
use codemap::{Spanned, respan};
|
use codemap::{Spanned, respan};
|
||||||
@@ -157,11 +157,15 @@ impl<'a> StripUnconfigured<'a> {
|
|||||||
// flag the offending attributes
|
// flag the offending attributes
|
||||||
for attr in attrs.iter() {
|
for attr in attrs.iter() {
|
||||||
if !self.features.map(|features| features.stmt_expr_attributes).unwrap_or(true) {
|
if !self.features.map(|features| features.stmt_expr_attributes).unwrap_or(true) {
|
||||||
emit_feature_err(&self.sess,
|
let mut err = feature_err(&self.sess,
|
||||||
"stmt_expr_attributes",
|
"stmt_expr_attributes",
|
||||||
attr.span,
|
attr.span,
|
||||||
GateIssue::Language,
|
GateIssue::Language,
|
||||||
EXPLAIN_STMT_ATTR_SYNTAX);
|
EXPLAIN_STMT_ATTR_SYNTAX);
|
||||||
|
if attr.node.is_sugared_doc {
|
||||||
|
err.help("`///` is for documentation comments. For a plain comment, use `//`.");
|
||||||
|
}
|
||||||
|
err.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ use ast::{self, NodeId, PatKind};
|
|||||||
use attr;
|
use attr;
|
||||||
use codemap::{CodeMap, Spanned};
|
use codemap::{CodeMap, Spanned};
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
use errors::Handler;
|
use errors::{DiagnosticBuilder, Handler};
|
||||||
use visit::{self, FnKind, Visitor};
|
use visit::{self, FnKind, Visitor};
|
||||||
use parse::ParseSess;
|
use parse::ParseSess;
|
||||||
use parse::token::InternedString;
|
use parse::token::InternedString;
|
||||||
@@ -792,6 +792,11 @@ pub enum GateIssue {
|
|||||||
|
|
||||||
pub fn emit_feature_err(sess: &ParseSess, feature: &str, span: Span, issue: GateIssue,
|
pub fn emit_feature_err(sess: &ParseSess, feature: &str, span: Span, issue: GateIssue,
|
||||||
explain: &str) {
|
explain: &str) {
|
||||||
|
feature_err(sess, feature, span, issue, explain).emit();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn feature_err<'a>(sess: &'a ParseSess, feature: &str, span: Span, issue: GateIssue,
|
||||||
|
explain: &str) -> DiagnosticBuilder<'a> {
|
||||||
let diag = &sess.span_diagnostic;
|
let diag = &sess.span_diagnostic;
|
||||||
|
|
||||||
let issue = match issue {
|
let issue = match issue {
|
||||||
@@ -812,7 +817,7 @@ pub fn emit_feature_err(sess: &ParseSess, feature: &str, span: Span, issue: Gate
|
|||||||
feature));
|
feature));
|
||||||
}
|
}
|
||||||
|
|
||||||
err.emit();
|
err
|
||||||
}
|
}
|
||||||
|
|
||||||
const EXPLAIN_BOX_SYNTAX: &'static str =
|
const EXPLAIN_BOX_SYNTAX: &'static str =
|
||||||
|
|||||||
Reference in New Issue
Block a user