Skip to content

Commit 5ea36cf

Browse files
authored
Rollup merge of rust-lang#104984 - GuillaumeGomez:remote-crate-primitives, r=notriddle
Remove Crate::primitives field It is a new approach to rust-lang#90447. Instead of removing primitives from everywhere (ie from `BadImplStripper`), I just removed them from the `Crate` type, allowing to reduce its size. cc `@camelid` r? `@notriddle`
2 parents 86304f5 + 23c3941 commit 5ea36cf

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

src/librustdoc/clean/types.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ impl From<DefId> for ItemId {
115115
#[derive(Clone, Debug)]
116116
pub(crate) struct Crate {
117117
pub(crate) module: Item,
118-
pub(crate) primitives: ThinVec<(DefId, PrimitiveType)>,
119118
/// Only here so that they can be filtered through the rustdoc passes.
120119
pub(crate) external_traits: Rc<RefCell<FxHashMap<DefId, Trait>>>,
121120
}
@@ -2572,7 +2571,7 @@ mod size_asserts {
25722571
use super::*;
25732572
use rustc_data_structures::static_assert_size;
25742573
// tidy-alphabetical-start
2575-
static_assert_size!(Crate, 72); // frequently moved by-value
2574+
static_assert_size!(Crate, 64); // frequently moved by-value
25762575
static_assert_size!(DocFragment, 32);
25772576
static_assert_size!(GenericArg, 32);
25782577
static_assert_size!(GenericArgs, 32);

src/librustdoc/clean/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub(crate) fn krate(cx: &mut DocContext<'_>) -> Crate {
7373
}));
7474
}
7575

76-
Crate { module, primitives, external_traits: cx.external_traits.clone() }
76+
Crate { module, external_traits: cx.external_traits.clone() }
7777
}
7878

7979
pub(crate) fn substs_to_args<'tcx>(

src/librustdoc/passes/collect_trait_impls.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::formats::cache::Cache;
88
use crate::visit::DocVisitor;
99

1010
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
11-
use rustc_hir::def_id::DefId;
11+
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
1212
use rustc_middle::ty::{self, DefIdTree};
1313
use rustc_span::symbol::sym;
1414

@@ -25,7 +25,9 @@ pub(crate) fn collect_trait_impls(mut krate: Crate, cx: &mut DocContext<'_>) ->
2525
synth.impls
2626
});
2727

28-
let prims: FxHashSet<PrimitiveType> = krate.primitives.iter().map(|p| p.1).collect();
28+
let local_crate = ExternalCrate { crate_num: LOCAL_CRATE };
29+
let prims: FxHashSet<PrimitiveType> =
30+
local_crate.primitives(cx.tcx).iter().map(|p| p.1).collect();
2931

3032
let crate_items = {
3133
let mut coll = ItemCollector::new();
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#![crate_name = "foo"]
2+
3+
// @has 'foo/struct.Foo.html'
4+
// @has - '//*[@id="deref-methods-i32"]' 'Methods from Deref<Target = i32>'
5+
// @has - '//*[@id="deref-methods-i32-1"]//*[@id="associatedconstant.BITS"]/h4' \
6+
// 'pub const BITS: u32 = 32u32'
7+
pub struct Foo(i32);
8+
9+
impl std::ops::Deref for Foo {
10+
type Target = i32;
11+
12+
fn deref(&self) -> &Self::Target {
13+
&self.0
14+
}
15+
}

0 commit comments

Comments
 (0)