Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ab1e634
Make `fold_item_recur` non-nullable
jyn514 Nov 22, 2020
0043fc9
Get rid of `doctree::Impl`
jyn514 Nov 22, 2020
0b6537a
Accept '!' in intra-doc links
camelid Nov 22, 2020
fafe3cd
Allow using `-Z fewer-names=no` to retain value names
tmiasko Nov 23, 2020
c5c3d7b
Fix typo in keyword docs for traits
Takashiidobe Nov 23, 2020
8526c31
BTreeMap: cut out the ceremony around BoxedNode
ssomers Nov 23, 2020
9c8db45
BTreeMap/BTreeSet: make public doc more consistent
ssomers Nov 23, 2020
7b62e09
Allow disabling TrapUnreachable via -Ztrap-unreachable=no
Dirbaio Nov 23, 2020
5b1cb0e
Add exploit mitigations chapter to the rustc book
rcvalle Sep 18, 2020
b7593e5
Add note to use nightly when using expr in const generics
mendess Nov 24, 2020
af978e3
Requested changes
mendess Nov 24, 2020
888055e
Swap note for help
mendess Nov 24, 2020
8fde4be
Rollup merge of #76858 - rcvalle:rust-lang-exploit-mitigations, r=ste…
jonas-schievink Nov 24, 2020
f74b223
Rollup merge of #79310 - jyn514:fold-item-cleanup, r=GuillaumeGomez
jonas-schievink Nov 24, 2020
5a66a73
Rollup merge of #79312 - jyn514:doctree-impl, r=GuillaumeGomez
jonas-schievink Nov 24, 2020
3f36f92
Rollup merge of #79321 - camelid:intra-doc-bang, r=Manishearth
jonas-schievink Nov 24, 2020
3a728bd
Rollup merge of #79346 - tmiasko:more-names, r=jonas-schievink
jonas-schievink Nov 24, 2020
ed5d539
Rollup merge of #79351 - Takashiidobe:keyword-docs-typo, r=m-ou-se
jonas-schievink Nov 24, 2020
012d5fd
Rollup merge of #79354 - ssomers:btree_bereave_BoxedNode, r=Mark-Simu…
jonas-schievink Nov 24, 2020
ce19796
Rollup merge of #79358 - ssomers:btree_public_comments, r=Mark-Simula…
jonas-schievink Nov 24, 2020
95e7af3
Rollup merge of #79367 - Dirbaio:trap-unreachable, r=jonas-schievink
jonas-schievink Nov 24, 2020
f049b0b
Rollup merge of #79374 - mendess:const-param-expr-diagnostic, r=lcnr
jonas-schievink Nov 24, 2020
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
13 changes: 5 additions & 8 deletions src/librustdoc/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl StripItem {

crate trait DocFolder: Sized {
fn fold_item(&mut self, item: Item) -> Option<Item> {
self.fold_item_recur(item)
Some(self.fold_item_recur(item))
}

/// don't override!
Expand Down Expand Up @@ -71,15 +71,12 @@ crate trait DocFolder: Sized {
}

/// don't override!
fn fold_item_recur(&mut self, item: Item) -> Option<Item> {
let Item { attrs, name, source, visibility, def_id, kind, stability, deprecation } = item;

let kind = match kind {
fn fold_item_recur(&mut self, mut item: Item) -> Item {
item.kind = match item.kind {
StrippedItem(box i) => StrippedItem(box self.fold_inner_recur(i)),
_ => self.fold_inner_recur(kind),
_ => self.fold_inner_recur(item.kind),
};

Some(Item { attrs, name, source, kind, visibility, stability, deprecation, def_id })
item
}

fn fold_mod(&mut self, m: Module) -> Module {
Expand Down
77 changes: 37 additions & 40 deletions src/librustdoc/formats/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,55 +421,52 @@ impl DocFolder for Cache {

// Once we've recursively found all the generics, hoard off all the
// implementations elsewhere.
let ret = self.fold_item_recur(item).and_then(|item| {
if let clean::Item { kind: clean::ImplItem(_), .. } = item {
// Figure out the id of this impl. This may map to a
// primitive rather than always to a struct/enum.
// Note: matching twice to restrict the lifetime of the `i` borrow.
let mut dids = FxHashSet::default();
if let clean::Item { kind: clean::ImplItem(ref i), .. } = item {
match i.for_ {
clean::ResolvedPath { did, .. }
| clean::BorrowedRef {
type_: box clean::ResolvedPath { did, .. }, ..
} => {
dids.insert(did);
}
ref t => {
let did = t
.primitive_type()
.and_then(|t| self.primitive_locations.get(&t).cloned());
let item = self.fold_item_recur(item);
let ret = if let clean::Item { kind: clean::ImplItem(_), .. } = item {
// Figure out the id of this impl. This may map to a
// primitive rather than always to a struct/enum.
// Note: matching twice to restrict the lifetime of the `i` borrow.
let mut dids = FxHashSet::default();
if let clean::Item { kind: clean::ImplItem(ref i), .. } = item {
match i.for_ {
clean::ResolvedPath { did, .. }
| clean::BorrowedRef { type_: box clean::ResolvedPath { did, .. }, .. } => {
dids.insert(did);
}
ref t => {
let did = t
.primitive_type()
.and_then(|t| self.primitive_locations.get(&t).cloned());

if let Some(did) = did {
dids.insert(did);
}
if let Some(did) = did {
dids.insert(did);
}
}
}

if let Some(generics) = i.trait_.as_ref().and_then(|t| t.generics()) {
for bound in generics {
if let Some(did) = bound.def_id() {
dids.insert(did);
}
if let Some(generics) = i.trait_.as_ref().and_then(|t| t.generics()) {
for bound in generics {
if let Some(did) = bound.def_id() {
dids.insert(did);
}
}
} else {
unreachable!()
};
let impl_item = Impl { impl_item: item };
if impl_item.trait_did().map_or(true, |d| self.traits.contains_key(&d)) {
for did in dids {
self.impls.entry(did).or_insert(vec![]).push(impl_item.clone());
}
} else {
let trait_did = impl_item.trait_did().expect("no trait did");
self.orphan_trait_impls.push((trait_did, dids, impl_item));
}
None
} else {
Some(item)
unreachable!()
};
let impl_item = Impl { impl_item: item };
if impl_item.trait_did().map_or(true, |d| self.traits.contains_key(&d)) {
for did in dids {
self.impls.entry(did).or_insert(vec![]).push(impl_item.clone());
}
} else {
let trait_did = impl_item.trait_did().expect("no trait did");
self.orphan_trait_impls.push((trait_did, dids, impl_item));
}
});
None
} else {
Some(item)
};

if pushed {
self.stack.pop().expect("stack already empty");
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl<'a> DocFolder for SourceCollector<'a> {
}
};
}
self.fold_item_recur(item)
Some(self.fold_item_recur(item))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/passes/calculate_doc_coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,6 @@ impl<'a, 'b> fold::DocFolder for CoverageCalculator<'a, 'b> {
}
}

self.fold_item_recur(i)
Some(self.fold_item_recur(i))
}
}
2 changes: 1 addition & 1 deletion src/librustdoc/passes/check_code_block_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl<'a, 'tcx> DocFolder for SyntaxChecker<'a, 'tcx> {
}
}

self.fold_item_recur(item)
Some(self.fold_item_recur(item))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/passes/collapse_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct Collapser;
impl fold::DocFolder for Collapser {
fn fold_item(&mut self, mut i: Item) -> Option<Item> {
i.attrs.collapse_doc_comments();
self.fold_item_recur(i)
Some(self.fold_item_recur(i))
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
// we don't display docs on `extern crate` items anyway, so don't process them.
clean::ExternCrateItem(..) => {
debug!("ignoring extern crate item {:?}", item.def_id);
return self.fold_item_recur(item);
return Some(self.fold_item_recur(item));
}
clean::ImportItem(Import { kind: clean::ImportKind::Simple(ref name, ..), .. }) => {
Some(name.clone())
Expand Down Expand Up @@ -958,7 +958,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
}
}

if item.is_mod() {
Some(if item.is_mod() {
if !item.attrs.inner_docs {
self.mod_ids.push(item.def_id);
}
Expand All @@ -968,7 +968,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
ret
} else {
self.fold_item_recur(item)
}
})
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/passes/collect_trait_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl<'a, 'tcx> DocFolder for SyntheticImplCollector<'a, 'tcx> {
}
}

self.fold_item_recur(i)
Some(self.fold_item_recur(i))
}
}

Expand All @@ -152,7 +152,7 @@ impl DocFolder for ItemCollector {
fn fold_item(&mut self, i: Item) -> Option<Item> {
self.items.insert(i.def_id);

self.fold_item_recur(i)
Some(self.fold_item_recur(i))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/passes/doc_test_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<'a, 'tcx> DocFolder for PrivateItemDocTestLinter<'a, 'tcx> {

look_for_tests(&cx, &dox, &item);

self.fold_item_recur(item)
Some(self.fold_item_recur(item))
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/passes/html_tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl<'a, 'tcx> DocFolder for InvalidHtmlTagsLinter<'a, 'tcx> {
Some(hir_id) => hir_id,
None => {
// If non-local, no need to check anything.
return self.fold_item_recur(item);
return Some(self.fold_item_recur(item));
}
};
let dox = item.attrs.collapsed_doc_value().unwrap_or_default();
Expand Down Expand Up @@ -223,6 +223,6 @@ impl<'a, 'tcx> DocFolder for InvalidHtmlTagsLinter<'a, 'tcx> {
}
}

self.fold_item_recur(item)
Some(self.fold_item_recur(item))
}
}
4 changes: 2 additions & 2 deletions src/librustdoc/passes/non_autolinks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl<'a, 'tcx> DocFolder for NonAutolinksLinter<'a, 'tcx> {
Some(hir_id) => hir_id,
None => {
// If non-local, no need to check anything.
return self.fold_item_recur(item);
return Some(self.fold_item_recur(item));
}
};
let dox = item.attrs.collapsed_doc_value().unwrap_or_default();
Expand Down Expand Up @@ -133,6 +133,6 @@ impl<'a, 'tcx> DocFolder for NonAutolinksLinter<'a, 'tcx> {
}
}

self.fold_item_recur(item)
Some(self.fold_item_recur(item))
}
}
2 changes: 1 addition & 1 deletion src/librustdoc/passes/propagate_doc_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ impl DocFolder for CfgPropagator {
let result = self.fold_item_recur(item);
self.parent_cfg = old_parent_cfg;

result
Some(result)
}
}
4 changes: 2 additions & 2 deletions src/librustdoc/passes/strip_hidden.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl<'a> DocFolder for Stripper<'a> {
// strip things like impl methods but when doing so
// we must not add any items to the `retained` set.
let old = mem::replace(&mut self.update_retained, false);
let ret = StripItem(self.fold_item_recur(i).unwrap()).strip();
let ret = StripItem(self.fold_item_recur(i)).strip();
self.update_retained = old;
return ret;
}
Expand All @@ -58,6 +58,6 @@ impl<'a> DocFolder for Stripper<'a> {
self.retained.insert(i.def_id);
}
}
self.fold_item_recur(i)
Some(self.fold_item_recur(i))
}
}
16 changes: 7 additions & 9 deletions src/librustdoc/passes/stripper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl<'a> DocFolder for Stripper<'a> {
let old = mem::replace(&mut self.update_retained, false);
let ret = self.fold_item_recur(i);
self.update_retained = old;
return ret;
return Some(ret);
}
// These items can all get re-exported
clean::OpaqueTyItem(..)
Expand Down Expand Up @@ -59,7 +59,7 @@ impl<'a> DocFolder for Stripper<'a> {
if i.def_id.is_local() && !i.visibility.is_public() {
debug!("Stripper: stripping module {:?}", i.name);
let old = mem::replace(&mut self.update_retained, false);
let ret = StripItem(self.fold_item_recur(i).unwrap()).strip();
let ret = StripItem(self.fold_item_recur(i)).strip();
self.update_retained = old;
return ret;
}
Expand Down Expand Up @@ -107,12 +107,10 @@ impl<'a> DocFolder for Stripper<'a> {
self.fold_item_recur(i)
};

if let Some(ref i) = i {
if self.update_retained {
self.retained.insert(i.def_id);
}
if self.update_retained {
self.retained.insert(i.def_id);
}
i
Some(i)
}
}

Expand Down Expand Up @@ -153,7 +151,7 @@ impl<'a> DocFolder for ImplStripper<'a> {
}
}
}
self.fold_item_recur(i)
Some(self.fold_item_recur(i))
}
}

Expand All @@ -164,7 +162,7 @@ impl DocFolder for ImportStripper {
fn fold_item(&mut self, i: Item) -> Option<Item> {
match i.kind {
clean::ExternCrateItem(..) | clean::ImportItem(..) if !i.visibility.is_public() => None,
_ => self.fold_item_recur(i),
_ => Some(self.fold_item_recur(i)),
}
}
}
2 changes: 1 addition & 1 deletion src/librustdoc/passes/unindent_comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct CommentCleaner;
impl fold::DocFolder for CommentCleaner {
fn fold_item(&mut self, mut i: Item) -> Option<Item> {
i.attrs.unindent_doc_comments();
self.fold_item_recur(i)
Some(self.fold_item_recur(i))
}
}

Expand Down