From 00a32b288442efdf219230147ddcb834827ce65d Mon Sep 17 00:00:00 2001 From: mitaa Date: Tue, 22 Mar 2016 06:59:43 +0100 Subject: [PATCH] Omit `pub` for inlined variant-struct fields --- src/librustdoc/clean/mod.rs | 2 +- src/test/auxiliary/variant-struct.rs | 15 +++++++++++++++ src/test/rustdoc/issue-32395.rs | 21 +++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/test/auxiliary/variant-struct.rs create mode 100644 src/test/rustdoc/issue-32395.rs diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 54821bd1161..2d3961ee6f4 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1885,7 +1885,7 @@ impl<'tcx> Clean for ty::VariantDefData<'tcx, 'static> { source: Span::empty(), name: Some(field.name.clean(cx)), attrs: Vec::new(), - visibility: Some(hir::Public), + visibility: Some(field.vis), // FIXME: this is not accurate, we need an id for // the specific field but we're using the id // for the whole variant. Thus we read the diff --git a/src/test/auxiliary/variant-struct.rs b/src/test/auxiliary/variant-struct.rs new file mode 100644 index 00000000000..d846c0adf61 --- /dev/null +++ b/src/test/auxiliary/variant-struct.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub enum Foo { + Bar { + qux: (), + } +} diff --git a/src/test/rustdoc/issue-32395.rs b/src/test/rustdoc/issue-32395.rs new file mode 100644 index 00000000000..fba2a6ad487 --- /dev/null +++ b/src/test/rustdoc/issue-32395.rs @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:variant-struct.rs +// build-aux-docs +// ignore-cross-compile + +// @has variant_struct/enum.Foo.html +// @!has - 'pub qux' +extern crate variant_struct; + +// @has issue_32395/enum.Foo.html +// @!has - 'pub qux' +pub use variant_struct::Foo;