Skip to content

Commit 64e6dda

Browse files
committed
Auto merge of rust-lang#50326 - ollie27:rustdoc_cross_crate_const_link, r=GuillaumeGomez
rustdoc: Fix links to constants in external crates r? @GuillaumeGomez
2 parents 7fbc4d8 + 7232df7 commit 64e6dda

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed

src/librustdoc/clean/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3881,6 +3881,7 @@ fn register_def(cx: &DocContext, def: Def) -> DefId {
38813881
Def::Union(i) => (i, TypeKind::Union),
38823882
Def::Mod(i) => (i, TypeKind::Module),
38833883
Def::TyForeign(i) => (i, TypeKind::Foreign),
3884+
Def::Const(i) => (i, TypeKind::Const),
38843885
Def::Static(i, _) => (i, TypeKind::Static),
38853886
Def::Variant(i) => (cx.tcx.parent_def_id(i).unwrap(), TypeKind::Enum),
38863887
Def::Macro(i, _) => (i, TypeKind::Macro),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
#![feature(extern_types)]
12+
13+
pub mod foo_mod {}
14+
extern "C" {
15+
pub fn foo_ffn();
16+
pub static FOO_FSTATIC: FooStruct;
17+
pub type FooFType;
18+
}
19+
pub fn foo_fn() {}
20+
pub trait FooTrait {}
21+
pub struct FooStruct;
22+
pub enum FooEnum {}
23+
pub union FooUnion {
24+
x: (),
25+
}
26+
pub type FooType = FooStruct;
27+
pub static FOO_STATIC: FooStruct = FooStruct;
28+
pub const FOO_CONSTANT: FooStruct = FooStruct;
29+
#[macro_export]
30+
macro_rules! foo_macro {
31+
() => ();
32+
}

src/test/rustdoc/cross-crate-links.rs

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
// aux-build:all-item-types.rs
12+
// build-aux-docs
13+
14+
#![feature(use_extern_macros)]
15+
16+
#![crate_name = "foo"]
17+
18+
#[macro_use]
19+
extern crate all_item_types;
20+
21+
// @has 'foo/index.html' '//a[@href="../all_item_types/foo_mod/index.html"]' 'foo_mod'
22+
#[doc(no_inline)]
23+
pub use all_item_types::foo_mod;
24+
25+
// @has 'foo/index.html' '//a[@href="../all_item_types/fn.foo_ffn.html"]' 'foo_ffn'
26+
#[doc(no_inline)]
27+
pub use all_item_types::foo_ffn;
28+
29+
// @has 'foo/index.html' '//a[@href="../all_item_types/static.FOO_FSTATIC.html"]' 'FOO_FSTATIC'
30+
#[doc(no_inline)]
31+
pub use all_item_types::FOO_FSTATIC;
32+
33+
// @has 'foo/index.html' '//a[@href="../all_item_types/foreigntype.FooFType.html"]' 'FooFType'
34+
#[doc(no_inline)]
35+
pub use all_item_types::FooFType;
36+
37+
// @has 'foo/index.html' '//a[@href="../all_item_types/fn.foo_fn.html"]' 'foo_fn'
38+
#[doc(no_inline)]
39+
pub use all_item_types::foo_fn;
40+
41+
// @has 'foo/index.html' '//a[@href="../all_item_types/trait.FooTrait.html"]' 'FooTrait'
42+
#[doc(no_inline)]
43+
pub use all_item_types::FooTrait;
44+
45+
// @has 'foo/index.html' '//a[@href="../all_item_types/struct.FooStruct.html"]' 'FooStruct'
46+
#[doc(no_inline)]
47+
pub use all_item_types::FooStruct;
48+
49+
// @has 'foo/index.html' '//a[@href="../all_item_types/enum.FooEnum.html"]' 'FooEnum'
50+
#[doc(no_inline)]
51+
pub use all_item_types::FooEnum;
52+
53+
// @has 'foo/index.html' '//a[@href="../all_item_types/union.FooUnion.html"]' 'FooUnion'
54+
#[doc(no_inline)]
55+
pub use all_item_types::FooUnion;
56+
57+
// @has 'foo/index.html' '//a[@href="../all_item_types/type.FooType.html"]' 'FooType'
58+
#[doc(no_inline)]
59+
pub use all_item_types::FooType;
60+
61+
// @has 'foo/index.html' '//a[@href="../all_item_types/static.FOO_STATIC.html"]' 'FOO_STATIC'
62+
#[doc(no_inline)]
63+
pub use all_item_types::FOO_STATIC;
64+
65+
// @has 'foo/index.html' '//a[@href="../all_item_types/constant.FOO_CONSTANT.html"]' 'FOO_CONSTANT'
66+
#[doc(no_inline)]
67+
pub use all_item_types::FOO_CONSTANT;
68+
69+
// @has 'foo/index.html' '//a[@href="../all_item_types/macro.foo_macro.html"]' 'foo_macro'
70+
#[doc(no_inline)]
71+
pub use all_item_types::foo_macro;

0 commit comments

Comments
 (0)