Auto merge of #46384 - ollie27:rustdoc_inline_assoc, r=QuietMisdreavus
rustdoc: Fix issues with cross-crate inlined associated items * Visibility was missing from impl items. * Attributes and docs were missing from consts and types in impls. * Const default values were missing from traits. This unifies the code that handles associated items from impls and traits.
This commit is contained in:
commit
16ba4591d7
5 changed files with 158 additions and 97 deletions
57
src/test/rustdoc/inline_cross/assoc-items.rs
Normal file
57
src/test/rustdoc/inline_cross/assoc-items.rs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
// Copyright 2017 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 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:assoc-items.rs
|
||||
// build-aux-docs
|
||||
// ignore-cross-compile
|
||||
|
||||
#![crate_name = "foo"]
|
||||
|
||||
extern crate assoc_items;
|
||||
|
||||
// @has foo/struct.MyStruct.html
|
||||
// @!has - 'PrivateConst'
|
||||
// @has - '//*[@id="associatedconstant.PublicConst"]' 'pub const PublicConst: u8'
|
||||
// @has - '//*[@class="docblock"]' 'PublicConst: u8 = 123'
|
||||
// @has - '//*[@class="docblock"]' 'docs for PublicConst'
|
||||
// @!has - 'private_method'
|
||||
// @has - '//*[@id="method.public_method"]' 'pub fn public_method()'
|
||||
// @has - '//*[@class="docblock"]' 'docs for public_method'
|
||||
// @has - '//*[@id="associatedconstant.ConstNoDefault"]' 'const ConstNoDefault: i16'
|
||||
// @has - '//*[@class="docblock"]' 'ConstNoDefault: i16 = -123'
|
||||
// @has - '//*[@class="docblock"]' 'dox for ConstNoDefault'
|
||||
// @has - '//*[@id="associatedconstant.ConstWithDefault"]' 'const ConstWithDefault: u16'
|
||||
// @has - '//*[@class="docblock"]' 'ConstWithDefault: u16 = 12345'
|
||||
// @has - '//*[@class="docblock"]' 'docs for ConstWithDefault'
|
||||
// @has - '//*[@id="associatedtype.TypeNoDefault"]' 'type TypeNoDefault = i32'
|
||||
// @has - '//*[@class="docblock"]' 'dox for TypeNoDefault'
|
||||
// @has - '//*[@id="associatedtype.TypeWithDefault"]' 'type TypeWithDefault = u32'
|
||||
// @has - '//*[@class="docblock"]' 'docs for TypeWithDefault'
|
||||
// @has - '//*[@id="method.method_no_default"]' 'fn method_no_default()'
|
||||
// @has - '//*[@class="docblock"]' 'dox for method_no_default'
|
||||
// @has - '//*[@id="method.method_with_default"]' 'fn method_with_default()'
|
||||
// @has - '//*[@class="docblock"]' 'docs for method_with_default'
|
||||
pub use assoc_items::MyStruct;
|
||||
|
||||
// @has foo/trait.MyTrait.html
|
||||
// @has - '//*[@id="associatedconstant.ConstNoDefault"]' 'const ConstNoDefault: i16'
|
||||
// @has - '//*[@class="docblock"]' 'docs for ConstNoDefault'
|
||||
// @has - '//*[@id="associatedconstant.ConstWithDefault"]' 'const ConstWithDefault: u16'
|
||||
// @has - '//*[@class="docblock"]' 'ConstWithDefault: u16 = 12345'
|
||||
// @has - '//*[@class="docblock"]' 'docs for ConstWithDefault'
|
||||
// @has - '//*[@id="associatedtype.TypeNoDefault"]' 'type TypeNoDefault'
|
||||
// @has - '//*[@class="docblock"]' 'docs for TypeNoDefault'
|
||||
// @has - '//*[@id="associatedtype.TypeWithDefault"]' 'type TypeWithDefault = u32'
|
||||
// @has - '//*[@class="docblock"]' 'docs for TypeWithDefault'
|
||||
// @has - '//*[@id="tymethod.method_no_default"]' 'fn method_no_default()'
|
||||
// @has - '//*[@class="docblock"]' 'docs for method_no_default'
|
||||
// @has - '//*[@id="method.method_with_default"]' 'fn method_with_default()'
|
||||
// @has - '//*[@class="docblock"]' 'docs for method_with_default'
|
||||
pub use assoc_items::MyTrait;
|
||||
48
src/test/rustdoc/inline_cross/auxiliary/assoc-items.rs
Normal file
48
src/test/rustdoc/inline_cross/auxiliary/assoc-items.rs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
// Copyright 2017 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 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(associated_type_defaults)]
|
||||
|
||||
pub struct MyStruct;
|
||||
|
||||
impl MyStruct {
|
||||
/// docs for PrivateConst
|
||||
const PrivateConst: i8 = -123;
|
||||
/// docs for PublicConst
|
||||
pub const PublicConst: u8 = 123;
|
||||
/// docs for private_method
|
||||
fn private_method() {}
|
||||
/// docs for public_method
|
||||
pub fn public_method() {}
|
||||
}
|
||||
|
||||
pub trait MyTrait {
|
||||
/// docs for ConstNoDefault
|
||||
const ConstNoDefault: i16;
|
||||
/// docs for ConstWithDefault
|
||||
const ConstWithDefault: u16 = 12345;
|
||||
/// docs for TypeNoDefault
|
||||
type TypeNoDefault;
|
||||
/// docs for TypeWithDefault
|
||||
type TypeWithDefault = u32;
|
||||
/// docs for method_no_default
|
||||
fn method_no_default();
|
||||
/// docs for method_with_default
|
||||
fn method_with_default() {}
|
||||
}
|
||||
|
||||
impl MyTrait for MyStruct {
|
||||
/// dox for ConstNoDefault
|
||||
const ConstNoDefault: i16 = -12345;
|
||||
/// dox for TypeNoDefault
|
||||
type TypeNoDefault = i32;
|
||||
/// dox for method_no_default
|
||||
fn method_no_default() {}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue