Auto merge of #50326 - ollie27:rustdoc_cross_crate_const_link, r=GuillaumeGomez
rustdoc: Fix links to constants in external crates r? @GuillaumeGomez
This commit is contained in:
commit
64e6dda0bc
3 changed files with 104 additions and 0 deletions
|
@ -3881,6 +3881,7 @@ fn register_def(cx: &DocContext, def: Def) -> DefId {
|
||||||
Def::Union(i) => (i, TypeKind::Union),
|
Def::Union(i) => (i, TypeKind::Union),
|
||||||
Def::Mod(i) => (i, TypeKind::Module),
|
Def::Mod(i) => (i, TypeKind::Module),
|
||||||
Def::TyForeign(i) => (i, TypeKind::Foreign),
|
Def::TyForeign(i) => (i, TypeKind::Foreign),
|
||||||
|
Def::Const(i) => (i, TypeKind::Const),
|
||||||
Def::Static(i, _) => (i, TypeKind::Static),
|
Def::Static(i, _) => (i, TypeKind::Static),
|
||||||
Def::Variant(i) => (cx.tcx.parent_def_id(i).unwrap(), TypeKind::Enum),
|
Def::Variant(i) => (cx.tcx.parent_def_id(i).unwrap(), TypeKind::Enum),
|
||||||
Def::Macro(i, _) => (i, TypeKind::Macro),
|
Def::Macro(i, _) => (i, TypeKind::Macro),
|
||||||
|
|
32
src/test/rustdoc/auxiliary/all-item-types.rs
Normal file
32
src/test/rustdoc/auxiliary/all-item-types.rs
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#![feature(extern_types)]
|
||||||
|
|
||||||
|
pub mod foo_mod {}
|
||||||
|
extern "C" {
|
||||||
|
pub fn foo_ffn();
|
||||||
|
pub static FOO_FSTATIC: FooStruct;
|
||||||
|
pub type FooFType;
|
||||||
|
}
|
||||||
|
pub fn foo_fn() {}
|
||||||
|
pub trait FooTrait {}
|
||||||
|
pub struct FooStruct;
|
||||||
|
pub enum FooEnum {}
|
||||||
|
pub union FooUnion {
|
||||||
|
x: (),
|
||||||
|
}
|
||||||
|
pub type FooType = FooStruct;
|
||||||
|
pub static FOO_STATIC: FooStruct = FooStruct;
|
||||||
|
pub const FOO_CONSTANT: FooStruct = FooStruct;
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! foo_macro {
|
||||||
|
() => ();
|
||||||
|
}
|
71
src/test/rustdoc/cross-crate-links.rs
Normal file
71
src/test/rustdoc/cross-crate-links.rs
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
// aux-build:all-item-types.rs
|
||||||
|
// build-aux-docs
|
||||||
|
|
||||||
|
#![feature(use_extern_macros)]
|
||||||
|
|
||||||
|
#![crate_name = "foo"]
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate all_item_types;
|
||||||
|
|
||||||
|
// @has 'foo/index.html' '//a[@href="../all_item_types/foo_mod/index.html"]' 'foo_mod'
|
||||||
|
#[doc(no_inline)]
|
||||||
|
pub use all_item_types::foo_mod;
|
||||||
|
|
||||||
|
// @has 'foo/index.html' '//a[@href="../all_item_types/fn.foo_ffn.html"]' 'foo_ffn'
|
||||||
|
#[doc(no_inline)]
|
||||||
|
pub use all_item_types::foo_ffn;
|
||||||
|
|
||||||
|
// @has 'foo/index.html' '//a[@href="../all_item_types/static.FOO_FSTATIC.html"]' 'FOO_FSTATIC'
|
||||||
|
#[doc(no_inline)]
|
||||||
|
pub use all_item_types::FOO_FSTATIC;
|
||||||
|
|
||||||
|
// @has 'foo/index.html' '//a[@href="../all_item_types/foreigntype.FooFType.html"]' 'FooFType'
|
||||||
|
#[doc(no_inline)]
|
||||||
|
pub use all_item_types::FooFType;
|
||||||
|
|
||||||
|
// @has 'foo/index.html' '//a[@href="../all_item_types/fn.foo_fn.html"]' 'foo_fn'
|
||||||
|
#[doc(no_inline)]
|
||||||
|
pub use all_item_types::foo_fn;
|
||||||
|
|
||||||
|
// @has 'foo/index.html' '//a[@href="../all_item_types/trait.FooTrait.html"]' 'FooTrait'
|
||||||
|
#[doc(no_inline)]
|
||||||
|
pub use all_item_types::FooTrait;
|
||||||
|
|
||||||
|
// @has 'foo/index.html' '//a[@href="../all_item_types/struct.FooStruct.html"]' 'FooStruct'
|
||||||
|
#[doc(no_inline)]
|
||||||
|
pub use all_item_types::FooStruct;
|
||||||
|
|
||||||
|
// @has 'foo/index.html' '//a[@href="../all_item_types/enum.FooEnum.html"]' 'FooEnum'
|
||||||
|
#[doc(no_inline)]
|
||||||
|
pub use all_item_types::FooEnum;
|
||||||
|
|
||||||
|
// @has 'foo/index.html' '//a[@href="../all_item_types/union.FooUnion.html"]' 'FooUnion'
|
||||||
|
#[doc(no_inline)]
|
||||||
|
pub use all_item_types::FooUnion;
|
||||||
|
|
||||||
|
// @has 'foo/index.html' '//a[@href="../all_item_types/type.FooType.html"]' 'FooType'
|
||||||
|
#[doc(no_inline)]
|
||||||
|
pub use all_item_types::FooType;
|
||||||
|
|
||||||
|
// @has 'foo/index.html' '//a[@href="../all_item_types/static.FOO_STATIC.html"]' 'FOO_STATIC'
|
||||||
|
#[doc(no_inline)]
|
||||||
|
pub use all_item_types::FOO_STATIC;
|
||||||
|
|
||||||
|
// @has 'foo/index.html' '//a[@href="../all_item_types/constant.FOO_CONSTANT.html"]' 'FOO_CONSTANT'
|
||||||
|
#[doc(no_inline)]
|
||||||
|
pub use all_item_types::FOO_CONSTANT;
|
||||||
|
|
||||||
|
// @has 'foo/index.html' '//a[@href="../all_item_types/macro.foo_macro.html"]' 'foo_macro'
|
||||||
|
#[doc(no_inline)]
|
||||||
|
pub use all_item_types::foo_macro;
|
Loading…
Add table
Add a link
Reference in a new issue