]> git.lizzy.rs Git - rust.git/blobdiff - src/librustdoc/passes/calculate_doc_coverage.rs
Use local and remapped paths where appropriate
[rust.git] / src / librustdoc / passes / calculate_doc_coverage.rs
index fdac33fd60e2aef31de0c1d84b5cf6c99fcd2796..c115f741afc52694b675cfddea84fde360aa7cdb 100644 (file)
@@ -119,7 +119,7 @@ fn to_json(&self) -> String {
             &self
                 .items
                 .iter()
-                .map(|(k, v)| (k.to_string(), v))
+                .map(|(k, v)| (k.prefer_local().to_string(), v))
                 .collect::<BTreeMap<String, &ItemCount>>(),
         )
         .expect("failed to convert JSON data to string")
@@ -159,7 +159,7 @@ fn print_table_record(
         for (file, &count) in &self.items {
             if let Some(percentage) = count.percentage() {
                 print_table_record(
-                    &limit_filename_len(file.to_string()),
+                    &limit_filename_len(file.prefer_local().to_string_lossy().into()),
                     count,
                     percentage,
                     count.examples_percentage().unwrap_or(0.),
@@ -211,7 +211,7 @@ fn fold_item(&mut self, i: clean::Item) -> Option<clean::Item> {
                     None,
                 );
 
-                let filename = i.span.filename(self.ctx.sess());
+                let filename = i.span(self.ctx.tcx).filename(self.ctx.sess());
                 let has_doc_example = tests.found_tests != 0;
                 let hir_id = self.ctx.tcx.hir().local_def_id_to_hir_id(i.def_id.expect_local());
                 let (level, source) = self.ctx.tcx.lint_level_at_node(MISSING_DOCS, hir_id);
@@ -219,7 +219,7 @@ fn fold_item(&mut self, i: clean::Item) -> Option<clean::Item> {
                 // unless the user had an explicit `allow`
                 let should_have_docs =
                     level != lint::Level::Allow || matches!(source, LintLevelSource::Default);
-                debug!("counting {:?} {:?} in {}", i.type_(), i.name, filename);
+                debug!("counting {:?} {:?} in {:?}", i.type_(), i.name, filename);
                 self.items.entry(filename).or_default().count_item(
                     has_docs,
                     has_doc_example,