Enforce whitespace ascii character check for doc alias
This commit is contained in:
parent
accc26abc0
commit
11f3476c59
5 changed files with 40 additions and 2 deletions
|
@ -303,6 +303,16 @@ impl CheckAttrVisitor<'tcx> {
|
||||||
.emit();
|
.emit();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if doc_alias.starts_with(' ') || doc_alias.ends_with(' ') {
|
||||||
|
self.tcx
|
||||||
|
.sess
|
||||||
|
.struct_span_err(
|
||||||
|
meta.span(),
|
||||||
|
"`#[doc(alias = \"...\")]` cannot start or end with ' '",
|
||||||
|
)
|
||||||
|
.emit();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if let Some(err) = match target {
|
if let Some(err) = match target {
|
||||||
Target::Impl => Some("implementation block"),
|
Target::Impl => Some("implementation block"),
|
||||||
Target::ForeignMod => Some("extern block"),
|
Target::ForeignMod => Some("extern block"),
|
||||||
|
|
|
@ -12,4 +12,6 @@ pub struct Bar;
|
||||||
#[doc(alias = "
|
#[doc(alias = "
|
||||||
")] //~^ ERROR
|
")] //~^ ERROR
|
||||||
#[doc(alias = "\t")] //~ ERROR
|
#[doc(alias = "\t")] //~ ERROR
|
||||||
|
#[doc(alias = " hello")] //~ ERROR
|
||||||
|
#[doc(alias = "hello ")] //~ ERROR
|
||||||
pub struct Foo;
|
pub struct Foo;
|
||||||
|
|
|
@ -42,5 +42,17 @@ error: '\t' character isn't allowed in `#[doc(alias = "...")]`
|
||||||
LL | #[doc(alias = "\t")]
|
LL | #[doc(alias = "\t")]
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 7 previous errors
|
error: `#[doc(alias = "...")]` cannot start or end with ' '
|
||||||
|
--> $DIR/check-doc-alias-attr.rs:15:7
|
||||||
|
|
|
||||||
|
LL | #[doc(alias = " hello")]
|
||||||
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: `#[doc(alias = "...")]` cannot start or end with ' '
|
||||||
|
--> $DIR/check-doc-alias-attr.rs:16:7
|
||||||
|
|
|
||||||
|
LL | #[doc(alias = "hello ")]
|
||||||
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 9 previous errors
|
||||||
|
|
||||||
|
|
|
@ -12,4 +12,6 @@ pub struct Bar;
|
||||||
#[doc(alias = "
|
#[doc(alias = "
|
||||||
")] //~^ ERROR
|
")] //~^ ERROR
|
||||||
#[doc(alias = "\t")] //~ ERROR
|
#[doc(alias = "\t")] //~ ERROR
|
||||||
|
#[doc(alias = " hello")] //~ ERROR
|
||||||
|
#[doc(alias = "hello ")] //~ ERROR
|
||||||
pub struct Foo;
|
pub struct Foo;
|
||||||
|
|
|
@ -42,5 +42,17 @@ error: '\t' character isn't allowed in `#[doc(alias = "...")]`
|
||||||
LL | #[doc(alias = "\t")]
|
LL | #[doc(alias = "\t")]
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 7 previous errors
|
error: `#[doc(alias = "...")]` cannot start or end with ' '
|
||||||
|
--> $DIR/check-doc-alias-attr.rs:15:7
|
||||||
|
|
|
||||||
|
LL | #[doc(alias = " hello")]
|
||||||
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: `#[doc(alias = "...")]` cannot start or end with ' '
|
||||||
|
--> $DIR/check-doc-alias-attr.rs:16:7
|
||||||
|
|
|
||||||
|
LL | #[doc(alias = "hello ")]
|
||||||
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 9 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue