Skip to content

Commit 675c95c

Browse files
committed
Rollup merge of rust-lang#55882 - hugwijst:rc_return_crate_inherent_impls, r=Mark-Simulacrum
Reference count `crate_inherent_impls`s return value. The repeated cloning of the result in `inherent_impls` queries has quite an impact on crates with many inherent trait implementations. For instance on https://github.com/jmesmon/stm32f429, `cargo check` went from 75 seconds to 38 seconds on my machine.
2 parents a277435 + 4fdae85 commit 675c95c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/librustc/ty/query/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ define_queries! { <'tcx>
291291
/// Gets a complete map from all types to their inherent impls.
292292
/// Not meant to be used directly outside of coherence.
293293
/// (Defined only for LOCAL_CRATE)
294-
[] fn crate_inherent_impls: crate_inherent_impls_dep_node(CrateNum) -> CrateInherentImpls,
294+
[] fn crate_inherent_impls: crate_inherent_impls_dep_node(CrateNum)
295+
-> Lrc<CrateInherentImpls>,
295296

296297
/// Checks all types in the krate for overlap in their inherent impls. Reports errors.
297298
/// Not meant to be used directly outside of coherence.

src/librustc_typeck/coherence/inherent_impls.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use syntax_pos::Span;
3131
/// On-demand query: yields a map containing all types mapped to their inherent impls.
3232
pub fn crate_inherent_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
3333
crate_num: CrateNum)
34-
-> CrateInherentImpls {
34+
-> Lrc<CrateInherentImpls> {
3535
assert_eq!(crate_num, LOCAL_CRATE);
3636

3737
let krate = tcx.hir.krate();
@@ -42,7 +42,7 @@ pub fn crate_inherent_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
4242
}
4343
};
4444
krate.visit_all_item_likes(&mut collect);
45-
collect.impls_map
45+
Lrc::new(collect.impls_map)
4646
}
4747

4848
/// On-demand query: yields a vector of the inherent impls for a specific type.

0 commit comments

Comments
 (0)