Allow ascii whitespace char for doc aliases

This commit is contained in:
Guillaume Gomez 2020-10-05 14:00:00 +02:00
parent efbaa41306
commit a215151cd3
5 changed files with 7 additions and 20 deletions

View File

@ -287,8 +287,9 @@ impl CheckAttrVisitor<'tcx> {
self.doc_alias_str_error(meta);
return false;
}
if let Some(c) =
doc_alias.chars().find(|&c| c == '"' || c == '\'' || c.is_whitespace())
if let Some(c) = doc_alias
.chars()
.find(|&c| c == '"' || c == '\'' || (c.is_whitespace() && c != ' '))
{
self.tcx
.sess

View File

@ -11,6 +11,5 @@ pub struct Bar;
#[doc(alias = "\n")] //~ ERROR
#[doc(alias = "
")] //~^ ERROR
#[doc(alias = " ")] //~ ERROR
#[doc(alias = "\t")] //~ ERROR
pub struct Foo;

View File

@ -36,17 +36,11 @@ LL | #[doc(alias = "
LL | | ")]
| |_^
error: ' ' character isn't allowed in `#[doc(alias = "...")]`
--> $DIR/check-doc-alias-attr.rs:14:7
|
LL | #[doc(alias = " ")]
| ^^^^^^^^^^^
error: '\t' character isn't allowed in `#[doc(alias = "...")]`
--> $DIR/check-doc-alias-attr.rs:15:7
--> $DIR/check-doc-alias-attr.rs:14:7
|
LL | #[doc(alias = "\t")]
| ^^^^^^^^^^^^
error: aborting due to 8 previous errors
error: aborting due to 7 previous errors

View File

@ -11,6 +11,5 @@ pub struct Bar;
#[doc(alias = "\n")] //~ ERROR
#[doc(alias = "
")] //~^ ERROR
#[doc(alias = " ")] //~ ERROR
#[doc(alias = "\t")] //~ ERROR
pub struct Foo;

View File

@ -36,17 +36,11 @@ LL | #[doc(alias = "
LL | | ")]
| |_^
error: ' ' character isn't allowed in `#[doc(alias = "...")]`
--> $DIR/check-doc-alias-attr.rs:14:7
|
LL | #[doc(alias = " ")]
| ^^^^^^^^^^^
error: '\t' character isn't allowed in `#[doc(alias = "...")]`
--> $DIR/check-doc-alias-attr.rs:15:7
--> $DIR/check-doc-alias-attr.rs:14:7
|
LL | #[doc(alias = "\t")]
| ^^^^^^^^^^^^
error: aborting due to 8 previous errors
error: aborting due to 7 previous errors