Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

ices/83937.sh: fixed with no errors #846

Merged
merged 1 commit into from
Jun 22, 2021
Merged

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#83937

#!/bin/bash

cat > Cargo.toml <<'EOF'
[package]
name = "temp"
version = "0.1.0"
edition = "2018"

[[bench]]
name = "counting_sort"
EOF

mkdir -p benches src

cat > src/lib.rs <<'EOF'
#![feature(const_trait_impl)]
#![allow(incomplete_features)]

pub trait UsizeConversions {
    fn into_usize(self) -> usize;
}

impl const UsizeConversions for u8 {
    fn into_usize(self) -> usize {
        self as usize
    }
}

pub trait CountingSort {
    fn sort(&mut self);
}

impl CountingSort for [u8] {
    #[inline] // when this is removed, everything works well
    fn sort(&mut self) {
        let _counts = [0usize; u8::MAX.into_usize() + 1];
    }
}

#[test]
fn works_in_tests() {
    let mut data = vec![5, 2, 8, 10];
    CountingSort::sort(&mut *data);
}
EOF

cat > benches/counting_sort.rs <<'EOF'
#![feature(test)]

extern crate test;

use temp::CountingSort;
use test::Bencher;

#[bench]
fn counting_sort(b: &mut Bencher) {
    b.iter(|| {
        let mut data = vec![5, 2, 8, 10]; 
        CountingSort::sort(&mut *data);
    });
}
EOF

cargo bench
=== stdout ===

running 1 test
test works_in_tests ... ignored

test result: ok. 0 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.00s


running 1 test
test counting_sort ... bench:           0 ns/iter (+/- 0)

test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in 4.65s

=== stderr ===
   Compiling temp v0.1.0 (/tmp/.tmpiBUxib)
    Finished bench [optimized] target(s) in 1.31s
     Running unittests (target/release/deps/temp-a1b60024de1fffcb)
     Running unittests (target/release/deps/counting_sort-17e6cc0f26796e1f)
==============

=== stdout ===

running 1 test
test works_in_tests ... ignored

test result: ok. 0 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.00s


running 1 test
test counting_sort ... bench:           0 ns/iter (+/- 0)

test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in 4.65s

=== stderr ===
   Compiling temp v0.1.0 (/tmp/.tmpiBUxib)
    Finished bench [optimized] target(s) in 1.31s
     Running unittests (target/release/deps/temp-a1b60024de1fffcb)
     Running unittests (target/release/deps/counting_sort-17e6cc0f26796e1f)
==============
@JohnTitor JohnTitor merged commit 1fb5822 into master Jun 22, 2021
@JohnTitor JohnTitor deleted the autofix/ices/83937.sh branch June 22, 2021 21:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants