diff --git a/src/librustc/query/mod.rs b/src/librustc/query/mod.rs index 1861420b408b6..c22f11f662e02 100644 --- a/src/librustc/query/mod.rs +++ b/src/librustc/query/mod.rs @@ -174,7 +174,7 @@ rustc_queries! { /// Returns the inferred outlives predicates (e.g., for `struct /// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`). - query inferred_outlives_of(_: DefId) -> Lrc>> {} + query inferred_outlives_of(_: DefId) -> &'tcx [ty::Predicate<'tcx>] {} /// Maps from the `DefId` of a trait to the list of /// super-predicates. This is a subset of the full list of diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 67be228d232e1..198bd0b058439 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -1118,11 +1118,7 @@ pub struct CratePredicatesMap<'tcx> { /// For each struct with outlive bounds, maps to a vector of the /// predicate of its outlive bounds. If an item has no outlives /// bounds, it will have no entry. - pub predicates: FxHashMap>>>, - - /// An empty vector, useful for cloning. - #[stable_hasher(ignore)] - pub empty_predicate: Lrc>>, + pub predicates: FxHashMap]>, } impl<'tcx> AsRef> for Predicate<'tcx> { diff --git a/src/librustc_typeck/outlives/mod.rs b/src/librustc_typeck/outlives/mod.rs index 913990ee87897..e3e2fe7106a08 100644 --- a/src/librustc_typeck/outlives/mod.rs +++ b/src/librustc_typeck/outlives/mod.rs @@ -23,7 +23,7 @@ pub fn provide(providers: &mut Providers<'_>) { fn inferred_outlives_of<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, item_def_id: DefId, -) -> Lrc>> { +) -> &'tcx [ty::Predicate<'tcx>] { let id = tcx .hir() .as_local_hir_id(item_def_id) @@ -37,8 +37,8 @@ fn inferred_outlives_of<'a, 'tcx>( let predicates = crate_map .predicates .get(&item_def_id) - .unwrap_or(&crate_map.empty_predicate) - .clone(); + .map(|p| *p) + .unwrap_or(&[]); if tcx.has_attr(item_def_id, "rustc_outlives") { let mut pred: Vec = predicates @@ -63,10 +63,10 @@ fn inferred_outlives_of<'a, 'tcx>( predicates } - _ => Lrc::new(Vec::new()), + _ => &[], }, - _ => Lrc::new(Vec::new()), + _ => &[], } } @@ -96,7 +96,7 @@ fn inferred_outlives_crate<'tcx>( let predicates = global_inferred_outlives .iter() .map(|(&def_id, set)| { - let vec: Vec> = set + let predicates = tcx.arena.alloc_from_iter(set .iter() .filter_map( |ty::OutlivesPredicate(kind1, region2)| match kind1.unpack() { @@ -115,14 +115,11 @@ fn inferred_outlives_crate<'tcx>( None } }, - ).collect(); - (def_id, Lrc::new(vec)) + )); + (def_id, &*predicates) }).collect(); - let empty_predicate = Lrc::new(Vec::new()); - Lrc::new(ty::CratePredicatesMap { predicates, - empty_predicate, }) }