diff options
| author | kennytm <kennytm@gmail.com> | 2018-04-04 11:07:22 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-04 11:07:22 +0200 |
| commit | 52fd162603f75ae10bafebb9dfdd0acd36f5aab5 (patch) | |
| tree | 48aa8cacd6625685e154b71eafc3b8377fa16253 | |
| parent | e1ebd0a9ee98f3f178b2b58a81479c58f8a07fe6 (diff) | |
| parent | f9cc0307fec0c37941186d9588ef437268bd5c92 (diff) | |
| download | rust-52fd162603f75ae10bafebb9dfdd0acd36f5aab5.tar.gz rust-52fd162603f75ae10bafebb9dfdd0acd36f5aab5.zip | |
Rollup merge of #49603 - GuillaumeGomez:fix-intra-link-trait-provided-method, r=QuietMisdreavus
Fix url for intra link provided method Fixes #49582. r? @QuietMisdreavus
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 8 | ||||
| -rw-r--r-- | src/test/rustdoc/default-trait-method-link.rs | 25 |
2 files changed, 32 insertions, 1 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 125e71a2a61..6ada4ccfbdd 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1120,7 +1120,13 @@ fn resolve(cx: &DocContext, path_str: &str, is_val: bool) -> Result<(Def, Option let kind = match item.kind { ty::AssociatedKind::Const if is_val => "associatedconstant", ty::AssociatedKind::Type if !is_val => "associatedtype", - ty::AssociatedKind::Method if is_val => "tymethod", + ty::AssociatedKind::Method if is_val => { + if item.defaultness.has_value() { + "method" + } else { + "tymethod" + } + } _ => return Err(()) }; diff --git a/src/test/rustdoc/default-trait-method-link.rs b/src/test/rustdoc/default-trait-method-link.rs new file mode 100644 index 00000000000..9cde446eb94 --- /dev/null +++ b/src/test/rustdoc/default-trait-method-link.rs @@ -0,0 +1,25 @@ +// Copyright 2018 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. + +#![crate_name = "foo"] + +// @has foo/trait.Foo.html '//a[@href="../foo/trait.Foo.html#tymethod.req"]' 'req' +// @has foo/trait.Foo.html '//a[@href="../foo/trait.Foo.html#method.prov"]' 'prov' + +/// Always make sure to implement [`req`], but you don't have to implement [`prov`]. +/// +/// [`req`]: Foo::req +/// [`prov`]: Foo::prov +pub trait Foo { + /// Required + fn req(); + /// Provided + fn prov() {} +} |
