File tree 3 files changed +10
-4
lines changed
3 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -786,6 +786,7 @@ impl IndividualTestOptions {
786
786
/// [`clean`]: crate::clean
787
787
/// [`run_merged_tests`]: crate::doctest::runner::DocTestRunner::run_merged_tests
788
788
/// [`generate_unique_doctest`]: crate::doctest::make::DocTestBuilder::generate_unique_doctest
789
+ #[ derive( Debug ) ]
789
790
pub ( crate ) struct ScrapedDocTest {
790
791
filename : FileName ,
791
792
line : usize ,
Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ impl ErrorCodes {
140
140
/// Controls whether a line will be hidden or shown in HTML output.
141
141
///
142
142
/// All lines are used in documentation tests.
143
- enum Line < ' a > {
143
+ pub ( crate ) enum Line < ' a > {
144
144
Hidden ( & ' a str ) ,
145
145
Shown ( Cow < ' a , str > ) ,
146
146
}
@@ -153,20 +153,22 @@ impl<'a> Line<'a> {
153
153
}
154
154
}
155
155
156
- fn for_code ( self ) -> Cow < ' a , str > {
156
+ pub ( crate ) fn for_code ( self ) -> Cow < ' a , str > {
157
157
match self {
158
158
Line :: Shown ( l) => l,
159
159
Line :: Hidden ( l) => Cow :: Borrowed ( l) ,
160
160
}
161
161
}
162
162
}
163
163
164
+ /// This function is used to handle the "hidden lines" (ie starting with `#`) in
165
+ /// doctests. It also transforms `##` back into `#`.
164
166
// FIXME: There is a minor inconsistency here. For lines that start with ##, we
165
167
// have no easy way of removing a potential single space after the hashes, which
166
168
// is done in the single # case. This inconsistency seems okay, if non-ideal. In
167
169
// order to fix it we'd have to iterate to find the first non-# character, and
168
170
// then reallocate to remove it; which would make us return a String.
169
- fn map_line ( s : & str ) -> Line < ' _ > {
171
+ pub ( crate ) fn map_line ( s : & str ) -> Line < ' _ > {
170
172
let trimmed = s. trim ( ) ;
171
173
if trimmed. starts_with ( "##" ) {
172
174
Line :: Shown ( Cow :: Owned ( s. replacen ( "##" , "#" , 1 ) ) )
Original file line number Diff line number Diff line change @@ -43,7 +43,10 @@ fn check_rust_syntax(
43
43
44
44
let sm = Arc :: new ( SourceMap :: new ( FilePathMapping :: empty ( ) ) ) ;
45
45
let dcx = DiagCtxt :: new ( Box :: new ( emitter) ) . disable_warnings ( ) ;
46
- let source = dox[ code_block. code ] . to_owned ( ) ;
46
+ let source = dox[ code_block. code ]
47
+ . lines ( )
48
+ . map ( |line| crate :: html:: markdown:: map_line ( line) . for_code ( ) )
49
+ . collect :: < String > ( ) ;
47
50
let psess = ParseSess :: with_dcx ( dcx, sm) ;
48
51
49
52
let edition = code_block. lang_string . edition . unwrap_or_else ( || cx. tcx . sess . edition ( ) ) ;
You can’t perform that action at this time.
0 commit comments