]> git.lizzy.rs Git - rust.git/blobdiff - src/librustdoc/scrape_examples.rs
Fix macro reexports duplicates in the sidebar
[rust.git] / src / librustdoc / scrape_examples.rs
index 93292efdcb629cfc4751647a84f4c6fdaa8dbcd1..16882cf83d09cdd058873d0cb5688ce9b7e981de 100644 (file)
@@ -196,7 +196,8 @@ fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) {
                 return;
             }
 
-            let file = tcx.sess.source_map().lookup_char_pos(span.lo()).file;
+            let source_map = tcx.sess.source_map();
+            let file = source_map.lookup_char_pos(span.lo()).file;
             let file_path = match file.name.clone() {
                 FileName::Real(real_filename) => real_filename.into_local_path(),
                 _ => None,
@@ -217,6 +218,8 @@ fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) {
                 let fn_entries = self.calls.entry(fn_key).or_default();
 
                 trace!("Including expr: {:?}", span);
+                let enclosing_item_span =
+                    source_map.span_extend_to_prev_char(enclosing_item_span, '\n', false);
                 let location = CallLocation::new(span, enclosing_item_span, &file);
                 fn_entries.entry(abs_path).or_insert_with(mk_call_data).locations.push(location);
             }