@@ -405,7 +405,9 @@ fn check_split_args() {
405
405
406
406
#[ test]
407
407
fn comment_in_attrs ( ) {
408
- // if input already has a fn main, it should insert a space before it
408
+ // If there is an inline code comment after attributes, we need to ensure that
409
+ // a backline will be added to prevent generating code "inside" it (and thus generating)
410
+ // invalid code.
409
411
let opts = default_global_opts ( "" ) ;
410
412
let input = "\
411
413
#![feature(rustdoc_internals)]
@@ -424,4 +426,24 @@ fn main() {
424
426
. to_string ( ) ;
425
427
let ( output, len) = make_test ( input, None , false , & opts, None ) ;
426
428
assert_eq ! ( ( output, len) , ( expected, 2 ) ) ;
429
+
430
+ // And same, if there is a `main` function provided by the user, we ensure that it's
431
+ // correctly separated.
432
+ let input = "\
433
+ #![feature(rustdoc_internals)]
434
+ #![allow(internal_features)]
435
+ #![doc(rust_logo)]
436
+ //! This crate has the Rust(tm) branding on it.
437
+ fn main() {}" ;
438
+ let expected = "\
439
+ #![allow(unused)]
440
+ #![feature(rustdoc_internals)]
441
+ #![allow(internal_features)]
442
+ #![doc(rust_logo)]
443
+ //! This crate has the Rust(tm) branding on it.
444
+
445
+ fn main() {}"
446
+ . to_string ( ) ;
447
+ let ( output, len) = make_test ( input, None , false , & opts, None ) ;
448
+ assert_eq ! ( ( output, len) , ( expected, 1 ) ) ;
427
449
}
0 commit comments