@@ -448,133 +448,30 @@ fn main() {}"
448
448
assert_eq ! ( ( output, len) , ( expected, 1 ) ) ;
449
449
}
450
450
451
+ // This test ensures that the only attributes taken into account when we switch between
452
+ // "crate level" content and the rest doesn't include inner attributes span, as it would
453
+ // include part of the item and generate broken code.
451
454
#[ test]
452
- fn comments ( ) {
455
+ fn inner_attributes ( ) {
453
456
let opts = default_global_opts ( "" ) ;
454
- let input = r## "
457
+ let input = r#"
455
458
//! A doc comment that applies to the implicit anonymous module of this crate
456
459
457
460
pub mod outer_module {
458
-
459
- //! - Inner line doc
460
461
//!! - Still an inner line doc (but with a bang at the beginning)
461
-
462
- /*! - Inner block doc */
463
- /*!! - Still an inner block doc (but with a bang at the beginning) */
464
-
465
- // - Only a comment
466
- /// - Outer line doc (exactly 3 slashes)
467
- //// - Only a comment
468
-
469
- /* - Only a comment */
470
- /** - Outer block doc (exactly) 2 asterisks */
471
- /*** - Only a comment */
472
-
473
- pub mod inner_module {}
474
-
475
- pub mod nested_comments {
476
- /* In Rust /* we can /* nest comments */ */ */
477
-
478
- // All three types of block comments can contain or be nested inside
479
- // any other type:
480
-
481
- /* /* */ /** */ /*! */ */
482
- /*! /* */ /** */ /*! */ */
483
- /** /* */ /** */ /*! */ */
484
- pub mod dummy_item {}
485
- }
486
-
487
- pub mod degenerate_cases {
488
- // empty inner line doc
489
- //!
490
-
491
- // empty inner block doc
492
- /*!*/
493
-
494
- // empty line comment
495
- //
496
-
497
- // empty outer line doc
498
- ///
499
-
500
- // empty block comment
501
- /**/
502
-
503
- pub mod dummy_item {}
504
-
505
- // empty 2-asterisk block isn't a doc block, it is a block comment
506
- /***/
507
-
508
- }
509
-
510
- /* The next one isn't allowed because outer doc comments
511
- require an item that will receive the doc */
512
-
513
- /// Where is my item?
514
462
}
515
- "## ;
516
- let expected = "
463
+ "# ;
464
+ let expected = "#![allow(unused)]
465
+
517
466
//! A doc comment that applies to the implicit anonymous module of this crate
518
467
519
- pub mod outer_module {
520
468
521
- //! - Inner line doc
469
+ fn main() {
470
+ pub mod outer_module {
522
471
//!! - Still an inner line doc (but with a bang at the beginning)
523
-
524
- /*! - Inner block doc */
525
- /*!! - Still an inner block doc (but with a bang at the beginning) */
526
-
527
- // - Only a comment
528
- /// - Outer line doc (exactly 3 slashes)
529
- //// - Only a comment
530
-
531
- /* - Only a comment */
532
- /** - Outer block doc (exactly) 2 asterisks */
533
- /*** - Only a comment */
534
-
535
- pub mod inner_module {}
536
-
537
- pub mod nested_comments {
538
- /* In Rust /* we can /* nest comments */ */ */
539
-
540
- // All three types of block comments can contain or be nested inside
541
- // any other type:
542
-
543
- /* /* */ /** */ /*! */ */
544
- /*! /* */ /** */ /*! */ */
545
- /** /* */ /** */ /*! */ */
546
- pub mod dummy_item {}
547
- }
548
-
549
- pub mod degenerate_cases {
550
- // empty inner line doc
551
- //!
552
-
553
- // empty inner block doc
554
- /*!*/
555
-
556
- // empty line comment
557
- //
558
-
559
- // empty outer line doc
560
- ///
561
-
562
- // empty block comment
563
- /**/
564
-
565
- pub mod dummy_item {}
566
-
567
- // empty 2-asterisk block isn't a doc block, it is a block comment
568
- /***/
569
-
570
- }
571
-
572
- /* The next one isn't allowed because outer doc comments
573
- require an item that will receive the doc */
574
-
575
- /// Where is my item?
576
472
}
577
- " . to_string ( ) ;
473
+ }"
474
+ . to_string ( ) ;
578
475
let ( output, len) = make_test ( input, None , false , & opts, None ) ;
579
- assert_eq ! ( ( output, len) , ( expected, 0 ) ) ;
580
- }
476
+ assert_eq ! ( ( output, len) , ( expected, 2 ) ) ;
477
+ }
0 commit comments