]> git.lizzy.rs Git - rust.git/commitdiff
Allocate query Vecs on the arena.
authorCamille GILLOT <gillot.camille@gmail.com>
Sat, 14 Mar 2020 11:06:06 +0000 (12:06 +0100)
committerCamille GILLOT <gillot.camille@gmail.com>
Sun, 5 Apr 2020 13:02:00 +0000 (15:02 +0200)
src/librustc_infer/traits/error_reporting/mod.rs
src/librustc_metadata/rmeta/decoder.rs
src/librustc_metadata/rmeta/decoder/cstore_impl.rs
src/librustc_middle/arena.rs
src/librustc_middle/query/mod.rs
src/librustc_trait_selection/traits/object_safety.rs
src/librustc_typeck/astconv.rs
src/librustdoc/clean/mod.rs

index 9206166d0bd67bd6e73434137a373ea3abff6ad9..2ae7b2ff92565e80585ddf138dbfb8072436034f 100644 (file)
@@ -39,7 +39,7 @@ pub fn report_object_safety_error(
     tcx: TyCtxt<'tcx>,
     span: Span,
     trait_def_id: DefId,
-    violations: Vec<ObjectSafetyViolation>,
+    violations: &[ObjectSafetyViolation],
 ) -> DiagnosticBuilder<'tcx> {
     let trait_str = tcx.def_path_str(trait_def_id);
     let trait_span = tcx.hir().get_if_local(trait_def_id).and_then(|node| match node {
index c59b155d5dbbce00aff24bc66f1a269f860aaf8e..0364493a48add05a76b93ca28b9fe9437d690918 100644 (file)
@@ -1331,13 +1331,13 @@ fn get_missing_lang_items(&self, tcx: TyCtxt<'tcx>) -> &'tcx [lang_items::LangIt
         }
     }
 
-    fn get_fn_param_names(&self, id: DefIndex) -> Vec<ast::Name> {
+    fn get_fn_param_names(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> &'tcx [ast::Name] {
         let param_names = match self.kind(id) {
             EntryKind::Fn(data) | EntryKind::ForeignFn(data) => data.decode(self).param_names,
             EntryKind::AssocFn(data) => data.decode(self).fn_data.param_names,
             _ => Lazy::empty(),
         };
-        param_names.decode(self).collect()
+        tcx.arena.alloc_from_iter(param_names.decode(self))
     }
 
     fn exported_symbols(
index c99b1dc360682955fb0b8772fe5d612f578342a5..5415c703039fd4794284a02b6b266ceb7daaed10 100644 (file)
@@ -144,7 +144,7 @@ fn into_args(self) -> (DefId, DefId) {
     // a `fn` when encoding, so the dep-tracking wouldn't work.
     // This is only used by rustdoc anyway, which shouldn't have
     // incremental recompilation ever enabled.
-    fn_arg_names => { cdata.get_fn_param_names(def_id.index) }
+    fn_arg_names => { cdata.get_fn_param_names(tcx, def_id.index) }
     rendered_const => { cdata.get_rendered_const(def_id.index) }
     impl_parent => { cdata.get_parent_impl(def_id.index) }
     trait_of_item => { cdata.get_trait_of_item(def_id.index) }
index e3dec59478c1f6095e44397f6fe0e4e4c60ac65c..2d3092305501b8dd701e189022e8a813ffd28fe7 100644 (file)
@@ -116,6 +116,7 @@ macro_rules! arena_types {
             [few] crate_variances: rustc_middle::ty::CrateVariancesMap<'tcx>,
             [few] inferred_outlives_crate: rustc_middle::ty::CratePredicatesMap<'tcx>,
             [] upvars: rustc_data_structures::fx::FxIndexMap<rustc_hir::HirId, rustc_hir::Upvar>,
+            [] object_safety_violations: rustc_middle::traits::ObjectSafetyViolation,
 
             // Interned types
             [] tys: rustc_middle::ty::TyS<$tcx>,
index 2ffbbfb1762d3a4d642b2b8d35764281cac43c86..dc3da9ec6ec5e55b3ee56c715cb7c3cda35a1175 100644 (file)
@@ -652,7 +652,7 @@ fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String {
     }
 
     Other {
-        query fn_arg_names(_: DefId) -> Vec<ast::Name> {}
+        query fn_arg_names(_: DefId) -> &'tcx [ast::Name] {}
         /// Gets the rendered value of the specified constant or associated constant.
         /// Used by rustdoc.
         query rendered_const(_: DefId) -> String {}
@@ -699,7 +699,7 @@ fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String {
             desc { |tcx| "building specialization graph of trait `{}`", tcx.def_path_str(key) }
             cache_on_disk_if { true }
         }
-        query object_safety_violations(key: DefId) -> Vec<traits::ObjectSafetyViolation> {
+        query object_safety_violations(key: DefId) -> &'tcx [traits::ObjectSafetyViolation] {
             desc { |tcx| "determine object safety of trait `{}`", tcx.def_path_str(key) }
         }
 
index 20b3fa908d2014e620b959de4bddefd17ead2833..715007c35c2dc1a4b47537b6594983cb8e7e6378 100644 (file)
@@ -47,13 +47,17 @@ pub fn astconv_object_safety_violations(
     violations
 }
 
-fn object_safety_violations(tcx: TyCtxt<'_>, trait_def_id: DefId) -> Vec<ObjectSafetyViolation> {
+fn object_safety_violations(
+    tcx: TyCtxt<'tcx>,
+    trait_def_id: DefId,
+) -> &'tcx [ObjectSafetyViolation] {
     debug_assert!(tcx.generics_of(trait_def_id).has_self);
     debug!("object_safety_violations: {:?}", trait_def_id);
 
-    traits::supertrait_def_ids(tcx, trait_def_id)
-        .flat_map(|def_id| object_safety_violations_for_trait(tcx, def_id))
-        .collect()
+    tcx.arena.alloc_from_iter(
+        traits::supertrait_def_ids(tcx, trait_def_id)
+            .flat_map(|def_id| object_safety_violations_for_trait(tcx, def_id)),
+    )
 }
 
 /// We say a method is *vtable safe* if it can be invoked on a trait
index c3ebcbfc832d13b263ee021dfe08fd228f2ef8fd..d3f1737b1e9b458b0f4327f7e79ffe40d3783542 100644 (file)
@@ -1582,7 +1582,7 @@ fn conv_object_ty_poly_trait_ref(
                     tcx,
                     span,
                     item.trait_ref().def_id(),
-                    object_safety_violations,
+                    &object_safety_violations[..],
                 )
                 .emit();
                 return tcx.types.err;
index e027db8b56c003f8b6302b195ace534670c94561..1c26d401d5612d8f9b9bcfb95bdea2ae16406a18 100644 (file)
@@ -973,10 +973,11 @@ impl<'tcx> Clean<FnDecl> for (DefId, ty::PolyFnSig<'tcx>) {
     fn clean(&self, cx: &DocContext<'_>) -> FnDecl {
         let (did, sig) = *self;
         let mut names = if cx.tcx.hir().as_local_hir_id(did).is_some() {
-            vec![].into_iter()
+            &[]
         } else {
-            cx.tcx.fn_arg_names(did).into_iter()
-        };
+            cx.tcx.fn_arg_names(did)
+        }
+        .iter();
 
         FnDecl {
             output: Return(sig.skip_binder().output().clean(cx)),