Rollup merge of #104984 - GuillaumeGomez:remote-crate-primitives, r=notriddle
Remove Crate::primitives field It is a new approach to #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`
This commit is contained in:
commit
5ea36cfc1c
@ -115,7 +115,6 @@ impl From<DefId> for ItemId {
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct Crate {
|
||||
pub(crate) module: Item,
|
||||
pub(crate) primitives: ThinVec<(DefId, PrimitiveType)>,
|
||||
/// Only here so that they can be filtered through the rustdoc passes.
|
||||
pub(crate) external_traits: Rc<RefCell<FxHashMap<DefId, Trait>>>,
|
||||
}
|
||||
@ -2572,7 +2571,7 @@ mod size_asserts {
|
||||
use super::*;
|
||||
use rustc_data_structures::static_assert_size;
|
||||
// tidy-alphabetical-start
|
||||
static_assert_size!(Crate, 72); // frequently moved by-value
|
||||
static_assert_size!(Crate, 64); // frequently moved by-value
|
||||
static_assert_size!(DocFragment, 32);
|
||||
static_assert_size!(GenericArg, 32);
|
||||
static_assert_size!(GenericArgs, 32);
|
||||
|
@ -73,7 +73,7 @@ pub(crate) fn krate(cx: &mut DocContext<'_>) -> Crate {
|
||||
}));
|
||||
}
|
||||
|
||||
Crate { module, primitives, external_traits: cx.external_traits.clone() }
|
||||
Crate { module, external_traits: cx.external_traits.clone() }
|
||||
}
|
||||
|
||||
pub(crate) fn substs_to_args<'tcx>(
|
||||
|
@ -8,7 +8,7 @@ use crate::formats::cache::Cache;
|
||||
use crate::visit::DocVisitor;
|
||||
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_middle::ty::{self, DefIdTree};
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
@ -25,7 +25,9 @@ pub(crate) fn collect_trait_impls(mut krate: Crate, cx: &mut DocContext<'_>) ->
|
||||
synth.impls
|
||||
});
|
||||
|
||||
let prims: FxHashSet<PrimitiveType> = krate.primitives.iter().map(|p| p.1).collect();
|
||||
let local_crate = ExternalCrate { crate_num: LOCAL_CRATE };
|
||||
let prims: FxHashSet<PrimitiveType> =
|
||||
local_crate.primitives(cx.tcx).iter().map(|p| p.1).collect();
|
||||
|
||||
let crate_items = {
|
||||
let mut coll = ItemCollector::new();
|
||||
|
15
src/test/rustdoc/deref-to-primitive.rs
Normal file
15
src/test/rustdoc/deref-to-primitive.rs
Normal file
@ -0,0 +1,15 @@
|
||||
#![crate_name = "foo"]
|
||||
|
||||
// @has 'foo/struct.Foo.html'
|
||||
// @has - '//*[@id="deref-methods-i32"]' 'Methods from Deref<Target = i32>'
|
||||
// @has - '//*[@id="deref-methods-i32-1"]//*[@id="associatedconstant.BITS"]/h4' \
|
||||
// 'pub const BITS: u32 = 32u32'
|
||||
pub struct Foo(i32);
|
||||
|
||||
impl std::ops::Deref for Foo {
|
||||
type Target = i32;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user