Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c28f2a8
Stabilize str_split_once
jhpratt Feb 9, 2021
4c70372
Make ItemKind::ExternCrate looks like hir::ItemKind::ExternCrate to m…
GuillaumeGomez Feb 15, 2021
5ff1be1
replaced some unwrap_or with unwrap_or_else
klensy Feb 23, 2021
c75c4a5
replaced some map_or with map_or_else
klensy Feb 23, 2021
6d5c0c1
Consider inexpensive inlining criteria first
tmiasko Feb 24, 2021
08b1e80
fix review
klensy Feb 25, 2021
fb24a10
Properly account for non-shorthand pattern field in unused variable lint
estebank Feb 25, 2021
356beb3
clarifies error when finding mismatched returned types for async func…
nellshamrell Feb 15, 2021
e130e9c
Update measureme dependency to the latest version
wesleywiser Feb 25, 2021
9d3739d
Set codegen thread names
wesleywiser Feb 18, 2021
c47903f
Add optional woff2 versions of FiraSans.
jsha Feb 26, 2021
ad7ed13
Embed woff2 files in rustdoc binary.
jsha Feb 26, 2021
91c246b
Rollup merge of #80845 - GuillaumeGomez:item-kind-transition, r=jyn514
GuillaumeGomez Feb 26, 2021
dc34ead
Rollup merge of #81940 - jhpratt:stabilize-str_split_once, r=m-ou-se
GuillaumeGomez Feb 26, 2021
3ddc7d4
Rollup merge of #82165 - nellshamrell:nell/fix-80658-B, r=estebank
GuillaumeGomez Feb 26, 2021
e11393a
Rollup merge of #82456 - klensy:or-else, r=estebank
GuillaumeGomez Feb 26, 2021
443c483
Rollup merge of #82491 - tmiasko:i, r=lcnr
GuillaumeGomez Feb 26, 2021
f6e77e8
Rollup merge of #82506 - estebank:unused_variable_lint, r=lcnr
GuillaumeGomez Feb 26, 2021
5964b43
Rollup merge of #82535 - wesleywiser:wip_codegen_thread_names, r=nagisa
GuillaumeGomez Feb 26, 2021
812d78f
Rollup merge of #82537 - wesleywiser:update_measureme, r=oli-obk
GuillaumeGomez Feb 26, 2021
65f3751
Rollup merge of #82545 - jsha:woff2, r=GuillaumeGomez
GuillaumeGomez Feb 26, 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
Make ItemKind::ExternCrate looks like hir::ItemKind::ExternCrate to m…
…ake transition over hir::ItemKind simpler
  • Loading branch information
GuillaumeGomez committed Feb 23, 2021
commit 4c70372b0c3f82fefb283f8d2d703dbcf0cb13f4
4 changes: 2 additions & 2 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2132,12 +2132,12 @@ fn clean_extern_crate(
}
// FIXME: using `from_def_id_and_kind` breaks `rustdoc/masked` for some reason
vec![Item {
name: None,
name: Some(name),
attrs: box krate.attrs.clean(cx),
source: krate.span.clean(cx),
def_id: crate_def_id,
visibility: krate.vis.clean(cx),
kind: box ExternCrateItem(name, orig_name),
kind: box ExternCrateItem { src: orig_name },
}]
}

Expand Down
7 changes: 5 additions & 2 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,10 @@ impl Item {

#[derive(Clone, Debug)]
crate enum ItemKind {
ExternCrateItem(Symbol, Option<Symbol>),
ExternCrateItem {
/// The crate's name, *not* the name it's imported as.
src: Option<Symbol>,
},
ImportItem(Import),
StructItem(Struct),
UnionItem(Union),
Expand Down Expand Up @@ -354,7 +357,7 @@ impl ItemKind {
TraitItem(t) => t.items.iter(),
ImplItem(i) => i.items.iter(),
ModuleItem(m) => m.items.iter(),
ExternCrateItem(_, _)
ExternCrateItem { .. }
| ImportItem(_)
| FunctionItem(_)
| TypedefItem(_, _)
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/formats/item_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl<'a> From<&'a clean::Item> for ItemType {

match *kind {
clean::ModuleItem(..) => ItemType::Module,
clean::ExternCrateItem(..) => ItemType::ExternCrate,
clean::ExternCrateItem { .. } => ItemType::ExternCrate,
clean::ImportItem(..) => ItemType::Import,
clean::StructItem(..) => ItemType::Struct,
clean::UnionItem(..) => ItemType::Union,
Expand Down
4 changes: 3 additions & 1 deletion src/librustdoc/formats/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
}

cx.mod_item_out(&name)?;
} else if item.name.is_some() {
// FIXME: checking `item.name.is_some()` is very implicit and leads to lots of special
// cases. Use an explicit match instead.
} else if item.name.is_some() && !item.is_extern_crate() {
prof.generic_activity_with_arg("render_item", &*item.name.unwrap_or(unknown).as_str())
.run(|| cx.item(item))?;
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2151,7 +2151,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
}

match *myitem.kind {
clean::ExternCrateItem(ref name, ref src) => {
clean::ExternCrateItem { ref src } => {
use crate::html::format::anchor;

match *src {
Expand All @@ -2160,13 +2160,13 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
"<tr><td><code>{}extern crate {} as {};",
myitem.visibility.print_with_space(cx.tcx(), myitem.def_id, cx.cache()),
anchor(myitem.def_id, &*src.as_str(), cx.cache()),
name
myitem.name.as_ref().unwrap(),
),
None => write!(
w,
"<tr><td><code>{}extern crate {};",
myitem.visibility.print_with_space(cx.tcx(), myitem.def_id, cx.cache()),
anchor(myitem.def_id, &*name.as_str(), cx.cache())
anchor(myitem.def_id, &*myitem.name.as_ref().unwrap().as_str(), cx.cache()),
),
}
w.write_str("</code></td></tr>");
Expand Down
61 changes: 32 additions & 29 deletions src/librustdoc/json/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,37 @@ impl JsonRenderer<'_> {
let item_type = ItemType::from(&item);
let deprecation = item.deprecation(self.tcx);
let clean::Item { source, name, attrs, kind, visibility, def_id } = item;
match *kind {
clean::StrippedItem(_) => None,
kind => Some(Item {
id: from_def_id(def_id),
crate_id: def_id.krate.as_u32(),
name: name.map(|sym| sym.to_string()),
source: self.convert_span(source),
visibility: self.convert_visibility(visibility),
docs: attrs.collapsed_doc_value(),
links: attrs
.links
.into_iter()
.filter_map(|clean::ItemLink { link, did, .. }| {
did.map(|did| (link, from_def_id(did)))
})
.collect(),
attrs: attrs
.other_attrs
.iter()
.map(rustc_ast_pretty::pprust::attribute_to_string)
.collect(),
deprecation: deprecation.map(from_deprecation),
kind: item_type.into(),
inner: from_clean_item_kind(kind, self.tcx),
}),
}
let inner = match *kind {
clean::ItemKind::ExternCrateItem { ref src } => ItemEnum::ExternCrateItem {
name: name.as_ref().unwrap().to_string(),
rename: src.map(|x| x.to_string()),
},
clean::StrippedItem(_) => return None,
x => from_clean_item_kind(x, self.tcx),
};
Some(Item {
id: from_def_id(def_id),
crate_id: def_id.krate.as_u32(),
name: name.map(|sym| sym.to_string()),
source: self.convert_span(source),
visibility: self.convert_visibility(visibility),
docs: attrs.collapsed_doc_value(),
links: attrs
.links
.into_iter()
.filter_map(|clean::ItemLink { link, did, .. }| {
did.map(|did| (link, from_def_id(did)))
})
.collect(),
attrs: attrs
.other_attrs
.iter()
.map(rustc_ast_pretty::pprust::attribute_to_string)
.collect(),
deprecation: deprecation.map(from_deprecation),
kind: item_type.into(),
inner,
})
}

fn convert_span(&self, span: clean::Span) -> Option<Span> {
Expand Down Expand Up @@ -153,9 +158,6 @@ fn from_clean_item_kind(item: clean::ItemKind, tcx: TyCtxt<'_>) -> ItemEnum {
use clean::ItemKind::*;
match item {
ModuleItem(m) => ItemEnum::ModuleItem(m.into()),
ExternCrateItem(c, a) => {
ItemEnum::ExternCrateItem { name: c.to_string(), rename: a.map(|x| x.to_string()) }
}
ImportItem(i) => ItemEnum::ImportItem(i.into()),
StructItem(s) => ItemEnum::StructItem(s.into()),
UnionItem(u) => ItemEnum::UnionItem(u.into()),
Expand Down Expand Up @@ -186,6 +188,7 @@ fn from_clean_item_kind(item: clean::ItemKind, tcx: TyCtxt<'_>) -> ItemEnum {
PrimitiveItem(_) | KeywordItem(_) => {
panic!("{:?} is not supported for JSON output", item)
}
ExternCrateItem { .. } => unreachable!(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
match &*item.kind {
// These don't have names so they don't get added to the output by default
ImportItem(_) => self.item(item.clone()).unwrap(),
ExternCrateItem(_, _) => self.item(item.clone()).unwrap(),
ExternCrateItem { .. } => self.item(item.clone()).unwrap(),
ImplItem(i) => i.items.iter().for_each(|i| self.item(i.clone()).unwrap()),
_ => {}
}
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 @@ -193,7 +193,7 @@ impl<'a, 'b> fold::DocFolder for CoverageCalculator<'a, 'b> {
// don't count items in stripped modules
return Some(i);
}
clean::ImportItem(..) | clean::ExternCrateItem(..) => {
clean::ImportItem(..) | clean::ExternCrateItem { .. } => {
// docs on `use` and `extern crate` statements are not displayed, so they're not
// worth counting
return Some(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 @@ -60,7 +60,7 @@ crate fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -> boo
| clean::TypedefItem(_, _)
| clean::StaticItem(_)
| clean::ConstantItem(_)
| clean::ExternCrateItem(_, _)
| clean::ExternCrateItem { .. }
| clean::ImportItem(_)
| clean::PrimitiveItem(_)
| clean::KeywordItem(_)
Expand Down
6 changes: 4 additions & 2 deletions src/librustdoc/passes/stripper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<'a> DocFolder for Stripper<'a> {
}

// handled in the `strip-priv-imports` pass
clean::ExternCrateItem(..) | clean::ImportItem(..) => {}
clean::ExternCrateItem { .. } | clean::ImportItem(..) => {}

clean::ImplItem(..) => {}

Expand Down Expand Up @@ -161,7 +161,9 @@ crate struct ImportStripper;
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,
clean::ExternCrateItem { .. } | clean::ImportItem(..) if !i.visibility.is_public() => {
None
}
_ => Some(self.fold_item_recur(i)),
}
}
Expand Down