Skip to content

Commit a215151

Browse files
Allow ascii whitespace char for doc aliases
1 parent efbaa41 commit a215151

File tree

5 files changed

+7
-20
lines changed

5 files changed

+7
-20
lines changed

compiler/rustc_passes/src/check_attr.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,9 @@ impl CheckAttrVisitor<'tcx> {
287287
self.doc_alias_str_error(meta);
288288
return false;
289289
}
290-
if let Some(c) =
291-
doc_alias.chars().find(|&c| c == '"' || c == '\'' || c.is_whitespace())
290+
if let Some(c) = doc_alias
291+
.chars()
292+
.find(|&c| c == '"' || c == '\'' || (c.is_whitespace() && c != ' '))
292293
{
293294
self.tcx
294295
.sess

src/test/rustdoc-ui/check-doc-alias-attr.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ pub struct Bar;
1111
#[doc(alias = "\n")] //~ ERROR
1212
#[doc(alias = "
1313
")] //~^ ERROR
14-
#[doc(alias = " ")] //~ ERROR
1514
#[doc(alias = "\t")] //~ ERROR
1615
pub struct Foo;

src/test/rustdoc-ui/check-doc-alias-attr.stderr

+2-8
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,11 @@ LL | #[doc(alias = "
3636
LL | | ")]
3737
| |_^
3838

39-
error: ' ' character isn't allowed in `#[doc(alias = "...")]`
40-
--> $DIR/check-doc-alias-attr.rs:14:7
41-
|
42-
LL | #[doc(alias = " ")]
43-
| ^^^^^^^^^^^
44-
4539
error: '\t' character isn't allowed in `#[doc(alias = "...")]`
46-
--> $DIR/check-doc-alias-attr.rs:15:7
40+
--> $DIR/check-doc-alias-attr.rs:14:7
4741
|
4842
LL | #[doc(alias = "\t")]
4943
| ^^^^^^^^^^^^
5044

51-
error: aborting due to 8 previous errors
45+
error: aborting due to 7 previous errors
5246

src/test/ui/check-doc-alias-attr.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ pub struct Bar;
1111
#[doc(alias = "\n")] //~ ERROR
1212
#[doc(alias = "
1313
")] //~^ ERROR
14-
#[doc(alias = " ")] //~ ERROR
1514
#[doc(alias = "\t")] //~ ERROR
1615
pub struct Foo;

src/test/ui/check-doc-alias-attr.stderr

+2-8
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,11 @@ LL | #[doc(alias = "
3636
LL | | ")]
3737
| |_^
3838

39-
error: ' ' character isn't allowed in `#[doc(alias = "...")]`
40-
--> $DIR/check-doc-alias-attr.rs:14:7
41-
|
42-
LL | #[doc(alias = " ")]
43-
| ^^^^^^^^^^^
44-
4539
error: '\t' character isn't allowed in `#[doc(alias = "...")]`
46-
--> $DIR/check-doc-alias-attr.rs:15:7
40+
--> $DIR/check-doc-alias-attr.rs:14:7
4741
|
4842
LL | #[doc(alias = "\t")]
4943
| ^^^^^^^^^^^^
5044

51-
error: aborting due to 8 previous errors
45+
error: aborting due to 7 previous errors
5246

0 commit comments

Comments
 (0)