rustdoc: Remove default keyword from re-exported trait methods

This commit is contained in:
Oliver Middleton 2019-04-14 23:53:51 +01:00
parent 9a612b2348
commit 1db76c1bff
5 changed files with 67 additions and 16 deletions

View File

@ -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,
})

View 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() {}
}

View File

@ -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() {}
}

View File

@ -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() {}
}

View 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;