Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e82734e

Browse files
committedApr 11, 2020
Auto merge of #70161 - cjgillot:query-arena, r=nikomatsakis
Allocate some query results on an arena This avoids a cloning few `Lrc` and `Vec`s in the queries.
2 parents 7688266 + 802c0be commit e82734e

File tree

17 files changed

+78
-98
lines changed

17 files changed

+78
-98
lines changed
 

‎src/librustc_codegen_llvm/context.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use rustc_target::spec::{HasTargetSpec, Target};
2626
use std::cell::{Cell, RefCell};
2727
use std::ffi::CStr;
2828
use std::str;
29-
use std::sync::Arc;
3029

3130
/// There is one `CodegenCx` per compilation unit. Each one has its own LLVM
3231
/// `llvm::Context` so that several compilation units may be optimized in parallel.
@@ -39,7 +38,7 @@ pub struct CodegenCx<'ll, 'tcx> {
3938

4039
pub llmod: &'ll llvm::Module,
4140
pub llcx: &'ll llvm::Context,
42-
pub codegen_unit: Arc<CodegenUnit<'tcx>>,
41+
pub codegen_unit: &'tcx CodegenUnit<'tcx>,
4342

4443
/// Cache instances of monomorphic and polymorphic items
4544
pub instances: RefCell<FxHashMap<Instance<'tcx>, &'ll Value>>,
@@ -232,7 +231,7 @@ pub unsafe fn create_module(
232231
impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
233232
crate fn new(
234233
tcx: TyCtxt<'tcx>,
235-
codegen_unit: Arc<CodegenUnit<'tcx>>,
234+
codegen_unit: &'tcx CodegenUnit<'tcx>,
236235
llvm_module: &'ll crate::ModuleLlvm,
237236
) -> Self {
238237
// An interesting part of Windows which MSVC forces our hand on (and
@@ -402,8 +401,8 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
402401
self.check_overflow
403402
}
404403

405-
fn codegen_unit(&self) -> &Arc<CodegenUnit<'tcx>> {
406-
&self.codegen_unit
404+
fn codegen_unit(&self) -> &'tcx CodegenUnit<'tcx> {
405+
self.codegen_unit
407406
}
408407

409408
fn used_statics(&self) -> &RefCell<Vec<&'ll Value>> {

‎src/librustc_codegen_ssa/back/symbol_export.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::collections::hash_map::Entry::*;
2-
use std::sync::Arc;
32

43
use rustc_ast::expand::allocator::ALLOCATOR_METHODS;
54
use rustc_data_structures::fingerprint::Fingerprint;
@@ -164,11 +163,11 @@ fn is_reachable_non_generic_provider_extern(tcx: TyCtxt<'_>, def_id: DefId) -> b
164163
fn exported_symbols_provider_local(
165164
tcx: TyCtxt<'_>,
166165
cnum: CrateNum,
167-
) -> Arc<Vec<(ExportedSymbol<'_>, SymbolExportLevel)>> {
166+
) -> &'tcx [(ExportedSymbol<'_>, SymbolExportLevel)] {
168167
assert_eq!(cnum, LOCAL_CRATE);
169168

170169
if !tcx.sess.opts.output_types.should_codegen() {
171-
return Arc::new(vec![]);
170+
return &[];
172171
}
173172

174173
let mut symbols: Vec<_> = tcx
@@ -274,7 +273,7 @@ fn exported_symbols_provider_local(
274273
// Sort so we get a stable incr. comp. hash.
275274
symbols.sort_by_cached_key(|s| s.0.symbol_name_for_local_instance(tcx));
276275

277-
Arc::new(symbols)
276+
tcx.arena.alloc_from_iter(symbols)
278277
}
279278

280279
fn upstream_monomorphizations_provider(

‎src/librustc_codegen_ssa/base.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,15 +533,14 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
533533
// Run the monomorphization collector and partition the collected items into
534534
// codegen units.
535535
let codegen_units = tcx.collect_and_partition_mono_items(LOCAL_CRATE).1;
536-
let codegen_units = (*codegen_units).clone();
537536

538537
// Force all codegen_unit queries so they are already either red or green
539538
// when compile_codegen_unit accesses them. We are not able to re-execute
540539
// the codegen_unit query from just the DepNode, so an unknown color would
541540
// lead to having to re-execute compile_codegen_unit, possibly
542541
// unnecessarily.
543542
if tcx.dep_graph.is_fully_enabled() {
544-
for cgu in &codegen_units {
543+
for cgu in codegen_units {
545544
tcx.codegen_unit(cgu.name());
546545
}
547546
}
@@ -603,7 +602,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
603602
// We sort the codegen units by size. This way we can schedule work for LLVM
604603
// a bit more efficiently.
605604
let codegen_units = {
606-
let mut codegen_units = codegen_units;
605+
let mut codegen_units = codegen_units.iter().collect::<Vec<_>>();
607606
codegen_units.sort_by_cached_key(|cgu| cmp::Reverse(cgu.size_estimate()));
608607
codegen_units
609608
};

‎src/librustc_codegen_ssa/traits/misc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use rustc_middle::mir::mono::CodegenUnit;
44
use rustc_middle::ty::{self, Instance, Ty};
55
use rustc_session::Session;
66
use std::cell::RefCell;
7-
use std::sync::Arc;
87

98
pub trait MiscMethods<'tcx>: BackendTypes {
109
fn vtables(
@@ -15,7 +14,7 @@ pub trait MiscMethods<'tcx>: BackendTypes {
1514
fn get_fn_addr(&self, instance: Instance<'tcx>) -> Self::Value;
1615
fn eh_personality(&self) -> Self::Value;
1716
fn sess(&self) -> &Session;
18-
fn codegen_unit(&self) -> &Arc<CodegenUnit<'tcx>>;
17+
fn codegen_unit(&self) -> &'tcx CodegenUnit<'tcx>;
1918
fn used_statics(&self) -> &RefCell<Vec<Self::Value>>;
2019
fn set_frame_pointer_elimination(&self, llfn: Self::Function);
2120
fn apply_target_cpu_attr(&self, llfn: Self::Function);

‎src/librustc_infer/traits/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn report_object_safety_error(
3939
tcx: TyCtxt<'tcx>,
4040
span: Span,
4141
trait_def_id: DefId,
42-
violations: Vec<ObjectSafetyViolation>,
42+
violations: &[ObjectSafetyViolation],
4343
) -> DiagnosticBuilder<'tcx> {
4444
let trait_str = tcx.def_path_str(trait_def_id);
4545
let trait_span = tcx.hir().get_if_local(trait_def_id).and_then(|node| match node {

‎src/librustc_metadata/rmeta/decoder.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
11961196
}
11971197
}
11981198

1199-
fn get_item_attrs(&self, node_id: DefIndex, sess: &Session) -> Lrc<[ast::Attribute]> {
1199+
fn get_item_attrs(&self, node_id: DefIndex, sess: &Session) -> Vec<ast::Attribute> {
12001200
// The attributes for a tuple struct/variant are attached to the definition, not the ctor;
12011201
// we assume that someone passing in a tuple struct ctor is actually wanting to
12021202
// look at the definition
@@ -1207,15 +1207,13 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
12071207
node_id
12081208
};
12091209

1210-
Lrc::from(
1211-
self.root
1212-
.tables
1213-
.attributes
1214-
.get(self, item_id)
1215-
.unwrap_or(Lazy::empty())
1216-
.decode((self, sess))
1217-
.collect::<Vec<_>>(),
1218-
)
1210+
self.root
1211+
.tables
1212+
.attributes
1213+
.get(self, item_id)
1214+
.unwrap_or(Lazy::empty())
1215+
.decode((self, sess))
1216+
.collect::<Vec<_>>()
12191217
}
12201218

12211219
fn get_struct_field_names(&self, id: DefIndex, sess: &Session) -> Vec<Spanned<ast::Name>> {
@@ -1330,25 +1328,25 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
13301328
}
13311329
}
13321330

1333-
fn get_fn_param_names(&self, id: DefIndex) -> Vec<ast::Name> {
1331+
fn get_fn_param_names(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> &'tcx [ast::Name] {
13341332
let param_names = match self.kind(id) {
13351333
EntryKind::Fn(data) | EntryKind::ForeignFn(data) => data.decode(self).param_names,
13361334
EntryKind::AssocFn(data) => data.decode(self).fn_data.param_names,
13371335
_ => Lazy::empty(),
13381336
};
1339-
param_names.decode(self).collect()
1337+
tcx.arena.alloc_from_iter(param_names.decode(self))
13401338
}
13411339

13421340
fn exported_symbols(
13431341
&self,
13441342
tcx: TyCtxt<'tcx>,
1345-
) -> Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)> {
1343+
) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportLevel)] {
13461344
if self.root.is_proc_macro_crate() {
13471345
// If this crate is a custom derive crate, then we're not even going to
13481346
// link those in so we skip those crates.
1349-
vec![]
1347+
&[]
13501348
} else {
1351-
self.root.exported_symbols.decode((self, tcx)).collect()
1349+
tcx.arena.alloc_from_iter(self.root.exported_symbols.decode((self, tcx)))
13521350
}
13531351
}
13541352

‎src/librustc_metadata/rmeta/decoder/cstore_impl.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use rustc_span::symbol::Symbol;
2626
use rustc_data_structures::sync::Lrc;
2727
use smallvec::SmallVec;
2828
use std::any::Any;
29-
use std::sync::Arc;
3029

3130
macro_rules! provide {
3231
(<$lt:tt> $tcx:ident, $def_id:ident, $other:ident, $cdata:ident,
@@ -139,12 +138,14 @@ provide! { <'tcx> tcx, def_id, other, cdata,
139138
lookup_deprecation_entry => {
140139
cdata.get_deprecation(def_id.index).map(DeprecationEntry::external)
141140
}
142-
item_attrs => { cdata.get_item_attrs(def_id.index, tcx.sess) }
141+
item_attrs => { tcx.arena.alloc_from_iter(
142+
cdata.get_item_attrs(def_id.index, tcx.sess).into_iter()
143+
) }
143144
// FIXME(#38501) We've skipped a `read` on the `hir_owner_nodes` of
144145
// a `fn` when encoding, so the dep-tracking wouldn't work.
145146
// This is only used by rustdoc anyway, which shouldn't have
146147
// incremental recompilation ever enabled.
147-
fn_arg_names => { cdata.get_fn_param_names(def_id.index) }
148+
fn_arg_names => { cdata.get_fn_param_names(tcx, def_id.index) }
148149
rendered_const => { cdata.get_rendered_const(def_id.index) }
149150
impl_parent => { cdata.get_parent_impl(def_id.index) }
150151
trait_of_item => { cdata.get_trait_of_item(def_id.index) }
@@ -239,7 +240,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
239240
// to block export of generics from dylibs, but we must fix
240241
// rust-lang/rust#65890 before we can do that robustly.
241242

242-
Arc::new(syms)
243+
syms
243244
}
244245
}
245246

‎src/librustc_middle/arena.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ macro_rules! arena_types {
116116
[few] crate_variances: rustc_middle::ty::CrateVariancesMap<'tcx>,
117117
[few] inferred_outlives_crate: rustc_middle::ty::CratePredicatesMap<'tcx>,
118118
[] upvars: rustc_data_structures::fx::FxIndexMap<rustc_hir::HirId, rustc_hir::Upvar>,
119+
[] object_safety_violations: rustc_middle::traits::ObjectSafetyViolation,
120+
[] codegen_unit: rustc_middle::mir::mono::CodegenUnit<$tcx>,
121+
[] attribute: rustc_ast::ast::Attribute,
122+
[] name_set: rustc_data_structures::fx::FxHashSet<rustc_ast::ast::Name>,
123+
[] hir_id_set: rustc_hir::HirIdSet,
119124

120125
// Interned types
121126
[] tys: rustc_middle::ty::TyS<$tcx>,

‎src/librustc_middle/query/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ rustc_queries! {
610610
}
611611

612612
Other {
613-
query reachable_set(_: CrateNum) -> Lrc<HirIdSet> {
613+
query reachable_set(_: CrateNum) -> &'tcx HirIdSet {
614614
desc { "reachability" }
615615
}
616616

@@ -642,7 +642,7 @@ rustc_queries! {
642642
query lookup_stability(_: DefId) -> Option<&'tcx attr::Stability> {}
643643
query lookup_const_stability(_: DefId) -> Option<&'tcx attr::ConstStability> {}
644644
query lookup_deprecation_entry(_: DefId) -> Option<DeprecationEntry> {}
645-
query item_attrs(_: DefId) -> Lrc<[ast::Attribute]> {}
645+
query item_attrs(_: DefId) -> &'tcx [ast::Attribute] {}
646646
}
647647

648648
Codegen {
@@ -652,7 +652,7 @@ rustc_queries! {
652652
}
653653

654654
Other {
655-
query fn_arg_names(_: DefId) -> Vec<ast::Name> {}
655+
query fn_arg_names(_: DefId) -> &'tcx [ast::Name] {}
656656
/// Gets the rendered value of the specified constant or associated constant.
657657
/// Used by rustdoc.
658658
query rendered_const(_: DefId) -> String {}
@@ -699,7 +699,7 @@ rustc_queries! {
699699
desc { |tcx| "building specialization graph of trait `{}`", tcx.def_path_str(key) }
700700
cache_on_disk_if { true }
701701
}
702-
query object_safety_violations(key: DefId) -> Vec<traits::ObjectSafetyViolation> {
702+
query object_safety_violations(key: DefId) -> &'tcx [traits::ObjectSafetyViolation] {
703703
desc { |tcx| "determine object safety of trait `{}`", tcx.def_path_str(key) }
704704
}
705705

@@ -1047,7 +1047,7 @@ rustc_queries! {
10471047
desc { "looking up all possibly unused extern crates" }
10481048
}
10491049
query names_imported_by_glob_use(_: DefId)
1050-
-> Lrc<FxHashSet<ast::Name>> {
1050+
-> &'tcx FxHashSet<ast::Name> {
10511051
eval_always
10521052
}
10531053

@@ -1075,19 +1075,19 @@ rustc_queries! {
10751075
/// correspond to a publicly visible symbol in `cnum` machine code.
10761076
/// - The `exported_symbols` sets of different crates do not intersect.
10771077
query exported_symbols(_: CrateNum)
1078-
-> Arc<Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)>> {
1078+
-> &'tcx [(ExportedSymbol<'tcx>, SymbolExportLevel)] {
10791079
desc { "exported_symbols" }
10801080
}
10811081
}
10821082

10831083
Codegen {
10841084
query collect_and_partition_mono_items(_: CrateNum)
1085-
-> (Arc<DefIdSet>, Arc<Vec<Arc<CodegenUnit<'tcx>>>>) {
1085+
-> (&'tcx DefIdSet, &'tcx [CodegenUnit<'tcx>]) {
10861086
eval_always
10871087
desc { "collect_and_partition_mono_items" }
10881088
}
10891089
query is_codegened_item(_: DefId) -> bool {}
1090-
query codegen_unit(_: Symbol) -> Arc<CodegenUnit<'tcx>> {
1090+
query codegen_unit(_: Symbol) -> &'tcx CodegenUnit<'tcx> {
10911091
desc { "codegen_unit" }
10921092
}
10931093
query backend_optimization_level(_: CrateNum) -> OptLevel {

‎src/librustc_middle/ty/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2723,7 +2723,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
27232723
};
27242724
providers.names_imported_by_glob_use = |tcx, id| {
27252725
assert_eq!(id.krate, LOCAL_CRATE);
2726-
Lrc::new(tcx.glob_map.get(&id).cloned().unwrap_or_default())
2726+
tcx.arena.alloc(tcx.glob_map.get(&id).cloned().unwrap_or_default())
27272727
};
27282728

27292729
providers.lookup_stability = |tcx, id| {

‎src/librustc_middle/ty/mod.rs

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use rustc_data_structures::fx::FxHashMap;
2828
use rustc_data_structures::fx::FxIndexMap;
2929
use rustc_data_structures::sorted_map::SortedIndexMultiMap;
3030
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
31-
use rustc_data_structures::sync::{self, par_iter, Lrc, ParallelIterator};
31+
use rustc_data_structures::sync::{self, par_iter, ParallelIterator};
3232
use rustc_hir as hir;
3333
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Namespace, Res};
3434
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, CRATE_DEF_INDEX};
@@ -2596,22 +2596,7 @@ impl BorrowKind {
25962596
}
25972597
}
25982598

2599-
#[derive(Debug, Clone)]
2600-
pub enum Attributes<'tcx> {
2601-
Owned(Lrc<[ast::Attribute]>),
2602-
Borrowed(&'tcx [ast::Attribute]),
2603-
}
2604-
2605-
impl<'tcx> ::std::ops::Deref for Attributes<'tcx> {
2606-
type Target = [ast::Attribute];
2607-
2608-
fn deref(&self) -> &[ast::Attribute] {
2609-
match self {
2610-
&Attributes::Owned(ref data) => &data,
2611-
&Attributes::Borrowed(data) => data,
2612-
}
2613-
}
2614-
}
2599+
pub type Attributes<'tcx> = &'tcx [ast::Attribute];
26152600

26162601
#[derive(Debug, PartialEq, Eq)]
26172602
pub enum ImplOverlapKind {
@@ -2847,9 +2832,9 @@ impl<'tcx> TyCtxt<'tcx> {
28472832
/// Gets the attributes of a definition.
28482833
pub fn get_attrs(self, did: DefId) -> Attributes<'tcx> {
28492834
if let Some(id) = self.hir().as_local_hir_id(did) {
2850-
Attributes::Borrowed(self.hir().attrs(id))
2835+
self.hir().attrs(id)
28512836
} else {
2852-
Attributes::Owned(self.item_attrs(did))
2837+
self.item_attrs(did)
28532838
}
28542839
}
28552840

‎src/librustc_mir/monomorphize/partitioning.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@
9494
9595
use std::cmp;
9696
use std::collections::hash_map::Entry;
97-
use std::sync::Arc;
9897

9998
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
10099
use rustc_data_structures::sync;
@@ -890,7 +889,7 @@ where
890889
fn collect_and_partition_mono_items(
891890
tcx: TyCtxt<'_>,
892891
cnum: CrateNum,
893-
) -> (Arc<DefIdSet>, Arc<Vec<Arc<CodegenUnit<'_>>>>) {
892+
) -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'_>]) {
894893
assert_eq!(cnum, LOCAL_CRATE);
895894

896895
let collection_mode = match tcx.sess.opts.debugging_opts.print_mono_items {
@@ -928,10 +927,12 @@ fn collect_and_partition_mono_items(
928927
let (codegen_units, _) = tcx.sess.time("partition_and_assert_distinct_symbols", || {
929928
sync::join(
930929
|| {
931-
partition(tcx, items.iter().cloned(), tcx.sess.codegen_units(), &inlining_map)
932-
.into_iter()
933-
.map(Arc::new)
934-
.collect::<Vec<_>>()
930+
&*tcx.arena.alloc_from_iter(partition(
931+
tcx,
932+
items.iter().cloned(),
933+
tcx.sess.codegen_units(),
934+
&inlining_map,
935+
))
935936
},
936937
|| assert_symbols_are_distinct(tcx, items.iter()),
937938
)
@@ -949,7 +950,7 @@ fn collect_and_partition_mono_items(
949950
if tcx.sess.opts.debugging_opts.print_mono_items.is_some() {
950951
let mut item_to_cgus: FxHashMap<_, Vec<_>> = Default::default();
951952

952-
for cgu in &codegen_units {
953+
for cgu in codegen_units {
953954
for (&mono_item, &linkage) in cgu.items() {
954955
item_to_cgus.entry(mono_item).or_default().push((cgu.name(), linkage));
955956
}
@@ -997,7 +998,7 @@ fn collect_and_partition_mono_items(
997998
}
998999
}
9991000

1000-
(Arc::new(mono_items), Arc::new(codegen_units))
1001+
(tcx.arena.alloc(mono_items), codegen_units)
10011002
}
10021003

10031004
pub fn provide(providers: &mut Providers<'_>) {
@@ -1012,7 +1013,6 @@ pub fn provide(providers: &mut Providers<'_>) {
10121013
let (_, all) = tcx.collect_and_partition_mono_items(LOCAL_CRATE);
10131014
all.iter()
10141015
.find(|cgu| cgu.name() == name)
1015-
.cloned()
10161016
.unwrap_or_else(|| panic!("failed to find cgu with name {:?}", name))
10171017
};
10181018
}

‎src/librustc_passes/reachable.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// reachable as well.
77

88
use rustc_data_structures::fx::FxHashSet;
9-
use rustc_data_structures::sync::Lrc;
109
use rustc_hir as hir;
1110
use rustc_hir::def::{DefKind, Res};
1211
use rustc_hir::def_id::LOCAL_CRATE;
@@ -375,7 +374,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, 'tcx
375374
}
376375
}
377376

378-
fn reachable_set(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Lrc<HirIdSet> {
377+
fn reachable_set<'tcx>(tcx: TyCtxt<'tcx>, crate_num: CrateNum) -> &'tcx HirIdSet {
379378
debug_assert!(crate_num == LOCAL_CRATE);
380379

381380
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
@@ -421,7 +420,7 @@ fn reachable_set(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Lrc<HirIdSet> {
421420
debug!("Inline reachability shows: {:?}", reachable_context.reachable_symbols);
422421

423422
// Return the set of reachable symbols.
424-
Lrc::new(reachable_context.reachable_symbols)
423+
tcx.arena.alloc(reachable_context.reachable_symbols)
425424
}
426425

427426
pub fn provide(providers: &mut Providers<'_>) {

‎src/librustc_trait_selection/traits/object_safety.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,17 @@ pub fn astconv_object_safety_violations(
4747
violations
4848
}
4949

50-
fn object_safety_violations(tcx: TyCtxt<'_>, trait_def_id: DefId) -> Vec<ObjectSafetyViolation> {
50+
fn object_safety_violations(
51+
tcx: TyCtxt<'tcx>,
52+
trait_def_id: DefId,
53+
) -> &'tcx [ObjectSafetyViolation] {
5154
debug_assert!(tcx.generics_of(trait_def_id).has_self);
5255
debug!("object_safety_violations: {:?}", trait_def_id);
5356

54-
traits::supertrait_def_ids(tcx, trait_def_id)
55-
.flat_map(|def_id| object_safety_violations_for_trait(tcx, def_id))
56-
.collect()
57+
tcx.arena.alloc_from_iter(
58+
traits::supertrait_def_ids(tcx, trait_def_id)
59+
.flat_map(|def_id| object_safety_violations_for_trait(tcx, def_id)),
60+
)
5761
}
5862

5963
/// We say a method is *vtable safe* if it can be invoked on a trait

‎src/librustc_typeck/astconv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
15831583
tcx,
15841584
span,
15851585
item.trait_ref().def_id(),
1586-
object_safety_violations,
1586+
&object_safety_violations[..],
15871587
)
15881588
.emit();
15891589
return tcx.types.err;

‎src/librustdoc/clean/mod.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -975,10 +975,11 @@ impl<'tcx> Clean<FnDecl> for (DefId, ty::PolyFnSig<'tcx>) {
975975
fn clean(&self, cx: &DocContext<'_>) -> FnDecl {
976976
let (did, sig) = *self;
977977
let mut names = if cx.tcx.hir().as_local_hir_id(did).is_some() {
978-
vec![].into_iter()
978+
&[]
979979
} else {
980-
cx.tcx.fn_arg_names(did).into_iter()
981-
};
980+
cx.tcx.fn_arg_names(did)
981+
}
982+
.iter();
982983

983984
FnDecl {
984985
output: Return(sig.skip_binder().output().clean(cx)),
@@ -2180,13 +2181,9 @@ impl Clean<Vec<Item>> for doctree::ExternCrate<'_> {
21802181

21812182
let res = Res::Def(DefKind::Mod, DefId { krate: self.cnum, index: CRATE_DEF_INDEX });
21822183

2183-
if let Some(items) = inline::try_inline(
2184-
cx,
2185-
res,
2186-
self.name,
2187-
Some(rustc_middle::ty::Attributes::Borrowed(self.attrs)),
2188-
&mut visited,
2189-
) {
2184+
if let Some(items) =
2185+
inline::try_inline(cx, res, self.name, Some(self.attrs), &mut visited)
2186+
{
21902187
return items;
21912188
}
21922189
}
@@ -2247,13 +2244,9 @@ impl Clean<Vec<Item>> for doctree::Import<'_> {
22472244
}
22482245
if !denied {
22492246
let mut visited = FxHashSet::default();
2250-
if let Some(items) = inline::try_inline(
2251-
cx,
2252-
path.res,
2253-
name,
2254-
Some(rustc_middle::ty::Attributes::Borrowed(self.attrs)),
2255-
&mut visited,
2256-
) {
2247+
if let Some(items) =
2248+
inline::try_inline(cx, path.res, name, Some(self.attrs), &mut visited)
2249+
{
22572250
return items;
22582251
}
22592252
}

‎src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use rustc_span::symbol::Symbol;
2626
use rustc_target::spec::Target;
2727
use std::any::Any;
2828
use std::path::Path;
29-
use std::sync::Arc;
3029

3130
pub struct NoLlvmMetadataLoader;
3231

@@ -57,7 +56,7 @@ impl CodegenBackend for TheBackend {
5756
tcx.arena.alloc(Default::default()) // Just a dummy
5857
};
5958
providers.is_reachable_non_generic = |_tcx, _defid| true;
60-
providers.exported_symbols = |_tcx, _crate| Arc::new(Vec::new());
59+
providers.exported_symbols = |_tcx, _crate| &[];
6160
}
6261

6362
fn provide_extern(&self, providers: &mut Providers) {

0 commit comments

Comments
 (0)
Please sign in to comment.