Skip to content

Commit 52fd162

Browse files
authored
Rollup merge of rust-lang#49603 - GuillaumeGomez:fix-intra-link-trait-provided-method, r=QuietMisdreavus
Fix url for intra link provided method Fixes rust-lang#49582. r? @QuietMisdreavus
2 parents e1ebd0a + f9cc030 commit 52fd162

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/librustdoc/clean/mod.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,13 @@ fn resolve(cx: &DocContext, path_str: &str, is_val: bool) -> Result<(Def, Option
11201120
let kind = match item.kind {
11211121
ty::AssociatedKind::Const if is_val => "associatedconstant",
11221122
ty::AssociatedKind::Type if !is_val => "associatedtype",
1123-
ty::AssociatedKind::Method if is_val => "tymethod",
1123+
ty::AssociatedKind::Method if is_val => {
1124+
if item.defaultness.has_value() {
1125+
"method"
1126+
} else {
1127+
"tymethod"
1128+
}
1129+
}
11241130
_ => return Err(())
11251131
};
11261132

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_name = "foo"]
12+
13+
// @has foo/trait.Foo.html '//a[@href="../foo/trait.Foo.html#tymethod.req"]' 'req'
14+
// @has foo/trait.Foo.html '//a[@href="../foo/trait.Foo.html#method.prov"]' 'prov'
15+
16+
/// Always make sure to implement [`req`], but you don't have to implement [`prov`].
17+
///
18+
/// [`req`]: Foo::req
19+
/// [`prov`]: Foo::prov
20+
pub trait Foo {
21+
/// Required
22+
fn req();
23+
/// Provided
24+
fn prov() {}
25+
}

0 commit comments

Comments
 (0)