Skip to content

Commit 1ab23bd

Browse files
committed
Include all contents of first line of scraped item
1 parent 686663a commit 1ab23bd

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

src/librustdoc/scrape_examples.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ where
196196
return;
197197
}
198198

199-
let file = tcx.sess.source_map().lookup_char_pos(span.lo()).file;
199+
let source_map = tcx.sess.source_map();
200+
let file = source_map.lookup_char_pos(span.lo()).file;
200201
let file_path = match file.name.clone() {
201202
FileName::Real(real_filename) => real_filename.into_local_path(),
202203
_ => None,
@@ -217,6 +218,8 @@ where
217218
let fn_entries = self.calls.entry(fn_key).or_default();
218219

219220
trace!("Including expr: {:?}", span);
221+
let enclosing_item_span =
222+
source_map.span_extend_to_prev_char(enclosing_item_span, '\n', false);
220223
let location = CallLocation::new(span, enclosing_item_span, &file);
221224
fn_entries.entry(abs_path).or_insert_with(mk_call_data).locations.push(location);
222225
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
deps := ex
2+
3+
-include ../rustdoc-scrape-examples-multiple/scrape.mk
4+
5+
all: scrape
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
struct Foo;
2+
impl Foo {
3+
fn bar() { foobar::ok(); }
4+
}
5+
6+
fn main() {
7+
Foo::bar();
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// @has foobar/fn.ok.html '//*[@class="docblock scraped-example-list"]//code' ' '
2+
3+
pub fn ok() {}

0 commit comments

Comments
 (0)