mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 14:01:51 +00:00
rustdoc: Remove default keyword from re-exported trait methods
This commit is contained in:
parent
9a612b2348
commit
1db76c1bff
@ -2325,6 +2325,10 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
|
||||
} else {
|
||||
hir::Constness::NotConst
|
||||
};
|
||||
let defaultness = match self.container {
|
||||
ty::ImplContainer(_) => Some(self.defaultness),
|
||||
ty::TraitContainer(_) => None,
|
||||
};
|
||||
MethodItem(Method {
|
||||
generics,
|
||||
decl,
|
||||
@ -2334,7 +2338,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
|
||||
constness,
|
||||
asyncness: hir::IsAsync::NotAsync,
|
||||
},
|
||||
defaultness: Some(self.defaultness),
|
||||
defaultness,
|
||||
all_types,
|
||||
ret_types,
|
||||
})
|
||||
|
26
src/test/rustdoc/default-trait-method.rs
Normal file
26
src/test/rustdoc/default-trait-method.rs
Normal file
@ -0,0 +1,26 @@
|
||||
#![feature(specialization)]
|
||||
|
||||
// @has default_trait_method/trait.Item.html
|
||||
// @has - '//*[@id="tymethod.foo"]' 'fn foo()'
|
||||
// @!has - '//*[@id="tymethod.foo"]' 'default fn foo()'
|
||||
// @has - '//*[@id="tymethod.bar"]' 'fn bar()'
|
||||
// @!has - '//*[@id="tymethod.bar"]' 'default fn bar()'
|
||||
// @has - '//*[@id="method.baz"]' 'fn baz()'
|
||||
// @!has - '//*[@id="method.baz"]' 'default fn baz()'
|
||||
pub trait Item {
|
||||
fn foo();
|
||||
fn bar();
|
||||
fn baz() {}
|
||||
}
|
||||
|
||||
// @has default_trait_method/struct.Foo.html
|
||||
// @has - '//*[@id="method.foo"]' 'default fn foo()'
|
||||
// @has - '//*[@id="method.bar"]' 'fn bar()'
|
||||
// @!has - '//*[@id="method.bar"]' 'default fn bar()'
|
||||
// @has - '//*[@id="method.baz"]' 'fn baz()'
|
||||
// @!has - '//*[@id="method.baz"]' 'default fn baz()'
|
||||
pub struct Foo;
|
||||
impl Item for Foo {
|
||||
default fn foo() {}
|
||||
fn bar() {}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
#![feature(specialization)]
|
||||
|
||||
pub trait Item {
|
||||
fn foo();
|
||||
fn bar();
|
||||
}
|
||||
|
||||
// @has default_trait_method/trait.Item.html
|
||||
// @has - '//*[@id="method.foo"]' 'default fn foo()'
|
||||
// @has - '//*[@id="method.bar"]' 'fn bar()'
|
||||
// @!has - '//*[@id="method.bar"]' 'default fn bar()'
|
||||
impl<T: ?Sized> Item for T {
|
||||
default fn foo() {}
|
||||
fn bar() {}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
#![feature(specialization)]
|
||||
|
||||
#![crate_name = "foo"]
|
||||
|
||||
pub trait Item {
|
||||
fn foo();
|
||||
fn bar();
|
||||
fn baz() {}
|
||||
}
|
||||
|
||||
pub struct Foo;
|
||||
|
||||
impl Item for Foo {
|
||||
default fn foo() {}
|
||||
fn bar() {}
|
||||
}
|
20
src/test/rustdoc/inline_cross/default-trait-method.rs
Normal file
20
src/test/rustdoc/inline_cross/default-trait-method.rs
Normal file
@ -0,0 +1,20 @@
|
||||
// aux-build:default-trait-method.rs
|
||||
|
||||
extern crate foo;
|
||||
|
||||
// @has default_trait_method/trait.Item.html
|
||||
// @has - '//*[@id="tymethod.foo"]' 'fn foo()'
|
||||
// @!has - '//*[@id="tymethod.foo"]' 'default fn foo()'
|
||||
// @has - '//*[@id="tymethod.bar"]' 'fn bar()'
|
||||
// @!has - '//*[@id="tymethod.bar"]' 'default fn bar()'
|
||||
// @has - '//*[@id="method.baz"]' 'fn baz()'
|
||||
// @!has - '//*[@id="method.baz"]' 'default fn baz()'
|
||||
pub use foo::Item;
|
||||
|
||||
// @has default_trait_method/struct.Foo.html
|
||||
// @has - '//*[@id="method.foo"]' 'default fn foo()'
|
||||
// @has - '//*[@id="method.bar"]' 'fn bar()'
|
||||
// @!has - '//*[@id="method.bar"]' 'default fn bar()'
|
||||
// @has - '//*[@id="method.baz"]' 'fn baz()'
|
||||
// @!has - '//*[@id="method.baz"]' 'default fn baz()'
|
||||
pub use foo::Foo;
|
Loading…
Reference in New Issue
Block a user