Skip to content

Commit de007e0

Browse files
committed
Update inferred_outlives_of
1 parent 99da733 commit de007e0

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

src/librustc/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ rustc_queries! {
174174

175175
/// Returns the inferred outlives predicates (e.g., for `struct
176176
/// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`).
177-
query inferred_outlives_of(_: DefId) -> Lrc<Vec<ty::Predicate<'tcx>>> {}
177+
query inferred_outlives_of(_: DefId) -> &'tcx [ty::Predicate<'tcx>] {}
178178

179179
/// Maps from the `DefId` of a trait to the list of
180180
/// super-predicates. This is a subset of the full list of

src/librustc/ty/mod.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1110,11 +1110,7 @@ pub struct CratePredicatesMap<'tcx> {
11101110
/// For each struct with outlive bounds, maps to a vector of the
11111111
/// predicate of its outlive bounds. If an item has no outlives
11121112
/// bounds, it will have no entry.
1113-
pub predicates: FxHashMap<DefId, Lrc<Vec<ty::Predicate<'tcx>>>>,
1114-
1115-
/// An empty vector, useful for cloning.
1116-
#[stable_hasher(ignore)]
1117-
pub empty_predicate: Lrc<Vec<ty::Predicate<'tcx>>>,
1113+
pub predicates: FxHashMap<DefId, &'tcx [ty::Predicate<'tcx>]>,
11181114
}
11191115

11201116
impl<'tcx> AsRef<Predicate<'tcx>> for Predicate<'tcx> {

src/librustc_typeck/outlives/mod.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn provide(providers: &mut Providers<'_>) {
2323
fn inferred_outlives_of<'a, 'tcx>(
2424
tcx: TyCtxt<'a, 'tcx, 'tcx>,
2525
item_def_id: DefId,
26-
) -> Lrc<Vec<ty::Predicate<'tcx>>> {
26+
) -> &'tcx [ty::Predicate<'tcx>] {
2727
let id = tcx
2828
.hir()
2929
.as_local_hir_id(item_def_id)
@@ -37,8 +37,8 @@ fn inferred_outlives_of<'a, 'tcx>(
3737
let predicates = crate_map
3838
.predicates
3939
.get(&item_def_id)
40-
.unwrap_or(&crate_map.empty_predicate)
41-
.clone();
40+
.map(|p| *p)
41+
.unwrap_or(&[]);
4242

4343
if tcx.has_attr(item_def_id, "rustc_outlives") {
4444
let mut pred: Vec<String> = predicates
@@ -63,10 +63,10 @@ fn inferred_outlives_of<'a, 'tcx>(
6363
predicates
6464
}
6565

66-
_ => Lrc::new(Vec::new()),
66+
_ => &[],
6767
},
6868

69-
_ => Lrc::new(Vec::new()),
69+
_ => &[],
7070
}
7171
}
7272

@@ -96,7 +96,7 @@ fn inferred_outlives_crate<'tcx>(
9696
let predicates = global_inferred_outlives
9797
.iter()
9898
.map(|(&def_id, set)| {
99-
let vec: Vec<ty::Predicate<'tcx>> = set
99+
let predicates = tcx.arena.alloc_from_iter(set
100100
.iter()
101101
.filter_map(
102102
|ty::OutlivesPredicate(kind1, region2)| match kind1.unpack() {
@@ -115,14 +115,11 @@ fn inferred_outlives_crate<'tcx>(
115115
None
116116
}
117117
},
118-
).collect();
119-
(def_id, Lrc::new(vec))
118+
));
119+
(def_id, &*predicates)
120120
}).collect();
121121

122-
let empty_predicate = Lrc::new(Vec::new());
123-
124122
Lrc::new(ty::CratePredicatesMap {
125123
predicates,
126-
empty_predicate,
127124
})
128125
}

0 commit comments

Comments
 (0)