Skip to content

Commit 8f185a3

Browse files
committed
Make libcore compile again
1 parent 227af1e commit 8f185a3

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/preempt_count/annotation.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,33 @@ impl<'tcx> AnalysisCtxt<'tcx> {
136136
};
137137
}
138138

139+
if data.len() == 5
140+
&& let DefPathData::TypeNs(slice) = data[0].data
141+
&& slice == sym::slice
142+
&& let DefPathData::TypeNs(sort) = data[1].data
143+
&& sort == *crate::symbol::sort
144+
&& let DefPathData::TypeNs(unstable) = data[2].data
145+
&& unstable == sym::unstable
146+
&& let DefPathData::TypeNs(quicksort) = data[3].data
147+
&& quicksort == *crate::symbol::quicksort
148+
&& let DefPathData::ValueNs(partition) = data[4].data
149+
&& partition == *crate::symbol::partition
150+
{
151+
// HACK: `core::sort::unstable::quicksort::partition` uses a const fn to produce a
152+
// function pointer which is called at runtime. This means that it'll guarantee to be
153+
// the same function, so in theory we could see through and check, but this is
154+
// currently beyond klint's ability.
155+
//
156+
// Given this is an internal function and it's only called by `quicksort`, which
157+
// already calls into `is_less` in other means, we shouldn't need to depend on
158+
// `partition` to deduce correct property.
159+
return PreemptionCount {
160+
adjustment: Some(0),
161+
expectation: Some(super::ExpectationRange::top()),
162+
unchecked: true,
163+
};
164+
}
165+
139166
Default::default()
140167
}
141168
}

src/symbol.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,7 @@ def! {
2929
Waker,
3030
wake,
3131
wake_by_ref,
32+
sort,
33+
quicksort,
34+
partition,
3235
}

0 commit comments

Comments
 (0)