From 11f3476c59ee013c017e669676cfaca00a67b3f1 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 6 Oct 2020 14:29:42 +0200 Subject: Enforce whitespace ascii character check for doc alias --- compiler/rustc_passes/src/check_attr.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'compiler/rustc_passes/src') diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index e8e54c3cfaa..1acaa4c6eff 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -303,6 +303,16 @@ impl CheckAttrVisitor<'tcx> { .emit(); 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 { Target::Impl => Some("implementation block"), Target::ForeignMod => Some("extern block"), -- cgit 1.4.1-3-g733a5