Improve some attributes error spans
This commit is contained in:
parent
7df0052df8
commit
63816da5ed
6 changed files with 33 additions and 31 deletions
|
@ -182,7 +182,9 @@ impl Attribute {
|
||||||
|
|
||||||
pub fn name_value_literal_span(&self) -> Option<Span> {
|
pub fn name_value_literal_span(&self) -> Option<Span> {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
AttrKind::Normal(ref item, _) => item.meta(self.span).and_then(|meta| meta.name_value_literal_span()),
|
AttrKind::Normal(ref item, _) => {
|
||||||
|
item.meta(self.span).and_then(|meta| meta.name_value_literal_span())
|
||||||
|
}
|
||||||
AttrKind::DocComment(..) => None,
|
AttrKind::DocComment(..) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,7 +319,7 @@ impl CheckAttrVisitor<'tcx> {
|
||||||
self.tcx
|
self.tcx
|
||||||
.sess
|
.sess
|
||||||
.struct_span_err(
|
.struct_span_err(
|
||||||
meta.span(),
|
meta.name_value_literal_span().unwrap_or_else(|| meta.span()),
|
||||||
&format!(
|
&format!(
|
||||||
"{:?} character isn't allowed in `#[doc(alias = \"...\")]`",
|
"{:?} character isn't allowed in `#[doc(alias = \"...\")]`",
|
||||||
c,
|
c,
|
||||||
|
@ -332,7 +332,7 @@ impl CheckAttrVisitor<'tcx> {
|
||||||
self.tcx
|
self.tcx
|
||||||
.sess
|
.sess
|
||||||
.struct_span_err(
|
.struct_span_err(
|
||||||
meta.span(),
|
meta.name_value_literal_span().unwrap_or_else(|| meta.span()),
|
||||||
"`#[doc(alias = \"...\")]` cannot start or end with ' '",
|
"`#[doc(alias = \"...\")]` cannot start or end with ' '",
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
|
|
|
@ -17,42 +17,42 @@ LL | #[doc(alias("bar"))]
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
|
||||||
error: '\"' character isn't allowed in `#[doc(alias = "...")]`
|
error: '\"' character isn't allowed in `#[doc(alias = "...")]`
|
||||||
--> $DIR/check-doc-alias-attr.rs:9:7
|
--> $DIR/check-doc-alias-attr.rs:9:15
|
||||||
|
|
|
|
||||||
LL | #[doc(alias = "\"")]
|
LL | #[doc(alias = "\"")]
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^
|
||||||
|
|
||||||
error: '\n' character isn't allowed in `#[doc(alias = "...")]`
|
error: '\n' character isn't allowed in `#[doc(alias = "...")]`
|
||||||
--> $DIR/check-doc-alias-attr.rs:10:7
|
--> $DIR/check-doc-alias-attr.rs:10:15
|
||||||
|
|
|
|
||||||
LL | #[doc(alias = "\n")]
|
LL | #[doc(alias = "\n")]
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^
|
||||||
|
|
||||||
error: '\n' character isn't allowed in `#[doc(alias = "...")]`
|
error: '\n' character isn't allowed in `#[doc(alias = "...")]`
|
||||||
--> $DIR/check-doc-alias-attr.rs:11:7
|
--> $DIR/check-doc-alias-attr.rs:11:15
|
||||||
|
|
|
|
||||||
LL | #[doc(alias = "
|
LL | #[doc(alias = "
|
||||||
| _______^
|
| _______________^
|
||||||
LL | | ")]
|
LL | | ")]
|
||||||
| |_^
|
| |_^
|
||||||
|
|
||||||
error: '\t' character isn't allowed in `#[doc(alias = "...")]`
|
error: '\t' character isn't allowed in `#[doc(alias = "...")]`
|
||||||
--> $DIR/check-doc-alias-attr.rs:13:7
|
--> $DIR/check-doc-alias-attr.rs:13:15
|
||||||
|
|
|
|
||||||
LL | #[doc(alias = "\t")]
|
LL | #[doc(alias = "\t")]
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^
|
||||||
|
|
||||||
error: `#[doc(alias = "...")]` cannot start or end with ' '
|
error: `#[doc(alias = "...")]` cannot start or end with ' '
|
||||||
--> $DIR/check-doc-alias-attr.rs:14:7
|
--> $DIR/check-doc-alias-attr.rs:14:15
|
||||||
|
|
|
|
||||||
LL | #[doc(alias = " hello")]
|
LL | #[doc(alias = " hello")]
|
||||||
| ^^^^^^^^^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
||||||
error: `#[doc(alias = "...")]` cannot start or end with ' '
|
error: `#[doc(alias = "...")]` cannot start or end with ' '
|
||||||
--> $DIR/check-doc-alias-attr.rs:15:7
|
--> $DIR/check-doc-alias-attr.rs:15:15
|
||||||
|
|
|
|
||||||
LL | #[doc(alias = "hello ")]
|
LL | #[doc(alias = "hello ")]
|
||||||
| ^^^^^^^^^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 9 previous errors
|
error: aborting due to 9 previous errors
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: '\'' character isn't allowed in `#[doc(alias = "...")]`
|
error: '\'' character isn't allowed in `#[doc(alias = "...")]`
|
||||||
--> $DIR/doc-alias-crate-level.rs:5:7
|
--> $DIR/doc-alias-crate-level.rs:5:15
|
||||||
|
|
|
|
||||||
LL | #[doc(alias = "shouldn't work!")]
|
LL | #[doc(alias = "shouldn't work!")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: `#![doc(alias = "...")]` isn't allowed as a crate level attribute
|
error: `#![doc(alias = "...")]` isn't allowed as a crate level attribute
|
||||||
--> $DIR/doc-alias-crate-level.rs:3:8
|
--> $DIR/doc-alias-crate-level.rs:3:8
|
||||||
|
|
|
@ -17,42 +17,42 @@ LL | #[doc(alias("bar"))]
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
|
||||||
error: '\"' character isn't allowed in `#[doc(alias = "...")]`
|
error: '\"' character isn't allowed in `#[doc(alias = "...")]`
|
||||||
--> $DIR/check-doc-alias-attr.rs:10:7
|
--> $DIR/check-doc-alias-attr.rs:10:15
|
||||||
|
|
|
|
||||||
LL | #[doc(alias = "\"")]
|
LL | #[doc(alias = "\"")]
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^
|
||||||
|
|
||||||
error: '\n' character isn't allowed in `#[doc(alias = "...")]`
|
error: '\n' character isn't allowed in `#[doc(alias = "...")]`
|
||||||
--> $DIR/check-doc-alias-attr.rs:11:7
|
--> $DIR/check-doc-alias-attr.rs:11:15
|
||||||
|
|
|
|
||||||
LL | #[doc(alias = "\n")]
|
LL | #[doc(alias = "\n")]
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^
|
||||||
|
|
||||||
error: '\n' character isn't allowed in `#[doc(alias = "...")]`
|
error: '\n' character isn't allowed in `#[doc(alias = "...")]`
|
||||||
--> $DIR/check-doc-alias-attr.rs:12:7
|
--> $DIR/check-doc-alias-attr.rs:12:15
|
||||||
|
|
|
|
||||||
LL | #[doc(alias = "
|
LL | #[doc(alias = "
|
||||||
| _______^
|
| _______________^
|
||||||
LL | | ")]
|
LL | | ")]
|
||||||
| |_^
|
| |_^
|
||||||
|
|
||||||
error: '\t' character isn't allowed in `#[doc(alias = "...")]`
|
error: '\t' character isn't allowed in `#[doc(alias = "...")]`
|
||||||
--> $DIR/check-doc-alias-attr.rs:14:7
|
--> $DIR/check-doc-alias-attr.rs:14:15
|
||||||
|
|
|
|
||||||
LL | #[doc(alias = "\t")]
|
LL | #[doc(alias = "\t")]
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^
|
||||||
|
|
||||||
error: `#[doc(alias = "...")]` cannot start or end with ' '
|
error: `#[doc(alias = "...")]` cannot start or end with ' '
|
||||||
--> $DIR/check-doc-alias-attr.rs:15:7
|
--> $DIR/check-doc-alias-attr.rs:15:15
|
||||||
|
|
|
|
||||||
LL | #[doc(alias = " hello")]
|
LL | #[doc(alias = " hello")]
|
||||||
| ^^^^^^^^^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
||||||
error: `#[doc(alias = "...")]` cannot start or end with ' '
|
error: `#[doc(alias = "...")]` cannot start or end with ' '
|
||||||
--> $DIR/check-doc-alias-attr.rs:16:7
|
--> $DIR/check-doc-alias-attr.rs:16:15
|
||||||
|
|
|
|
||||||
LL | #[doc(alias = "hello ")]
|
LL | #[doc(alias = "hello ")]
|
||||||
| ^^^^^^^^^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 9 previous errors
|
error: aborting due to 9 previous errors
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: '\'' character isn't allowed in `#[doc(alias = "...")]`
|
error: '\'' character isn't allowed in `#[doc(alias = "...")]`
|
||||||
--> $DIR/doc-alias-crate-level.rs:7:8
|
--> $DIR/doc-alias-crate-level.rs:7:16
|
||||||
|
|
|
|
||||||
LL | #![doc(alias = "shouldn't work!")]
|
LL | #![doc(alias = "shouldn't work!")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue