File tree Expand file tree Collapse file tree 3 files changed +44
-6
lines changed Expand file tree Collapse file tree 3 files changed +44
-6
lines changed Original file line number Diff line number Diff line change @@ -147,12 +147,19 @@ fn map_line(s: &str) -> Line<'_> {
147147 let trimmed = s. trim ( ) ;
148148 if trimmed. starts_with ( "##" ) {
149149 Line :: Shown ( Cow :: Owned ( s. replacen ( "##" , "#" , 1 ) ) )
150- } else if let Some ( stripped) = trimmed. strip_prefix ( "# " ) {
151- // # text
152- Line :: Hidden ( & stripped)
153- } else if trimmed == "#" {
154- // We cannot handle '#text' because it could be #[attr].
155- Line :: Hidden ( "" )
150+ } else if trimmed. starts_with ( '#' ) {
151+ let mut without_hash = trimmed[ 1 ..] . trim_start ( ) ;
152+ if without_hash. starts_with ( '!' ) {
153+ // #! text
154+ without_hash = without_hash[ 1 ..] . trim_start_matches ( ' ' ) ;
155+ }
156+ if without_hash. starts_with ( '[' ) {
157+ // #[attr] or #![attr]
158+ Line :: Shown ( Cow :: Borrowed ( s) )
159+ } else {
160+ // #text
161+ Line :: Hidden ( without_hash)
162+ }
156163 } else {
157164 Line :: Shown ( Cow :: Borrowed ( s) )
158165 }
Original file line number Diff line number Diff line change 1+ // check-pass
2+ // compile-flags:--test
3+ // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
4+ // normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR"
5+
6+ /// ```
7+ // If `const_err` becomes a hard error in the future, please replace this with another
8+ // deny-by-default lint instead of removing it altogether
9+ /// # ! [allow(const_err)]
10+ /// const C: usize = 1/0;
11+ ///
12+ /// # use std::path::PathBuf;
13+ /// #use std::path::Path;
14+ /// let x = Path::new("y.rs");
15+ /// let x = PathBuf::from("y.rs");
16+ ///
17+ /// #[cfg(FALSE)]
18+ /// assert!(false);
19+ ///
20+ /// # [cfg(FALSE)]
21+ /// assert!(false);
22+ /// ```
23+ fn main ( ) {
24+ panic ! ( ) ;
25+ }
Original file line number Diff line number Diff line change 1+
2+ running 1 test
3+ test $DIR/test-hidden.rs - main (line 6) ... ok
4+
5+ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
6+
You can’t perform that action at this time.
0 commit comments