Omit underscore constants from rustdoc
This commit is contained in:
parent
cd8377d37e
commit
097126e284
2 changed files with 22 additions and 11 deletions
|
@ -9,7 +9,7 @@ use rustc::ty::TyCtxt;
|
|||
use rustc::util::nodemap::{FxHashMap, FxHashSet};
|
||||
use rustc_span::hygiene::MacroKind;
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::symbol::{kw, sym};
|
||||
use rustc_span::{self, Span};
|
||||
use syntax::ast;
|
||||
|
||||
|
@ -513,16 +513,20 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
om.statics.push(s);
|
||||
}
|
||||
hir::ItemKind::Const(type_, expr) => {
|
||||
let s = Constant {
|
||||
type_,
|
||||
expr,
|
||||
id: item.hir_id,
|
||||
name: ident.name,
|
||||
attrs: &item.attrs,
|
||||
whence: item.span,
|
||||
vis: &item.vis,
|
||||
};
|
||||
om.constants.push(s);
|
||||
// Underscore constants do not correspond to a nameable item and
|
||||
// so are never useful in documentation.
|
||||
if ident.name != kw::Underscore {
|
||||
let s = Constant {
|
||||
type_,
|
||||
expr,
|
||||
id: item.hir_id,
|
||||
name: ident.name,
|
||||
attrs: &item.attrs,
|
||||
whence: item.span,
|
||||
vis: &item.vis,
|
||||
};
|
||||
om.constants.push(s);
|
||||
}
|
||||
}
|
||||
hir::ItemKind::Trait(is_auto, unsafety, ref generics, ref bounds, ref item_ids) => {
|
||||
let items = item_ids.iter().map(|ti| self.cx.tcx.hir().trait_item(ti.id)).collect();
|
||||
|
|
7
src/test/rustdoc/const-underscore.rs
Normal file
7
src/test/rustdoc/const-underscore.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
// compile-flags: --document-private-items
|
||||
|
||||
// @!has const_underscore/constant._.html
|
||||
const _: () = {
|
||||
#[no_mangle]
|
||||
extern "C" fn implementation_detail() {}
|
||||
};
|
Loading…
Add table
Reference in a new issue