Skip to content

Commit 8302044

Browse files
committed
rustdoc: Don't import macros from private imports
1 parent ee220da commit 8302044

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

src/librustdoc/visit_ast.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use rustc::hir::def::Def;
2323
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
2424
use rustc::middle::cstore::{LoadedMacro, CrateStore};
2525
use rustc::middle::privacy::AccessLevel;
26+
use rustc::ty::Visibility;
2627
use rustc::util::nodemap::FxHashSet;
2728

2829
use rustc::hir;
@@ -204,7 +205,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
204205
self.inside_public_path = orig_inside_public_path;
205206
let def_id = self.cx.tcx.hir.local_def_id(id);
206207
if let Some(exports) = self.cx.tcx.module_exports(def_id) {
207-
for export in exports.iter() {
208+
for export in exports.iter().filter(|e| e.vis == Visibility::Public) {
208209
if let Def::Macro(def_id, ..) = export.def {
209210
if def_id.krate == LOCAL_CRATE || self.reexported_macros.contains(&def_id) {
210211
continue // These are `krate.exported_macros`, handled in `self.visit()`.

src/test/rustdoc/issue-47038.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(decl_macro)]
12+
13+
#![crate_name = "foo"]
14+
15+
use std::vec;
16+
17+
// @has 'foo/index.html'
18+
// @!has - '//*[@id="macros"]' 'Macros'
19+
// @!has - '//a/@href' 'macro.vec.html'
20+
// @!has 'foo/macro.vec.html'

src/tools/linkchecker/main.rs

-7
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,6 @@ fn check(cache: &mut Cache,
158158
file.ends_with("sync/struct.RwLock.html") {
159159
return None;
160160
}
161-
// FIXME(#47038)
162-
if file.ends_with("deriving/generic/index.html") ||
163-
file.ends_with("deriving/generic/macro.vec.html") ||
164-
file.ends_with("deriving/custom/macro.panic.html") ||
165-
file.ends_with("proc_macro_impl/macro.panic.html") {
166-
return None;
167-
}
168161

169162
let res = load_file(cache, root, file, SkipRedirect);
170163
let (pretty_file, contents) = match res {

0 commit comments

Comments
 (0)