File tree 5 files changed +40
-2
lines changed
compiler/rustc_passes/src
5 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -303,6 +303,16 @@ impl CheckAttrVisitor<'tcx> {
303
303
. emit ( ) ;
304
304
return false ;
305
305
}
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
+ }
306
316
if let Some ( err) = match target {
307
317
Target :: Impl => Some ( "implementation block" ) ,
308
318
Target :: ForeignMod => Some ( "extern block" ) ,
Original file line number Diff line number Diff line change @@ -12,4 +12,6 @@ pub struct Bar;
12
12
#[ doc( alias = "
13
13
" ) ] //~^ ERROR
14
14
#[ doc( alias = "\t " ) ] //~ ERROR
15
+ #[ doc( alias = " hello" ) ] //~ ERROR
16
+ #[ doc( alias = "hello " ) ] //~ ERROR
15
17
pub 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 = "...")]`
42
42
LL | #[doc(alias = "\t")]
43
43
| ^^^^^^^^^^^^
44
44
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
46
58
Original file line number Diff line number Diff line change @@ -12,4 +12,6 @@ pub struct Bar;
12
12
#[ doc( alias = "
13
13
" ) ] //~^ ERROR
14
14
#[ doc( alias = "\t " ) ] //~ ERROR
15
+ #[ doc( alias = " hello" ) ] //~ ERROR
16
+ #[ doc( alias = "hello " ) ] //~ ERROR
15
17
pub 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 = "...")]`
42
42
LL | #[doc(alias = "\t")]
43
43
| ^^^^^^^^^^^^
44
44
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
46
58
You can’t perform that action at this time.
0 commit comments