Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7d7221c
typeck: adding type information to projection
Azhng Jun 24, 2020
8dc1e42
libstd/net/tcp.rs: #![deny(unsafe_op_in_unsafe_fn)]
ryr3 Jul 2, 2020
ec31b4e
Audit uses of `span_suggestion_short`
JohnTitor Jul 2, 2020
84282fd
Audit uses of `tool_only_span_suggestion`
JohnTitor Jul 2, 2020
1b747a0
mir: mark mir construction temporaries as internal
davidtwco Jul 2, 2020
7391bf8
Move A|Rc::as_ptr from feature(weak_into_raw)
CAD97 Jul 2, 2020
2f31426
rustdoc: Restore underline text decoration on hover for FQN in header
rye Jul 5, 2020
5fa19ad
Remove unused RUSTC_DEBUG_ASSERTIONS
tmiasko Jul 6, 2020
f226e6b
Add `read_exact_at` and `write_all_at` to WASI's `FileExt`
sunfishcode Jul 3, 2020
6196eaa
Fix the return type of Windows' `OpenOptionsExt::security_qos_flags`.
sunfishcode Jul 3, 2020
e46c187
Always resolve type@primitive as a primitive, not a module
jyn514 Jul 6, 2020
fdd39a3
Add rust-analyzer to the build manifest
matklad Jul 6, 2020
96a8f37
Rollup merge of #73870 - sexxi-goose:projection-ty, r=nikomatsakis
Manishearth Jul 6, 2020
a394dee
Rollup merge of #73953 - JohnTitor:audit-hidden-sugg, r=estebank
Manishearth Jul 6, 2020
ac069b2
Rollup merge of #73962 - ryr3:unsafe_tcp, r=LukasKalbertodt
Manishearth Jul 6, 2020
31690ac
Rollup merge of #73969 - davidtwco:issue-73914-checkedadd-temp-genera…
Manishearth Jul 6, 2020
bbf3efa
Rollup merge of #73974 - CAD97:rc-no-weak, r=dtolnay
Manishearth Jul 6, 2020
26935a4
Rollup merge of #74067 - rye:rustdoc-fqn-hover-underline, r=Guillaume…
Manishearth Jul 6, 2020
a16490e
Rollup merge of #74074 - sunfishcode:windows-openoptionsext-return-ty…
Manishearth Jul 6, 2020
53dee43
Rollup merge of #74076 - sunfishcode:wasi-fileext-newmethods, r=alexc…
Manishearth Jul 6, 2020
6819d56
Rollup merge of #74078 - jyn514:lut, r=Manishearth
Manishearth Jul 6, 2020
95f3c5d
Rollup merge of #74089 - matklad:ship-rust-analyzer-some-more, r=piet…
Manishearth Jul 6, 2020
0eba54f
Rollup merge of #74090 - tmiasko:rustc-debug-assertions, r=RalfJung
Manishearth Jul 6, 2020
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
fn resolve(
&self,
path_str: &str,
disambiguator: Option<&str>,
ns: Namespace,
current_item: &Option<String>,
parent_id: Option<hir::HirId>,
Expand Down Expand Up @@ -203,11 +204,22 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
}
return Ok((res, Some(path_str.to_owned())));
}
other => {
debug!(
"failed to resolve {} in namespace {:?} (got {:?})",
path_str, ns, other
);
Res::Def(DefKind::Mod, _) => {
// This resolved to a module, but if we were passed `type@`,
// we want primitive types to take precedence instead.
if disambiguator == Some("type") {
if let Some(prim) = is_primitive(path_str, ns) {
if extra_fragment.is_some() {
return Err(ErrorKind::AnchorFailure(
"primitive types cannot be followed by anchors",
));
}
return Ok((prim, Some(path_str.to_owned())));
}
}
return Ok((res, extra_fragment.clone()));
}
_ => {
return Ok((res, extra_fragment.clone()));
}
};
Expand Down Expand Up @@ -566,11 +578,13 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
let mut path_str;
let (res, fragment) = {
let mut kind = None;
let mut disambiguator = None;
path_str = if let Some(prefix) = ["struct@", "enum@", "type@", "trait@", "union@"]
.iter()
.find(|p| link.starts_with(**p))
{
kind = Some(TypeNS);
disambiguator = Some(&prefix[..prefix.len() - 1]);
link.trim_start_matches(prefix)
} else if let Some(prefix) = [
"const@",
Expand All @@ -586,18 +600,23 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
.find(|p| link.starts_with(**p))
{
kind = Some(ValueNS);
disambiguator = Some(&prefix[..prefix.len() - 1]);
link.trim_start_matches(prefix)
} else if link.ends_with("()") {
kind = Some(ValueNS);
disambiguator = Some("fn");
link.trim_end_matches("()")
} else if link.starts_with("macro@") {
kind = Some(MacroNS);
disambiguator = Some("macro");
link.trim_start_matches("macro@")
} else if link.starts_with("derive@") {
kind = Some(MacroNS);
disambiguator = Some("derive");
link.trim_start_matches("derive@")
} else if link.ends_with('!') {
kind = Some(MacroNS);
disambiguator = Some("macro");
link.trim_end_matches('!')
} else {
&link[..]
Expand Down Expand Up @@ -634,6 +653,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
Some(ns @ ValueNS) => {
match self.resolve(
path_str,
disambiguator,
ns,
&current_item,
base_node,
Expand All @@ -657,6 +677,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
Some(ns @ TypeNS) => {
match self.resolve(
path_str,
disambiguator,
ns,
&current_item,
base_node,
Expand All @@ -683,6 +704,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
.map(|res| (res, extra_fragment.clone())),
type_ns: match self.resolve(
path_str,
disambiguator,
TypeNS,
&current_item,
base_node,
Expand All @@ -697,6 +719,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
},
value_ns: match self.resolve(
path_str,
disambiguator,
ValueNS,
&current_item,
base_node,
Expand Down
12 changes: 12 additions & 0 deletions src/test/rustdoc/intra-link-prim-precedence.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// ignore-tidy-linelength
#![deny(intra_doc_resolution_failure)]

pub mod char {}

/// See also [type@char]
// @has intra_link_prim_precedence/struct.MyString.html '//a/@href' 'https://doc.rust-lang.org/nightly/std/primitive.char.html'
pub struct MyString;

/// See also [char]
// @has intra_link_prim_precedence/struct.MyString2.html '//a/@href' 'intra_link_prim_precedence/char/index.html'
pub struct MyString2;