File tree Expand file tree Collapse file tree 1 file changed +67
-0
lines changed Expand file tree Collapse file tree 1 file changed +67
-0
lines changed Original file line number Diff line number Diff line change @@ -637,3 +637,70 @@ error: unresolved link to `bar`
637
637
)
638
638
. run ( ) ;
639
639
}
640
+
641
+ #[ cargo_test]
642
+ fn doctest_respects_lints ( ) {
643
+ let foo = project ( )
644
+ . file (
645
+ "Cargo.toml" ,
646
+ r#"
647
+ [package]
648
+ name = "foo"
649
+ version = "0.0.1"
650
+ authors = []
651
+
652
+ [lints.rust]
653
+ confusable-idents = 'allow'
654
+ "# ,
655
+ )
656
+ . file (
657
+ "src/lib.rs" ,
658
+ r#"
659
+ /// Test
660
+ ///
661
+ /// [`Foo`]
662
+ ///
663
+ /// ```
664
+ /// let s = "rust";
665
+ /// let s_s = "rust2";
666
+ /// ```
667
+ pub fn f() {}
668
+ pub const Ě: i32 = 1;
669
+ pub const Ĕ: i32 = 2;
670
+ "# ,
671
+ )
672
+ . build ( ) ;
673
+
674
+ foo. cargo ( "check -Zlints" )
675
+ . masquerade_as_nightly_cargo ( & [ "lints" ] )
676
+ . with_stderr (
677
+ "\
678
+ [CHECKING] foo v0.0.1 ([CWD])
679
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
680
+ " ,
681
+ )
682
+ . run ( ) ;
683
+
684
+ foo. cargo ( "test --doc -Zlints" )
685
+ . masquerade_as_nightly_cargo ( & [ "lints" ] )
686
+ . with_stderr (
687
+ "\
688
+ [COMPILING] foo v0.0.1 ([CWD])
689
+ [FINISHED] test [unoptimized + debuginfo] target(s) in [..]s
690
+ [DOCTEST] foo
691
+ warning: identifier pair considered confusable between `Ě` and `Ĕ`
692
+ --> src/lib.rs:12:11
693
+ |
694
+ 11 | pub const Ě: i32 = 1;
695
+ | - this is where the previous identifier occurred
696
+ 12 | pub const Ĕ: i32 = 2;
697
+ | ^
698
+ |
699
+ = note: `#[warn(confusable_idents)]` on by default
700
+
701
+ [WARNING] 1 warning emitted
702
+
703
+ " ,
704
+ )
705
+ . run ( ) ;
706
+ }
You can’t perform that action at this time.
0 commit comments