rust/tests/ui/codegen/overflow-during-mono.rs
David Wood 72d17bfebb
re-use sized fast path
There's an existing fast path for the `type_op_prove_predicate`
predicate, checking for trivially `Sized` types, which can be re-used
when evaluating obligations within queries. This should improve
performance, particularly in anticipation of new sizedness traits being
added which can take advantage of this.
2025-04-09 10:42:26 +00:00

28 lines
725 B
Rust

//~ ERROR overflow evaluating the requirement `for<'a> {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}: FnMut(&'a _)`
//@ build-fail
#![recursion_limit = "32"]
fn quicksort<It: Clone + Iterator<Item = T>, I: IntoIterator<IntoIter = It>, T: Ord>(
i: I,
) -> Vec<T> {
let mut i = i.into_iter();
match i.next() {
Some(x) => {
let less = i.clone().filter(|y| y < &x);
let greater = i.filter(|y| &x <= y);
let mut v = quicksort(less);
let u = quicksort(greater);
v.push(x);
v.extend(u);
v
}
None => vec![],
}
}
fn main() {
println!("{:?}", quicksort([5i32, 1, 6, 3, 6, 1, 9, 0, -1, 6, 8]));
}