File tree Expand file tree Collapse file tree 5 files changed +40
-2
lines changed
compiler/rustc_passes/src Expand file tree Collapse file tree 5 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -303,6 +303,16 @@ impl CheckAttrVisitor<'tcx> {
303303 . emit ( ) ;
304304 return false ;
305305 }
306+ if doc_alias. starts_with ( ' ' ) || doc_alias. ends_with ( ' ' ) {
307+ self . tcx
308+ . sess
309+ . struct_span_err (
310+ meta. span ( ) ,
311+ "`#[doc(alias = \" ...\" )]` cannot start or end with ' '" ,
312+ )
313+ . emit ( ) ;
314+ return false ;
315+ }
306316 if let Some ( err) = match target {
307317 Target :: Impl => Some ( "implementation block" ) ,
308318 Target :: ForeignMod => Some ( "extern block" ) ,
Original file line number Diff line number Diff line change @@ -12,4 +12,6 @@ pub struct Bar;
1212#[ doc( alias = "
1313" ) ] //~^ ERROR
1414#[ doc( alias = "\t " ) ] //~ ERROR
15+ #[ doc( alias = " hello" ) ] //~ ERROR
16+ #[ doc( alias = "hello " ) ] //~ ERROR
1517pub struct Foo ;
Original file line number Diff line number Diff line change @@ -42,5 +42,17 @@ error: '\t' character isn't allowed in `#[doc(alias = "...")]`
4242LL | #[doc(alias = "\t")]
4343 | ^^^^^^^^^^^^
4444
45- error: aborting due to 7 previous errors
45+ error: `#[doc(alias = "...")]` cannot start or end with ' '
46+ --> $DIR/check-doc-alias-attr.rs:15:7
47+ |
48+ LL | #[doc(alias = " hello")]
49+ | ^^^^^^^^^^^^^^^^
50+
51+ error: `#[doc(alias = "...")]` cannot start or end with ' '
52+ --> $DIR/check-doc-alias-attr.rs:16:7
53+ |
54+ LL | #[doc(alias = "hello ")]
55+ | ^^^^^^^^^^^^^^^^
56+
57+ error: aborting due to 9 previous errors
4658
Original file line number Diff line number Diff line change @@ -12,4 +12,6 @@ pub struct Bar;
1212#[ doc( alias = "
1313" ) ] //~^ ERROR
1414#[ doc( alias = "\t " ) ] //~ ERROR
15+ #[ doc( alias = " hello" ) ] //~ ERROR
16+ #[ doc( alias = "hello " ) ] //~ ERROR
1517pub struct Foo ;
Original file line number Diff line number Diff line change @@ -42,5 +42,17 @@ error: '\t' character isn't allowed in `#[doc(alias = "...")]`
4242LL | #[doc(alias = "\t")]
4343 | ^^^^^^^^^^^^
4444
45- error: aborting due to 7 previous errors
45+ error: `#[doc(alias = "...")]` cannot start or end with ' '
46+ --> $DIR/check-doc-alias-attr.rs:15:7
47+ |
48+ LL | #[doc(alias = " hello")]
49+ | ^^^^^^^^^^^^^^^^
50+
51+ error: `#[doc(alias = "...")]` cannot start or end with ' '
52+ --> $DIR/check-doc-alias-attr.rs:16:7
53+ |
54+ LL | #[doc(alias = "hello ")]
55+ | ^^^^^^^^^^^^^^^^
56+
57+ error: aborting due to 9 previous errors
4658
You can’t perform that action at this time.
0 commit comments