Skip to content

Commit

Permalink
Rollup merge of rust-lang#59978 - ollie27:rustdoc_default, r=QuietMis…
Browse files Browse the repository at this point in the history
…dreavus

rustdoc: Remove default keyword from re-exported trait methods

Fixes rust-lang#59977

r? @QuietMisdreavus

As this fixes a stable to beta regression, could it be backported?
  • Loading branch information
Centril authored Apr 15, 2019
2 parents c712d38 + 1db76c1 commit fb2ce84
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 16 deletions.
6 changes: 5 additions & 1 deletion src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
})
Expand Down
26 changes: 26 additions & 0 deletions src/test/rustdoc/default-trait-method.rs
Original file line number Diff line number Diff line change
@@ -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() {}
}
15 changes: 0 additions & 15 deletions src/test/rustdoc/default_trait_method.rs

This file was deleted.

16 changes: 16 additions & 0 deletions src/test/rustdoc/inline_cross/auxiliary/default-trait-method.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 20 additions & 0 deletions src/test/rustdoc/inline_cross/default-trait-method.rs
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit fb2ce84

Please sign in to comment.