Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 12 pull requests #86526

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5bbf8cf
Revert SGX inline asm syntax
May 7, 2021
08d44c2
Implement `Cursor::{remaining, is_empty}`
soerenmeier Jun 5, 2021
5fb2986
format symbols under shared frames
KodrAus Dec 4, 2020
8423a19
make both panic display formats collapse frames
KodrAus Dec 16, 2020
6c65a13
SocketAddr of Unix Sockets use sun_len as path's length in BSD-like OSes
zonyitoo Jun 15, 2021
95c1bf6
Allow to pass arguments to rustdoc-gui tool
GuillaumeGomez Jun 14, 2021
212e91a
Update tracking issue
soerenmeier Jun 16, 2021
503abc7
add regression test for issue #39161
yerke Jun 16, 2021
636170a
Remove `#[allow(unused_lifetimes)]` which is now unnecessary
JohnTitor Jun 16, 2021
664bde0
rename `remaining` to `remaining_slice` and add a new `remaining`
soerenmeier Jun 17, 2021
13bfbb4
Fix comment about rustc_inherit_overflow_checks in abs().
m-ou-se Jun 16, 2021
22029a2
add regression test for issue #54685
yerke Jun 18, 2021
4cd2fab
Specify if struct/enum in arg mismatch error
syvb Jun 20, 2021
9063eda
Move `available_concurrency` implementation to `sys`
CDirkx Apr 29, 2021
dd90900
Resolve type aliases to the type they point to in intra-doc links
LeSeulArtichaut Jun 15, 2021
05ec710
Remove tidy exception for `available_concurrency`
CDirkx May 11, 2021
888418a
Use `Unsupported` on platforms where `available_concurrency` is not i…
CDirkx Jun 21, 2021
b8a7bfb
Reference issue test originated from
syvb Jun 21, 2021
dfeb064
Rollup merge of #85054 - jethrogb:jb/sgx-inline-asm, r=Amanieu
JohnTitor Jun 21, 2021
c7db34a
Rollup merge of #85182 - CDirkx:available_concurrency, r=JohnTitor
JohnTitor Jun 21, 2021
0f6b73b
Rollup merge of #86037 - soerenmeier:cursor_remaining, r=yaahc
JohnTitor Jun 21, 2021
b79239c
Rollup merge of #86114 - JDuchniewicz:feat/panic-frame-fmt, r=yaahc
JohnTitor Jun 21, 2021
77569d9
Rollup merge of #86297 - GuillaumeGomez:rustdoc-gui-args, r=Mark-Simu…
JohnTitor Jun 21, 2021
56e4950
Rollup merge of #86318 - zonyitoo:master, r=yaahc
JohnTitor Jun 21, 2021
2706138
Rollup merge of #86334 - LeSeulArtichaut:86120-links-type-aliases, r=…
JohnTitor Jun 21, 2021
4706e45
Rollup merge of #86367 - m-ou-se:fix-abs-comment, r=scottmcm
JohnTitor Jun 21, 2021
63ad2ea
Rollup merge of #86381 - yerke:add-test-for-issue-39161, r=JohnTitor
JohnTitor Jun 21, 2021
e1f5338
Rollup merge of #86387 - JohnTitor:now-no-unused-lifetimes, r=Mark-Si…
JohnTitor Jun 21, 2021
26a6d38
Rollup merge of #86398 - yerke:add-test-for-issue-54685, r=Mark-Simul…
JohnTitor Jun 21, 2021
5f0aea3
Rollup merge of #86493 - Smittyvb:ctor-typeck-error, r=davidtwco
JohnTitor Jun 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 46 additions & 5 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,44 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
})
}

/// Convert a DefId to a Res, where possible.
///
/// This is used for resolving type aliases.
fn def_id_to_res(&self, ty_id: DefId) -> Option<Res> {
use PrimitiveType::*;
Some(match *self.cx.tcx.type_of(ty_id).kind() {
ty::Bool => Res::Primitive(Bool),
ty::Char => Res::Primitive(Char),
ty::Int(ity) => Res::Primitive(ity.into()),
ty::Uint(uty) => Res::Primitive(uty.into()),
ty::Float(fty) => Res::Primitive(fty.into()),
ty::Str => Res::Primitive(Str),
ty::Tuple(ref tys) if tys.is_empty() => Res::Primitive(Unit),
ty::Tuple(_) => Res::Primitive(Tuple),
ty::Array(..) => Res::Primitive(Array),
ty::Slice(_) => Res::Primitive(Slice),
ty::RawPtr(_) => Res::Primitive(RawPointer),
ty::Ref(..) => Res::Primitive(Reference),
ty::FnDef(..) => panic!("type alias to a function definition"),
ty::FnPtr(_) => Res::Primitive(Fn),
ty::Never => Res::Primitive(Never),
ty::Adt(&ty::AdtDef { did, .. }, _) | ty::Foreign(did) => {
Res::Def(self.cx.tcx.def_kind(did), did)
}
ty::Projection(_)
| ty::Closure(..)
| ty::Generator(..)
| ty::GeneratorWitness(_)
| ty::Opaque(..)
| ty::Dynamic(..)
| ty::Param(_)
| ty::Bound(..)
| ty::Placeholder(_)
| ty::Infer(_)
| ty::Error(_) => return None,
})
}

/// Returns:
/// - None if no associated item was found
/// - Some((_, _, Some(_))) if an item was found and should go through a side channel
Expand All @@ -559,12 +597,15 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {

match root_res {
Res::Primitive(prim) => self.resolve_primitive_associated_item(prim, ns, item_name),
Res::Def(DefKind::TyAlias, did) => {
// Resolve the link on the type the alias points to.
// FIXME: if the associated item is defined directly on the type alias,
// it will show up on its documentation page, we should link there instead.
let res = self.def_id_to_res(did)?;
self.resolve_associated_item(res, item_name, ns, module_id)
}
Res::Def(
DefKind::Struct
| DefKind::Union
| DefKind::Enum
| DefKind::TyAlias
| DefKind::ForeignTy,
DefKind::Struct | DefKind::Union | DefKind::Enum | DefKind::ForeignTy,
did,
) => {
debug!("looking for associated item named {} for item {:?}", item_name, did);
Expand Down
19 changes: 19 additions & 0 deletions src/test/rustdoc/intra-doc/type-alias.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Regression test for issue #86120.

#![deny(broken_intra_doc_links)]
#![crate_name = "foo"]

pub struct Foo;

/// You should really try [`Self::bar`]!
pub type Bar = Foo;

impl Bar {
pub fn bar() {}
}

/// The minimum is [`Self::MIN`].
pub type Int = i32;

// @has foo/type.Bar.html '//a[@href="struct.Foo.html#method.bar"]' 'Self::bar'
// @has foo/type.Int.html '//a[@href="{{channel}}/std/primitive.i32.html#associatedconstant.MIN"]' 'Self::MIN'