forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#46384 - ollie27:rustdoc_inline_assoc, r=Qui…
…etMisdreavus 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.
- Loading branch information
Showing
5 changed files
with
157 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} | ||
} |