From 130fd1a970a89e826f343da160b19bc853ce43cb Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 27 Sep 2020 21:22:11 +0200 Subject: [PATCH 1/7] Don't remove export items so that we can run lints on them --- src/librustdoc/clean/mod.rs | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index ca9135cd11a16..ca9d76f4cf435 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2232,6 +2232,12 @@ impl Clean> for doctree::ExternCrate<'_> { impl Clean> for doctree::Import<'_> { fn clean(&self, cx: &DocContext<'_>) -> Vec { + // We need this comparison because some imports (for std types for example) + // are "inserted" as well but directly by the compiler and they should not be + // taken into account. + if self.span.is_dummy() { + return Vec::new(); + } // We consider inlining the documentation of `pub use` statements, but we // forcefully don't inline if this is not public or if the // #[doc(no_inline)] attribute is present. @@ -2254,11 +2260,20 @@ impl Clean> for doctree::Import<'_> { let inner = if self.glob { if !denied { let mut visited = FxHashSet::default(); - if let Some(items) = inline::try_inline_glob(cx, path.res, &mut visited) { + if let Some(mut items) = inline::try_inline_glob(cx, path.res, &mut visited) { + items.push(Item { + name: None, + attrs: self.attrs.clean(cx), + source: self.span.clean(cx), + def_id: cx.tcx.hir().local_def_id(self.id).to_def_id(), + visibility: self.vis.clean(cx), + stability: None, + deprecation: None, + inner: ImportItem(Import::Glob(resolve_use_source(cx, path))), + }); return items; } } - Import::Glob(resolve_use_source(cx, path)) } else { let name = self.name; @@ -2273,7 +2288,8 @@ impl Clean> for doctree::Import<'_> { } if !denied { let mut visited = FxHashSet::default(); - if let Some(items) = inline::try_inline( + + if let Some(mut items) = inline::try_inline( cx, cx.tcx.parent_module(self.id).to_def_id(), path.res, @@ -2281,6 +2297,19 @@ impl Clean> for doctree::Import<'_> { Some(self.attrs), &mut visited, ) { + items.push(Item { + name: None, + attrs: self.attrs.clean(cx), + source: self.span.clean(cx), + def_id: cx.tcx.hir().local_def_id(self.id).to_def_id(), + visibility: self.vis.clean(cx), + stability: None, + deprecation: None, + inner: ImportItem(Import::Simple( + self.name.clean(cx), + resolve_use_source(cx, path), + )), + }); return items; } } From 7c0d576c59e9429157449e617ec5607373afc642 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 27 Sep 2020 21:22:39 +0200 Subject: [PATCH 2/7] Add test for reexported items lints --- src/test/rustdoc-ui/pub-export-lint.rs | 8 ++++++++ src/test/rustdoc-ui/pub-export-lint.stderr | 23 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/test/rustdoc-ui/pub-export-lint.rs create mode 100644 src/test/rustdoc-ui/pub-export-lint.stderr diff --git a/src/test/rustdoc-ui/pub-export-lint.rs b/src/test/rustdoc-ui/pub-export-lint.rs new file mode 100644 index 0000000000000..31953206fd927 --- /dev/null +++ b/src/test/rustdoc-ui/pub-export-lint.rs @@ -0,0 +1,8 @@ +#![deny(broken_intra_doc_links)] + +/// [somewhere] +//~^ ERROR unresolved link to `somewhere` +pub use std::str::*; +/// [aloha] +//~^ ERROR unresolved link to `aloha` +pub use std::task::RawWakerVTable; diff --git a/src/test/rustdoc-ui/pub-export-lint.stderr b/src/test/rustdoc-ui/pub-export-lint.stderr new file mode 100644 index 0000000000000..54fe113be657d --- /dev/null +++ b/src/test/rustdoc-ui/pub-export-lint.stderr @@ -0,0 +1,23 @@ +error: unresolved link to `somewhere` + --> $DIR/pub-export-lint.rs:3:6 + | +LL | /// [somewhere] + | ^^^^^^^^^ the module `pub_export_lint` contains no item named `somewhere` + | +note: the lint level is defined here + --> $DIR/pub-export-lint.rs:1:9 + | +LL | #![deny(broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^ + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: unresolved link to `aloha` + --> $DIR/pub-export-lint.rs:6:6 + | +LL | /// [aloha] + | ^^^^^ the module `pub_export_lint` contains no item named `aloha` + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: aborting due to 2 previous errors + From 31d275e5877d983fecb39bbaad837f6b7cf120d3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 28 Sep 2020 00:18:09 +0200 Subject: [PATCH 3/7] Correctly handle "pub use" reexports --- src/librustdoc/clean/inline.rs | 1 + src/librustdoc/clean/mod.rs | 10 +++++++--- src/librustdoc/clean/types.rs | 15 +++++++++++++-- src/librustdoc/doctree.rs | 1 + src/librustdoc/html/format.rs | 4 ++-- src/librustdoc/html/render/mod.rs | 14 ++++++++------ 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index a6c754ab67f61..17f9411fca8a6 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -514,6 +514,7 @@ fn build_module(cx: &DocContext<'_>, did: DefId, visited: &mut FxHashSet) }, did: None, }, + false, )), }); } else if let Some(i) = diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index ca9d76f4cf435..daa9f1df64937 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2269,12 +2269,12 @@ impl Clean> for doctree::Import<'_> { visibility: self.vis.clean(cx), stability: None, deprecation: None, - inner: ImportItem(Import::Glob(resolve_use_source(cx, path))), + inner: ImportItem(Import::Glob(resolve_use_source(cx, path), false)), }); return items; } } - Import::Glob(resolve_use_source(cx, path)) + Import::Glob(resolve_use_source(cx, path), true) } else { let name = self.name; if !please_inline { @@ -2297,6 +2297,9 @@ impl Clean> for doctree::Import<'_> { Some(self.attrs), &mut visited, ) { + // In case this is a macro, we don't want to show the reexport, only the macro + // itself. + let is_macro = matches!(path.res, Res::Def(DefKind::Macro(_), _)); items.push(Item { name: None, attrs: self.attrs.clean(cx), @@ -2308,12 +2311,13 @@ impl Clean> for doctree::Import<'_> { inner: ImportItem(Import::Simple( self.name.clean(cx), resolve_use_source(cx, path), + is_macro, )), }); return items; } } - Import::Simple(name.clean(cx), resolve_use_source(cx, path)) + Import::Simple(name.clean(cx), resolve_use_source(cx, path), false) }; vec![Item { diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 179cf248846a8..8b14b3e5de24d 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1655,9 +1655,20 @@ pub struct Impl { #[derive(Clone, Debug)] pub enum Import { // use source as str; - Simple(String, ImportSource), + // The bool indicates wether it imports a macro or not. + Simple(String, ImportSource, bool), // use source::*; - Glob(ImportSource), + // The bool indicates wether this is from an import. + Glob(ImportSource, bool), +} + +impl Import { + pub fn should_be_displayed(&self) -> bool { + match *self { + Self::Simple(_, _, is_macro) => !is_macro, + Self::Glob(_, is_from_import) => is_from_import, + } + } } #[derive(Clone, Debug)] diff --git a/src/librustdoc/doctree.rs b/src/librustdoc/doctree.rs index 6bb9b58bead65..ee217d99d2c77 100644 --- a/src/librustdoc/doctree.rs +++ b/src/librustdoc/doctree.rs @@ -245,6 +245,7 @@ pub struct ExternCrate<'hir> { pub span: Span, } +#[derive(Debug)] pub struct Import<'hir> { pub name: Symbol, pub id: hir::HirId, diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 2da9c68b1967c..ece0c247fb5e2 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -1150,14 +1150,14 @@ impl PrintWithSpace for hir::Mutability { impl clean::Import { crate fn print(&self) -> impl fmt::Display + '_ { display_fn(move |f| match *self { - clean::Import::Simple(ref name, ref src) => { + clean::Import::Simple(ref name, ref src, _) => { if *name == src.path.last_name() { write!(f, "use {};", src.print()) } else { write!(f, "use {} as {};", src.print(), *name) } } - clean::Import::Glob(ref src) => { + clean::Import::Glob(ref src, _) => { if src.path.segments.is_empty() { write!(f, "use *;") } else { diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index afd1dc596427f..a74e768f980d3 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -2074,12 +2074,14 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean: } clean::ImportItem(ref import) => { - write!( - w, - "{}{}", - myitem.visibility.print_with_space(), - import.print() - ); + if import.should_be_displayed() { + write!( + w, + "{}{}", + myitem.visibility.print_with_space(), + import.print() + ); + } } _ => { From bfdfc66f73b3e60ea2024ce090ae036b9f8200cf Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 28 Sep 2020 00:19:31 +0200 Subject: [PATCH 4/7] Add test to ensure that external items aren't lint-checked --- src/librustdoc/clean/types.rs | 4 ++-- src/test/rustdoc-ui/auxiliary/intra-doc-broken.rs | 4 ++++ src/test/rustdoc-ui/intra-doc-broken-reexport.rs | 8 ++++++++ src/test/rustdoc-ui/pub-export-lint.stderr | 4 ++-- 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 src/test/rustdoc-ui/auxiliary/intra-doc-broken.rs create mode 100644 src/test/rustdoc-ui/intra-doc-broken-reexport.rs diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 8b14b3e5de24d..6f35ab4b38606 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1655,10 +1655,10 @@ pub struct Impl { #[derive(Clone, Debug)] pub enum Import { // use source as str; - // The bool indicates wether it imports a macro or not. + // The bool indicates whether it imports a macro or not. Simple(String, ImportSource, bool), // use source::*; - // The bool indicates wether this is from an import. + // The bool indicates whether this is from an import. Glob(ImportSource, bool), } diff --git a/src/test/rustdoc-ui/auxiliary/intra-doc-broken.rs b/src/test/rustdoc-ui/auxiliary/intra-doc-broken.rs new file mode 100644 index 0000000000000..31a8310d47242 --- /dev/null +++ b/src/test/rustdoc-ui/auxiliary/intra-doc-broken.rs @@ -0,0 +1,4 @@ +#![crate_name = "intra_doc_broken"] + +/// [not_found] +pub fn foo() {} diff --git a/src/test/rustdoc-ui/intra-doc-broken-reexport.rs b/src/test/rustdoc-ui/intra-doc-broken-reexport.rs new file mode 100644 index 0000000000000..ef261359ebd9e --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc-broken-reexport.rs @@ -0,0 +1,8 @@ +// aux-build:intra-doc-broken.rs +// check-pass + +#![deny(broken_intra_doc_links)] + +extern crate intra_doc_broken; + +pub use intra_doc_broken::foo; diff --git a/src/test/rustdoc-ui/pub-export-lint.stderr b/src/test/rustdoc-ui/pub-export-lint.stderr index 54fe113be657d..7fc24d9bea385 100644 --- a/src/test/rustdoc-ui/pub-export-lint.stderr +++ b/src/test/rustdoc-ui/pub-export-lint.stderr @@ -1,8 +1,8 @@ error: unresolved link to `somewhere` --> $DIR/pub-export-lint.rs:3:6 | -LL | /// [somewhere] - | ^^^^^^^^^ the module `pub_export_lint` contains no item named `somewhere` +LL | /// [aloha] + | ^^^^^ no item named `aloha` in scope | note: the lint level is defined here --> $DIR/pub-export-lint.rs:1:9 From 6bea76f175f1a565320a1a93a174fb80567dda7c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 29 Sep 2020 17:04:40 +0200 Subject: [PATCH 5/7] Simplify included import items handling --- src/librustdoc/clean/inline.rs | 4 +-- src/librustdoc/clean/mod.rs | 13 +++----- src/librustdoc/clean/types.rs | 31 ++++++++++++------- src/librustdoc/html/format.rs | 16 +++++----- src/librustdoc/html/render/mod.rs | 19 ++++++------ .../passes/collect_intra_doc_links.rs | 2 +- src/test/rustdoc/reexport-check.rs | 11 +++++++ 7 files changed, 55 insertions(+), 41 deletions(-) create mode 100644 src/test/rustdoc/reexport-check.rs diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 17f9411fca8a6..79ff7fc62d53e 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -498,7 +498,7 @@ fn build_module(cx: &DocContext<'_>, did: DefId, visited: &mut FxHashSet) visibility: clean::Public, stability: None, deprecation: None, - inner: clean::ImportItem(clean::Import::Simple( + inner: clean::ImportItem(clean::Import::new_simple( item.ident.to_string(), clean::ImportSource { path: clean::Path { @@ -514,7 +514,7 @@ fn build_module(cx: &DocContext<'_>, did: DefId, visited: &mut FxHashSet) }, did: None, }, - false, + true, )), }); } else if let Some(i) = diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index daa9f1df64937..721e3902cf51a 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2269,12 +2269,12 @@ impl Clean> for doctree::Import<'_> { visibility: self.vis.clean(cx), stability: None, deprecation: None, - inner: ImportItem(Import::Glob(resolve_use_source(cx, path), false)), + inner: ImportItem(Import::new_glob(resolve_use_source(cx, path), false)), }); return items; } } - Import::Glob(resolve_use_source(cx, path), true) + Import::new_glob(resolve_use_source(cx, path), true) } else { let name = self.name; if !please_inline { @@ -2297,9 +2297,6 @@ impl Clean> for doctree::Import<'_> { Some(self.attrs), &mut visited, ) { - // In case this is a macro, we don't want to show the reexport, only the macro - // itself. - let is_macro = matches!(path.res, Res::Def(DefKind::Macro(_), _)); items.push(Item { name: None, attrs: self.attrs.clean(cx), @@ -2308,16 +2305,16 @@ impl Clean> for doctree::Import<'_> { visibility: self.vis.clean(cx), stability: None, deprecation: None, - inner: ImportItem(Import::Simple( + inner: ImportItem(Import::new_simple( self.name.clean(cx), resolve_use_source(cx, path), - is_macro, + false, )), }); return items; } } - Import::Simple(name.clean(cx), resolve_use_source(cx, path), false) + Import::new_simple(name.clean(cx), resolve_use_source(cx, path), true) }; vec![Item { diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 6f35ab4b38606..903f44a0f93df 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -177,6 +177,7 @@ impl Item { pub fn is_stripped(&self) -> bool { match self.inner { StrippedItem(..) => true, + ImportItem(ref i) => !i.should_be_displayed, _ => false, } } @@ -1653,24 +1654,30 @@ pub struct Impl { } #[derive(Clone, Debug)] -pub enum Import { - // use source as str; - // The bool indicates whether it imports a macro or not. - Simple(String, ImportSource, bool), - // use source::*; - // The bool indicates whether this is from an import. - Glob(ImportSource, bool), +pub struct Import { + pub kind: ImportKind, + pub source: ImportSource, + pub should_be_displayed: bool, } impl Import { - pub fn should_be_displayed(&self) -> bool { - match *self { - Self::Simple(_, _, is_macro) => !is_macro, - Self::Glob(_, is_from_import) => is_from_import, - } + pub fn new_simple(name: String, source: ImportSource, should_be_displayed: bool) -> Self { + Self { kind: ImportKind::Simple(name), source, should_be_displayed } + } + + pub fn new_glob(source: ImportSource, should_be_displayed: bool) -> Self { + Self { kind: ImportKind::Glob, source, should_be_displayed } } } +#[derive(Clone, Debug)] +pub enum ImportKind { + // use source as str; + Simple(String), + // use source::*; + Glob, +} + #[derive(Clone, Debug)] pub struct ImportSource { pub path: Path, diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index ece0c247fb5e2..d18282d6e675d 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -1149,19 +1149,19 @@ impl PrintWithSpace for hir::Mutability { impl clean::Import { crate fn print(&self) -> impl fmt::Display + '_ { - display_fn(move |f| match *self { - clean::Import::Simple(ref name, ref src, _) => { - if *name == src.path.last_name() { - write!(f, "use {};", src.print()) + display_fn(move |f| match self.kind { + clean::ImportKind::Simple(ref name) => { + if *name == self.source.path.last_name() { + write!(f, "use {};", self.source.print()) } else { - write!(f, "use {} as {};", src.print(), *name) + write!(f, "use {} as {};", self.source.print(), *name) } } - clean::Import::Glob(ref src, _) => { - if src.path.segments.is_empty() { + clean::ImportKind::Glob => { + if self.source.path.segments.is_empty() { write!(f, "use *;") } else { - write!(f, "use {}::*;", src.print()) + write!(f, "use {}::*;", self.source.print()) } } }) diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index a74e768f980d3..76334f0213d15 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -2074,14 +2074,12 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean: } clean::ImportItem(ref import) => { - if import.should_be_displayed() { - write!( - w, - "{}{}", - myitem.visibility.print_with_space(), - import.print() - ); - } + write!( + w, + "{}{}", + myitem.visibility.print_with_space(), + import.print() + ); } _ => { @@ -4440,8 +4438,9 @@ fn item_ty_to_strs(ty: &ItemType) -> (&'static str, &'static str) { fn sidebar_module(buf: &mut Buffer, items: &[clean::Item]) { let mut sidebar = String::new(); - if items.iter().any(|it| it.type_() == ItemType::ExternCrate || it.type_() == ItemType::Import) - { + if items.iter().any(|it| { + it.type_() == ItemType::ExternCrate || (it.type_() == ItemType::Import && !it.is_stripped()) + }) { sidebar.push_str(&format!( "
  • {name}
  • ", id = "reexports", diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index b9be3e2f92b46..5b5624298a41a 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -758,7 +758,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> { debug!("ignoring extern crate item {:?}", item.def_id); return self.fold_item_recur(item); } - ImportItem(Import::Simple(ref name, ..)) => Some(name.clone()), + ImportItem(Import { kind: ImportKind::Simple(ref name, ..), .. }) => Some(name.clone()), MacroItem(..) => None, _ => item.name.clone(), }; diff --git a/src/test/rustdoc/reexport-check.rs b/src/test/rustdoc/reexport-check.rs new file mode 100644 index 0000000000000..9ecf1abbea928 --- /dev/null +++ b/src/test/rustdoc/reexport-check.rs @@ -0,0 +1,11 @@ +#![crate_name = "foo"] + +// @!has 'foo/index.html' '//code' 'pub use self::i32;' +// @has 'foo/index.html' '//tr[@class="module-item"]' 'i32' +// @has 'foo/i32/index.html' +pub use std::i32; +// @!has 'foo/index.html' '//code' 'pub use self::string::String;' +// @has 'foo/index.html' '//tr[@class="module-item"]' 'String' +pub use std::string::String; +// @!has 'foo/index.html' '//code' 'pub use self::string::*;' +pub use std::string::*; From e3b1be3b624d6b225901e617bfe28f55b4ebac6d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 29 Sep 2020 20:23:02 +0200 Subject: [PATCH 6/7] Remove unneeded ImportItem on glob ones --- src/librustdoc/clean/mod.rs | 12 +----------- src/test/rustdoc-ui/pub-export-lint.rs | 3 --- src/test/rustdoc-ui/pub-export-lint.stderr | 12 ++---------- src/test/rustdoc/reexport-check.rs | 2 -- 4 files changed, 3 insertions(+), 26 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 721e3902cf51a..54751896bb3b4 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2260,17 +2260,7 @@ impl Clean> for doctree::Import<'_> { let inner = if self.glob { if !denied { let mut visited = FxHashSet::default(); - if let Some(mut items) = inline::try_inline_glob(cx, path.res, &mut visited) { - items.push(Item { - name: None, - attrs: self.attrs.clean(cx), - source: self.span.clean(cx), - def_id: cx.tcx.hir().local_def_id(self.id).to_def_id(), - visibility: self.vis.clean(cx), - stability: None, - deprecation: None, - inner: ImportItem(Import::new_glob(resolve_use_source(cx, path), false)), - }); + if let Some(items) = inline::try_inline_glob(cx, path.res, &mut visited) { return items; } } diff --git a/src/test/rustdoc-ui/pub-export-lint.rs b/src/test/rustdoc-ui/pub-export-lint.rs index 31953206fd927..3fd3f77400978 100644 --- a/src/test/rustdoc-ui/pub-export-lint.rs +++ b/src/test/rustdoc-ui/pub-export-lint.rs @@ -1,8 +1,5 @@ #![deny(broken_intra_doc_links)] -/// [somewhere] -//~^ ERROR unresolved link to `somewhere` -pub use std::str::*; /// [aloha] //~^ ERROR unresolved link to `aloha` pub use std::task::RawWakerVTable; diff --git a/src/test/rustdoc-ui/pub-export-lint.stderr b/src/test/rustdoc-ui/pub-export-lint.stderr index 7fc24d9bea385..c345def794c08 100644 --- a/src/test/rustdoc-ui/pub-export-lint.stderr +++ b/src/test/rustdoc-ui/pub-export-lint.stderr @@ -1,4 +1,4 @@ -error: unresolved link to `somewhere` +error: unresolved link to `aloha` --> $DIR/pub-export-lint.rs:3:6 | LL | /// [aloha] @@ -11,13 +11,5 @@ LL | #![deny(broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^ = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` -error: unresolved link to `aloha` - --> $DIR/pub-export-lint.rs:6:6 - | -LL | /// [aloha] - | ^^^^^ the module `pub_export_lint` contains no item named `aloha` - | - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/src/test/rustdoc/reexport-check.rs b/src/test/rustdoc/reexport-check.rs index 9ecf1abbea928..dea72b81a57c3 100644 --- a/src/test/rustdoc/reexport-check.rs +++ b/src/test/rustdoc/reexport-check.rs @@ -7,5 +7,3 @@ pub use std::i32; // @!has 'foo/index.html' '//code' 'pub use self::string::String;' // @has 'foo/index.html' '//tr[@class="module-item"]' 'String' pub use std::string::String; -// @!has 'foo/index.html' '//code' 'pub use self::string::*;' -pub use std::string::*; From 7e218bbd1a2f05244669b82421ce8d9344325acc Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 Oct 2020 11:04:08 +0200 Subject: [PATCH 7/7] Don't filter out imports added by the compiler for the moment --- src/librustdoc/clean/mod.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 54751896bb3b4..501891da573a6 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2232,12 +2232,6 @@ impl Clean> for doctree::ExternCrate<'_> { impl Clean> for doctree::Import<'_> { fn clean(&self, cx: &DocContext<'_>) -> Vec { - // We need this comparison because some imports (for std types for example) - // are "inserted" as well but directly by the compiler and they should not be - // taken into account. - if self.span.is_dummy() { - return Vec::new(); - } // We consider inlining the documentation of `pub use` statements, but we // forcefully don't inline if this is not public or if the // #[doc(no_inline)] attribute is present.