From a215151cd357945acdb2675010708cb2d10bb4c0 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 Oct 2020 14:00:00 +0200 Subject: [PATCH] Allow ascii whitespace char for doc aliases --- compiler/rustc_passes/src/check_attr.rs | 5 +++-- src/test/rustdoc-ui/check-doc-alias-attr.rs | 1 - src/test/rustdoc-ui/check-doc-alias-attr.stderr | 10 ++-------- src/test/ui/check-doc-alias-attr.rs | 1 - src/test/ui/check-doc-alias-attr.stderr | 10 ++-------- 5 files changed, 7 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 59955b27334..e8e54c3cfaa 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -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 diff --git a/src/test/rustdoc-ui/check-doc-alias-attr.rs b/src/test/rustdoc-ui/check-doc-alias-attr.rs index c8bec39fad6..d55be9f120c 100644 --- a/src/test/rustdoc-ui/check-doc-alias-attr.rs +++ b/src/test/rustdoc-ui/check-doc-alias-attr.rs @@ -11,6 +11,5 @@ pub struct Bar; #[doc(alias = "\n")] //~ ERROR #[doc(alias = " ")] //~^ ERROR -#[doc(alias = " ")] //~ ERROR #[doc(alias = "\t")] //~ ERROR pub struct Foo; diff --git a/src/test/rustdoc-ui/check-doc-alias-attr.stderr b/src/test/rustdoc-ui/check-doc-alias-attr.stderr index be7d7b3dbea..97444c69ff1 100644 --- a/src/test/rustdoc-ui/check-doc-alias-attr.stderr +++ b/src/test/rustdoc-ui/check-doc-alias-attr.stderr @@ -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 diff --git a/src/test/ui/check-doc-alias-attr.rs b/src/test/ui/check-doc-alias-attr.rs index c8bec39fad6..d55be9f120c 100644 --- a/src/test/ui/check-doc-alias-attr.rs +++ b/src/test/ui/check-doc-alias-attr.rs @@ -11,6 +11,5 @@ pub struct Bar; #[doc(alias = "\n")] //~ ERROR #[doc(alias = " ")] //~^ ERROR -#[doc(alias = " ")] //~ ERROR #[doc(alias = "\t")] //~ ERROR pub struct Foo; diff --git a/src/test/ui/check-doc-alias-attr.stderr b/src/test/ui/check-doc-alias-attr.stderr index be7d7b3dbea..97444c69ff1 100644 --- a/src/test/ui/check-doc-alias-attr.stderr +++ b/src/test/ui/check-doc-alias-attr.stderr @@ -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