Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
274e299
Stablize slice::strip_prefix and strip_suffix, with SlicePattern
ijackson Oct 12, 2020
f51b681
Use existing slice_pattern feature for SlicePattern
ijackson Dec 12, 2020
beb293d
Drop pointless as_slice call.
ijackson Dec 27, 2020
03b4ea4
Mark SlicePattern trait uses as ?Sized
ijackson Dec 27, 2020
8b2e79d
Add test for slice as prefix/suffix pattern
ijackson Dec 27, 2020
9a240e4
Edit rustc_ast::tokenstream docs
pierwill Jan 3, 2021
b4a0ef0
fix issue 80559
max-heller Jan 3, 2021
e33a205
primitive disambiguator tests
max-heller Jan 4, 2021
fc3a405
still verify disambiguators for primitives
max-heller Jan 4, 2021
06b0900
half working
max-heller Jan 4, 2021
6f04133
fix incompatible disambiguator test
max-heller Jan 4, 2021
2bdbb0d
Document hackiness around primitive associated item disambiguators
max-heller Jan 5, 2021
aea9a4b
Remove bottom margin from crate version when the sidebar is collapsed.
arusahni Jan 5, 2021
e636805
rustdoc: Turn `next_def_id` comments into docs
camelid Jan 6, 2021
1a2ee0b
Update cargo
ehuss Jan 6, 2021
7428e2d
Apply suggestions from code review
camelid Jan 6, 2021
7bc22e9
Don't use to_string on Symbol
GuillaumeGomez Jan 6, 2021
fa4d8bc
Prefer enum Endian in rustc_target::Target
tesuji Jan 5, 2021
8ee804d
Change related spec files to use the new enum
tesuji Jan 5, 2021
3f74fbd
handle generic trait methods in coverage tests
andjo403 Jan 6, 2021
f03907b
Add pointing const identifier when emitting E0435
sasurau4 Dec 13, 2020
c9e7045
bless tests
sasurau4 Dec 13, 2020
c71348a
Refine E0435 description
sasurau4 Dec 26, 2020
f942c3c
Return EOF_CHAR constant instead of magic char.
Jan 7, 2021
bc751f2
Rollup merge of #77853 - ijackson:slice-strip-stab, r=Amanieu
Dylan-DPC Jan 7, 2021
72dfeff
Rollup merge of #80012 - sasurau4:feature/point-constant-identifier-E…
Dylan-DPC Jan 7, 2021
7a1c817
Rollup merge of #80659 - pierwill:edit-tokenstream, r=davidtwco
Dylan-DPC Jan 7, 2021
208710a
Rollup merge of #80660 - max-heller:issue-80559-fix, r=jyn514
Dylan-DPC Jan 7, 2021
69daa35
Rollup merge of #80709 - lzutao:target-enumerate, r=petrochenkov
Dylan-DPC Jan 7, 2021
9342728
Rollup merge of #80738 - arusahni:master, r=GuillaumeGomez
Dylan-DPC Jan 7, 2021
55c007a
Rollup merge of #80744 - camelid:next_def_id-docs, r=jyn514
Dylan-DPC Jan 7, 2021
cc1238f
Rollup merge of #80746 - ehuss:update-cargo, r=ehuss
Dylan-DPC Jan 7, 2021
9558447
Rollup merge of #80750 - GuillaumeGomez:cleanup-to_string, r=lzutao
Dylan-DPC Jan 7, 2021
38ccca7
Rollup merge of #80761 - andjo403:generic_coverage, r=wesleywiser
Dylan-DPC Jan 7, 2021
e4ecfea
Rollup merge of #80780 - lianghanzhen:master, r=petrochenkov
Dylan-DPC Jan 7, 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
Prev Previous commit
Next Next commit
half working
  • Loading branch information
max-heller committed Jan 4, 2021
commit 06b0900a2dc53ed4b5fa98c859fec5c224929eb8
101 changes: 51 additions & 50 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1147,69 +1147,70 @@ impl LinkCollector<'_, '_> {
);
};

let (kind, id) = match res {
let verify = |kind: DefKind, id: DefId| {
debug!("intra-doc link to {} resolved to {:?}", path_str, res);

// Disallow e.g. linking to enums with `struct@`
debug!("saw kind {:?} with disambiguator {:?}", kind, disambiguator);
match (self.kind_side_channel.take().map(|(kind, _)| kind).unwrap_or(kind), disambiguator) {
| (DefKind::Const | DefKind::ConstParam | DefKind::AssocConst | DefKind::AnonConst, Some(Disambiguator::Kind(DefKind::Const)))
// NOTE: this allows 'method' to mean both normal functions and associated functions
// This can't cause ambiguity because both are in the same namespace.
| (DefKind::Fn | DefKind::AssocFn, Some(Disambiguator::Kind(DefKind::Fn)))
// These are namespaces; allow anything in the namespace to match
| (_, Some(Disambiguator::Namespace(_)))
// If no disambiguator given, allow anything
| (_, None)
// All of these are valid, so do nothing
=> {}
(actual, Some(Disambiguator::Kind(expected))) if actual == expected => {}
(_, Some(specified @ Disambiguator::Kind(_) | specified @ Disambiguator::Primitive)) => {
report_mismatch(specified, Disambiguator::Kind(kind));
return None;
}
}

// item can be non-local e.g. when using #[doc(primitive = "pointer")]
if let Some((src_id, dst_id)) = id
.as_local()
.and_then(|dst_id| item.def_id.as_local().map(|src_id| (src_id, dst_id)))
{
use rustc_hir::def_id::LOCAL_CRATE;

let hir_src = self.cx.tcx.hir().local_def_id_to_hir_id(src_id);
let hir_dst = self.cx.tcx.hir().local_def_id_to_hir_id(dst_id);

if self.cx.tcx.privacy_access_levels(LOCAL_CRATE).is_exported(hir_src)
&& !self.cx.tcx.privacy_access_levels(LOCAL_CRATE).is_exported(hir_dst)
{
privacy_error(cx, &item, &path_str, dox, &ori_link);
}
}

Some((kind, id))
};

match res {
Res::Primitive(_) => {
if let Some((kind, id)) = self.kind_side_channel.take() {
(kind, id)
verify(kind, id)?;
} else {
match disambiguator {
Some(Disambiguator::Primitive | Disambiguator::Namespace(_)) | None => {
return Some(ItemLink {
link: ori_link.link,
link_text,
did: None,
fragment,
});
}
Some(Disambiguator::Primitive | Disambiguator::Namespace(_)) | None => {}
Some(other) => {
report_mismatch(other, Disambiguator::Primitive);
return None;
}
}
}
Some(ItemLink { link: ori_link.link, link_text, did: None, fragment })
}
Res::Def(kind, id) => (kind, id),
};

debug!("intra-doc link to {} resolved to {:?}", path_str, res);

// Disallow e.g. linking to enums with `struct@`
debug!("saw kind {:?} with disambiguator {:?}", kind, disambiguator);
match (self.kind_side_channel.take().map(|(kind, _)| kind).unwrap_or(kind), disambiguator) {
| (DefKind::Const | DefKind::ConstParam | DefKind::AssocConst | DefKind::AnonConst, Some(Disambiguator::Kind(DefKind::Const)))
// NOTE: this allows 'method' to mean both normal functions and associated functions
// This can't cause ambiguity because both are in the same namespace.
| (DefKind::Fn | DefKind::AssocFn, Some(Disambiguator::Kind(DefKind::Fn)))
// These are namespaces; allow anything in the namespace to match
| (_, Some(Disambiguator::Namespace(_)))
// If no disambiguator given, allow anything
| (_, None)
// All of these are valid, so do nothing
=> {}
(actual, Some(Disambiguator::Kind(expected))) if actual == expected => {}
(_, Some(specified @ Disambiguator::Kind(_) | specified @ Disambiguator::Primitive)) => {
report_mismatch(specified, Disambiguator::Kind(kind));
return None;
}
}

// item can be non-local e.g. when using #[doc(primitive = "pointer")]
if let Some((src_id, dst_id)) =
id.as_local().and_then(|dst_id| item.def_id.as_local().map(|src_id| (src_id, dst_id)))
{
use rustc_hir::def_id::LOCAL_CRATE;

let hir_src = self.cx.tcx.hir().local_def_id_to_hir_id(src_id);
let hir_dst = self.cx.tcx.hir().local_def_id_to_hir_id(dst_id);

if self.cx.tcx.privacy_access_levels(LOCAL_CRATE).is_exported(hir_src)
&& !self.cx.tcx.privacy_access_levels(LOCAL_CRATE).is_exported(hir_dst)
{
privacy_error(cx, &item, &path_str, dox, &ori_link);
Res::Def(kind, id) => {
let (kind, id) = verify(kind, id)?;
let id = clean::register_res(cx, rustc_hir::def::Res::Def(kind, id));
Some(ItemLink { link: ori_link.link, link_text, did: Some(id), fragment })
}
}
let id = clean::register_res(cx, rustc_hir::def::Res::Def(kind, id));
Some(ItemLink { link: ori_link.link, link_text, did: Some(id), fragment })
}

fn resolve_with_disambiguator_cached(
Expand Down