Browse Source

Drstd with dlibc (#6)

* 完成drstd

* 1

* 1

* ft

* 1

* 1
GnoCiYeH 1 year ago
parent
commit
86982c5e9b

+ 2 - 0
.cargo/config.toml

@@ -0,0 +1,2 @@
+[alias]
+check = "check -Z build-std=core,alloc,compiler_builtins --target x86_64-unknown-dragonos"

+ 1 - 1
.vscode/settings.json

@@ -1,5 +1,5 @@
 {
     "rust-analyzer.linkedProjects": [
         "./Cargo.toml",
-    ]
+    ],
 }

+ 0 - 14
dlibc/core_io/src/b9adc3327ec7d2820ab2db8bb3cc2a0196a8375d/buffered.rs

@@ -1247,20 +1247,6 @@ mod tests {
         assert_eq!(WRITES.load(Ordering::SeqCst), 1);
     }
 
-    #[bench]
-    fn bench_buffered_reader(b: &mut test::Bencher) {
-        b.iter(|| {
-            BufReader::new(io::empty())
-        });
-    }
-
-    #[bench]
-    fn bench_buffered_writer(b: &mut test::Bencher) {
-        b.iter(|| {
-            BufWriter::new(io::sink())
-        });
-    }
-
     struct AcceptOneThenFail {
         written: bool,
         flushed: bool,

+ 0 - 62
dlibc/core_io/src/b9adc3327ec7d2820ab2db8bb3cc2a0196a8375d/impls.rs

@@ -277,65 +277,3 @@ impl Write for Vec<u8> {
     #[inline]
     fn flush(&mut self) -> io::Result<()> { Ok(()) }
 }
-
-#[cfg(test)]
-mod tests {
-    use io::prelude::*;
-    use test;
-
-    #[bench]
-    fn bench_read_slice(b: &mut test::Bencher) {
-        let buf = [5; 1024];
-        let mut dst = [0; 128];
-
-        b.iter(|| {
-            let mut rd = &buf[..];
-            for _ in 0..8 {
-                let _ = rd.read(&mut dst);
-                test::black_box(&dst);
-            }
-        })
-    }
-
-    #[bench]
-    fn bench_write_slice(b: &mut test::Bencher) {
-        let mut buf = [0; 1024];
-        let src = [5; 128];
-
-        b.iter(|| {
-            let mut wr = &mut buf[..];
-            for _ in 0..8 {
-                let _ = wr.write_all(&src);
-                test::black_box(&wr);
-            }
-        })
-    }
-
-    #[bench]
-    fn bench_read_vec(b: &mut test::Bencher) {
-        let buf = vec![5; 1024];
-        let mut dst = [0; 128];
-
-        b.iter(|| {
-            let mut rd = &buf[..];
-            for _ in 0..8 {
-                let _ = rd.read(&mut dst);
-                test::black_box(&dst);
-            }
-        })
-    }
-
-    #[bench]
-    fn bench_write_vec(b: &mut test::Bencher) {
-        let mut buf = Vec::with_capacity(1024);
-        let src = [5; 128];
-
-        b.iter(|| {
-            let mut wr = &mut buf[..];
-            for _ in 0..8 {
-                let _ = wr.write_all(&src);
-                test::black_box(&wr);
-            }
-        })
-    }
-}

+ 0 - 230
dlibc/core_io/src/b9adc3327ec7d2820ab2db8bb3cc2a0196a8375d/mod.rs

@@ -1986,233 +1986,3 @@ impl<B: BufRead> Iterator for Lines<B> {
         }
     }
 }
-
-#[cfg(test)]
-mod tests {
-    use io::prelude::*;
-    use io;
-    use super::Cursor;
-    use test;
-    use super::repeat;
-
-    #[test]
-    #[cfg_attr(target_os = "emscripten", ignore)]
-    fn read_until() {
-        let mut buf = Cursor::new(&b"12"[..]);
-        let mut v = Vec::new();
-        assert_eq!(buf.read_until(b'3', &mut v).unwrap(), 2);
-        assert_eq!(v, b"12");
-
-        let mut buf = Cursor::new(&b"1233"[..]);
-        let mut v = Vec::new();
-        assert_eq!(buf.read_until(b'3', &mut v).unwrap(), 3);
-        assert_eq!(v, b"123");
-        v.truncate(0);
-        assert_eq!(buf.read_until(b'3', &mut v).unwrap(), 1);
-        assert_eq!(v, b"3");
-        v.truncate(0);
-        assert_eq!(buf.read_until(b'3', &mut v).unwrap(), 0);
-        assert_eq!(v, []);
-    }
-
-    #[test]
-    fn split() {
-        let buf = Cursor::new(&b"12"[..]);
-        let mut s = buf.split(b'3');
-        assert_eq!(s.next().unwrap().unwrap(), vec![b'1', b'2']);
-        assert!(s.next().is_none());
-
-        let buf = Cursor::new(&b"1233"[..]);
-        let mut s = buf.split(b'3');
-        assert_eq!(s.next().unwrap().unwrap(), vec![b'1', b'2']);
-        assert_eq!(s.next().unwrap().unwrap(), vec![]);
-        assert!(s.next().is_none());
-    }
-
-    #[test]
-    fn read_line() {
-        let mut buf = Cursor::new(&b"12"[..]);
-        let mut v = String::new();
-        assert_eq!(buf.read_line(&mut v).unwrap(), 2);
-        assert_eq!(v, "12");
-
-        let mut buf = Cursor::new(&b"12\n\n"[..]);
-        let mut v = String::new();
-        assert_eq!(buf.read_line(&mut v).unwrap(), 3);
-        assert_eq!(v, "12\n");
-        v.truncate(0);
-        assert_eq!(buf.read_line(&mut v).unwrap(), 1);
-        assert_eq!(v, "\n");
-        v.truncate(0);
-        assert_eq!(buf.read_line(&mut v).unwrap(), 0);
-        assert_eq!(v, "");
-    }
-
-    #[test]
-    fn lines() {
-        let buf = Cursor::new(&b"12\r"[..]);
-        let mut s = buf.lines();
-        assert_eq!(s.next().unwrap().unwrap(), "12\r".to_string());
-        assert!(s.next().is_none());
-
-        let buf = Cursor::new(&b"12\r\n\n"[..]);
-        let mut s = buf.lines();
-        assert_eq!(s.next().unwrap().unwrap(), "12".to_string());
-        assert_eq!(s.next().unwrap().unwrap(), "".to_string());
-        assert!(s.next().is_none());
-    }
-
-    #[test]
-    fn read_to_end() {
-        let mut c = Cursor::new(&b""[..]);
-        let mut v = Vec::new();
-        assert_eq!(c.read_to_end(&mut v).unwrap(), 0);
-        assert_eq!(v, []);
-
-        let mut c = Cursor::new(&b"1"[..]);
-        let mut v = Vec::new();
-        assert_eq!(c.read_to_end(&mut v).unwrap(), 1);
-        assert_eq!(v, b"1");
-
-        let cap = 1024 * 1024;
-        let data = (0..cap).map(|i| (i / 3) as u8).collect::<Vec<_>>();
-        let mut v = Vec::new();
-        let (a, b) = data.split_at(data.len() / 2);
-        assert_eq!(Cursor::new(a).read_to_end(&mut v).unwrap(), a.len());
-        assert_eq!(Cursor::new(b).read_to_end(&mut v).unwrap(), b.len());
-        assert_eq!(v, data);
-    }
-
-    #[test]
-    fn read_to_string() {
-        let mut c = Cursor::new(&b""[..]);
-        let mut v = String::new();
-        assert_eq!(c.read_to_string(&mut v).unwrap(), 0);
-        assert_eq!(v, "");
-
-        let mut c = Cursor::new(&b"1"[..]);
-        let mut v = String::new();
-        assert_eq!(c.read_to_string(&mut v).unwrap(), 1);
-        assert_eq!(v, "1");
-
-        let mut c = Cursor::new(&b"\xff"[..]);
-        let mut v = String::new();
-        assert!(c.read_to_string(&mut v).is_err());
-    }
-
-    #[test]
-    fn read_exact() {
-        let mut buf = [0; 4];
-
-        let mut c = Cursor::new(&b""[..]);
-        assert_eq!(c.read_exact(&mut buf).unwrap_err().kind(),
-                   io::ErrorKind::UnexpectedEof);
-
-        let mut c = Cursor::new(&b"123"[..]).chain(Cursor::new(&b"456789"[..]));
-        c.read_exact(&mut buf).unwrap();
-        assert_eq!(&buf, b"1234");
-        c.read_exact(&mut buf).unwrap();
-        assert_eq!(&buf, b"5678");
-        assert_eq!(c.read_exact(&mut buf).unwrap_err().kind(),
-                   io::ErrorKind::UnexpectedEof);
-    }
-
-    #[test]
-    fn read_exact_slice() {
-        let mut buf = [0; 4];
-
-        let mut c = &b""[..];
-        assert_eq!(c.read_exact(&mut buf).unwrap_err().kind(),
-                   io::ErrorKind::UnexpectedEof);
-
-        let mut c = &b"123"[..];
-        assert_eq!(c.read_exact(&mut buf).unwrap_err().kind(),
-                   io::ErrorKind::UnexpectedEof);
-        // make sure the optimized (early returning) method is being used
-        assert_eq!(&buf, &[0; 4]);
-
-        let mut c = &b"1234"[..];
-        c.read_exact(&mut buf).unwrap();
-        assert_eq!(&buf, b"1234");
-
-        let mut c = &b"56789"[..];
-        c.read_exact(&mut buf).unwrap();
-        assert_eq!(&buf, b"5678");
-        assert_eq!(c, b"9");
-    }
-
-    #[test]
-    fn take_eof() {
-        struct R;
-
-        impl Read for R {
-            fn read(&mut self, _: &mut [u8]) -> io::Result<usize> {
-                Err(io::Error::new(io::ErrorKind::Other, ""))
-            }
-        }
-        impl BufRead for R {
-            fn fill_buf(&mut self) -> io::Result<&[u8]> {
-                Err(io::Error::new(io::ErrorKind::Other, ""))
-            }
-            fn consume(&mut self, _amt: usize) { }
-        }
-
-        let mut buf = [0; 1];
-        assert_eq!(0, R.take(0).read(&mut buf).unwrap());
-        assert_eq!(b"", R.take(0).fill_buf().unwrap());
-    }
-
-    fn cmp_bufread<Br1: BufRead, Br2: BufRead>(mut br1: Br1, mut br2: Br2, exp: &[u8]) {
-        let mut cat = Vec::new();
-        loop {
-            let consume = {
-                let buf1 = br1.fill_buf().unwrap();
-                let buf2 = br2.fill_buf().unwrap();
-                let minlen = if buf1.len() < buf2.len() { buf1.len() } else { buf2.len() };
-                assert_eq!(buf1[..minlen], buf2[..minlen]);
-                cat.extend_from_slice(&buf1[..minlen]);
-                minlen
-            };
-            if consume == 0 {
-                break;
-            }
-            br1.consume(consume);
-            br2.consume(consume);
-        }
-        assert_eq!(br1.fill_buf().unwrap().len(), 0);
-        assert_eq!(br2.fill_buf().unwrap().len(), 0);
-        assert_eq!(&cat[..], &exp[..])
-    }
-
-    #[test]
-    fn chain_bufread() {
-        let testdata = b"ABCDEFGHIJKL";
-        let chain1 = (&testdata[..3]).chain(&testdata[3..6])
-                                     .chain(&testdata[6..9])
-                                     .chain(&testdata[9..]);
-        let chain2 = (&testdata[..4]).chain(&testdata[4..8])
-                                     .chain(&testdata[8..]);
-        cmp_bufread(chain1, chain2, &testdata[..]);
-    }
-
-    #[test]
-    fn chain_zero_length_read_is_not_eof() {
-        let a = b"A";
-        let b = b"B";
-        let mut s = String::new();
-        let mut chain = (&a[..]).chain(&b[..]);
-        chain.read(&mut []).unwrap();
-        chain.read_to_string(&mut s).unwrap();
-        assert_eq!("AB", s);
-    }
-
-    #[bench]
-    #[cfg_attr(target_os = "emscripten", ignore)]
-    fn bench_read_to_end(b: &mut test::Bencher) {
-        b.iter(|| {
-            let mut lr = repeat(1).take(10000000);
-            let mut vec = Vec::with_capacity(1024);
-            super::read_to_end(&mut lr, &mut vec)
-        });
-    }
-}

+ 0 - 163
dlibc/posix-regex/src/compile.rs

@@ -312,166 +312,3 @@ impl<'a> PosixRegexBuilder<'a> {
         Ok(alternatives)
     }
 }
-
-#[cfg(test)]
-mod tests {
-    use super::*;
-
-    fn compile(input: &[u8]) -> Vec<(Token, Range)> {
-        PosixRegexBuilder::new(input)
-            .with_default_classes()
-            .compile_tokens()
-            .expect("error compiling regex")
-            .into_iter()
-            .next()
-            .unwrap()
-    }
-    fn t(t: Token) -> (Token, Range) {
-        (t, Range(1, Some(1)))
-    }
-    fn c(c: u8) -> (Token, Range) {
-        t(Token::Char(c))
-    }
-
-    #[test]
-    fn basic() {
-        assert_eq!(compile(b"abc"), &[c(b'a'), c(b'b'), c(b'c')]);
-    }
-    #[test]
-    fn groups() {
-        assert_eq!(compile(br"\(abc\|bcd\|cde\)"), &[t(Token::Group { id: 1, branches: vec![
-            vec![c(b'a'), c(b'b'), c(b'c')],
-            vec![c(b'b'), c(b'c'), c(b'd')],
-            vec![c(b'c'), c(b'd'), c(b'e')]
-        ]})]);
-        assert_eq!(compile(br"\(abc\|\(bcd\|cde\)\)"), &[
-            t(Token::Group { id: 1, branches: vec![
-                vec![c(b'a'), c(b'b'), c(b'c')],
-                vec![t(Token::Group { id: 2, branches: vec![
-                    vec![c(b'b'), c(b'c'), c(b'd')],
-                    vec![c(b'c'), c(b'd'), c(b'e')]
-                ]})]
-            ]})
-        ]);
-    }
-    #[test]
-    fn words() {
-        assert_eq!(
-            compile(br"\<word\>"),
-            &[t(Token::WordStart), c(b'w'), c(b'o'), c(b'r'), c(b'd'), t(Token::WordEnd)]
-        );
-    }
-    #[test]
-    fn repetitions() {
-        assert_eq!(
-            compile(br"yeee*"),
-            &[c(b'y'), c(b'e'), c(b'e'), (Token::Char(b'e'), Range(0, None))]
-        );
-        assert_eq!(
-            compile(br"yee\?"),
-            &[c(b'y'), c(b'e'), (Token::Char(b'e'), Range(0, Some(1)))]
-        );
-        assert_eq!(
-            compile(br"yee\+"),
-            &[c(b'y'), c(b'e'), (Token::Char(b'e'), Range(1, None))]
-        );
-        assert_eq!(
-            compile(br"ye\{2}"),
-            &[c(b'y'), (Token::Char(b'e'), Range(2, Some(2)))]
-        );
-        assert_eq!(
-            compile(br"ye\{2,}"),
-            &[c(b'y'), (Token::Char(b'e'), Range(2, None))]
-        );
-        assert_eq!(
-            compile(br"ye\{2,3}"),
-            &[c(b'y'), (Token::Char(b'e'), Range(2, Some(3)))]
-        );
-    }
-    #[test]
-    fn bracket() {
-        assert_eq!(
-            compile(b"[abc]"),
-            &[t(Token::OneOf {
-                invert: false,
-                list: vec![
-                    Collation::Char(b'a'),
-                    Collation::Char(b'b'),
-                    Collation::Char(b'c')
-                ]
-            })]
-        );
-        assert_eq!(
-            compile(b"[^abc]"),
-            &[t(Token::OneOf {
-                invert: true,
-                list: vec![
-                    Collation::Char(b'a'),
-                    Collation::Char(b'b'),
-                    Collation::Char(b'c')
-                ]
-            })]
-        );
-        assert_eq!(
-            compile(b"[]] [^]]"),
-            &[
-                t(Token::OneOf { invert: false, list: vec![ Collation::Char(b']') ] }),
-                c(b' '),
-                t(Token::OneOf { invert: true,  list: vec![ Collation::Char(b']') ] }),
-            ]
-        );
-        assert_eq!(
-            compile(b"[0-3] [a-c] [-1] [1-]"),
-            &[
-                t(Token::OneOf { invert: false, list: vec![
-                    Collation::Char(b'0'),
-                    Collation::Char(b'1'),
-                    Collation::Char(b'2'),
-                    Collation::Char(b'3')
-                ] }),
-                c(b' '),
-                t(Token::OneOf { invert: false, list: vec![
-                    Collation::Char(b'a'),
-                    Collation::Char(b'b'),
-                    Collation::Char(b'c')
-                ] }),
-                c(b' '),
-                t(Token::OneOf { invert: false, list: vec![
-                    Collation::Char(b'-'),
-                    Collation::Char(b'1')
-                ] }),
-                c(b' '),
-                t(Token::OneOf { invert: false, list: vec![
-                    Collation::Char(b'1'),
-                    Collation::Char(b'-')
-                ] })
-            ]
-        );
-        assert_eq!(
-            compile(b"[[.-.]-/]"),
-            &[
-                t(Token::OneOf { invert: false, list: vec![
-                    Collation::Char(b'-'),
-                    Collation::Char(b'.'),
-                    Collation::Char(b'/')
-                ] })
-            ]
-        );
-        assert_eq!(
-            compile(b"[[:digit:][:upper:]]"),
-            &[
-                t(Token::OneOf { invert: false, list: vec![
-                    Collation::Class(ctype::is_digit),
-                    Collation::Class(ctype::is_upper)
-                ] })
-            ]
-        );
-    }
-    #[test]
-    fn newline() {
-        assert_eq!(
-            compile(br"\r\n"),
-            &[c(b'\r'), c(b'\n')]
-        );
-    }
-}

+ 0 - 259
dlibc/posix-regex/src/matcher.rs

@@ -491,262 +491,3 @@ impl<'a> PosixRegexMatcher<'a> {
         }
     }
 }
-
-#[cfg(test)]
-mod tests {
-    #[cfg(feature = "bench")]
-    extern crate test;
-
-    #[cfg(feature = "bench")]
-    use self::test::Bencher;
-
-    use super::*;
-    use ::PosixRegexBuilder;
-
-    // FIXME: Workaround to coerce a Box<[T; N]> into a Box<[T]>. Use type
-    // ascription when stabilized.
-    fn boxed_slice<T>(slice: Box<[T]>) -> Box<[T]> {
-        slice
-    }
-
-    macro_rules! abox {
-        ($($item:expr),*) => {
-            boxed_slice(Box::new([$($item),*]))
-        }
-    }
-
-    fn compile(regex: &str) -> PosixRegex {
-        PosixRegexBuilder::new(regex.as_bytes())
-            .with_default_classes()
-            .compile()
-            .expect("error compiling regex")
-    }
-    fn matches(regex: &str, input: &str) -> Vec<Box<[Option<(usize, usize)>]>> {
-        compile(regex)
-            .matches(input.as_bytes(), None)
-    }
-    fn matches_exact(regex: &str, input: &str) -> Option<Box<[Option<(usize, usize)>]>> {
-        compile(regex)
-            .matches_exact(input.as_bytes())
-    }
-
-    #[test]
-    fn basic() {
-        assert!(matches_exact("abc", "abc").is_some());
-        assert!(matches_exact("abc", "bbc").is_none());
-        assert!(matches_exact("abc", "acc").is_none());
-        assert!(matches_exact("abc", "abd").is_none());
-    }
-    #[test]
-    fn repetitions() {
-        assert!(matches_exact("abc*", "ab").is_some());
-        assert!(matches_exact("abc*", "abc").is_some());
-        assert!(matches_exact("abc*", "abccc").is_some());
-
-        assert!(matches_exact(r"a\{1,2\}b", "b").is_none());
-        assert!(matches_exact(r"a\{1,2\}b", "ab").is_some());
-        assert!(matches_exact(r"a\{1,2\}b", "aab").is_some());
-        assert!(matches_exact(r"a\{1,2\}b", "aaab").is_none());
-
-        assert!(matches_exact(r"[abc]\{3\}", "abcTRAILING").is_some());
-        assert!(matches_exact(r"[abc]\{3\}", "abTRAILING").is_none());
-    }
-    #[test]
-    fn any() {
-        assert!(matches_exact(".*", "").is_some());
-        assert!(matches_exact(".*b", "b").is_some());
-        assert!(matches_exact(".*b", "ab").is_some());
-        assert!(matches_exact(".*b", "aaaaab").is_some());
-        assert!(matches_exact(".*b", "HELLO WORLD").is_none());
-        assert!(matches_exact(".*b", "HELLO WORLDb").is_some());
-        assert!(matches_exact("H.*O WORLD", "HELLO WORLD").is_some());
-        assert!(matches_exact("H.*ORLD", "HELLO WORLD").is_some());
-    }
-    #[test]
-    fn brackets() {
-        assert!(matches_exact("[abc]*d", "abcd").is_some());
-        assert!(matches_exact("[0-9]*d", "1234d").is_some());
-        assert!(matches_exact("[[:digit:]]*d", "1234d").is_some());
-        assert!(matches_exact("[[:digit:]]*d", "abcd").is_none());
-    }
-    #[test]
-    fn alternations() {
-        assert!(matches_exact(r"abc\|bcd", "abc").is_some());
-        assert!(matches_exact(r"abc\|bcd", "bcd").is_some());
-        assert!(matches_exact(r"abc\|bcd", "cde").is_none());
-        assert!(matches_exact(r"[A-Z]\+\|yee", "").is_none());
-        assert!(matches_exact(r"[A-Z]\+\|yee", "HELLO").is_some());
-        assert!(matches_exact(r"[A-Z]\+\|yee", "yee").is_some());
-        assert!(matches_exact(r"[A-Z]\+\|yee", "hello").is_none());
-    }
-    #[test]
-    fn offsets() {
-        assert_eq!(
-            matches_exact("abc", "abcd"),
-            Some(abox![Some((0, 3))])
-        );
-        assert_eq!(
-            matches_exact(r"[[:alpha:]]\+", "abcde12345"),
-            Some(abox![Some((0, 5))])
-        );
-        assert_eq!(
-            matches_exact(r"a\(bc\)\+d", "abcbcd"),
-            Some(abox![Some((0, 6)), Some((3, 5))])
-        );
-        assert_eq!(
-            matches_exact(r"hello\( \(world\|universe\) :D\)\?!", "hello world :D!"),
-            Some(abox![Some((0, 15)), Some((5, 14)), Some((6, 11))])
-        );
-        assert_eq!(
-            matches_exact(r"hello\( \(world\|universe\) :D\)\?", "hello world :D"),
-            Some(abox![Some((0, 14)), Some((5, 14)), Some((6, 11))])
-        );
-        assert_eq!(
-            matches_exact(r"\(\<hello\>\) world", "hello world"),
-            Some(abox![Some((0, 11)), Some((0, 5))])
-        );
-        assert_eq!(
-            matches_exact(r".*d", "hid howd ared youd"),
-            Some(abox![Some((0, 18))])
-        );
-        assert_eq!(
-            matches_exact(r".*\(a\)", "bbbbba"),
-            Some(abox![Some((0, 6)), Some((5, 6))])
-        );
-        assert_eq!(
-            matches_exact(r"\(a \(b\) \(c\)\) \(d\)", "a b c d"),
-            Some(abox![Some((0, 7)), Some((0, 5)), Some((2, 3)), Some((4, 5)), Some((6, 7))])
-        );
-        assert_eq!(
-            matches_exact(r"\(.\)*", "hello"),
-            Some(abox![Some((0, 5)), Some((4, 5))])
-        );
-        assert_eq!(
-            matches(r"h\(i\)", "hello hi lol"),
-            vec!(abox![Some((6, 8)), Some((7, 8))])
-        );
-        assert_eq!(
-            matches_exact(r"\(\([[:alpha:]]\)*\)", "abcdefg"),
-            Some(abox![Some((0, 7)), Some((0, 7)), Some((6, 7))])
-        );
-        assert_eq!(
-            matches_exact(r"\(\.\([[:alpha:]]\)\)*", ".a.b.c.d.e.f.g"),
-            Some(abox![Some((0, 14)), Some((12, 14)), Some((13, 14))])
-        );
-        assert_eq!(
-            matches_exact(r"\(a\|\(b\)\)*\(c\)", "bababac"),
-            Some(abox![Some((0, 7)), Some((5, 6)), Some((4, 5)), Some((6, 7))])
-        );
-        assert_eq!(
-            matches_exact(r"\(a\|\(b\)\)*\(c\)", "aaac"),
-            Some(abox![Some((0, 4)), Some((2, 3)), None, Some((3, 4))])
-        );
-    }
-    #[test]
-    fn start_and_end() {
-        assert!(matches_exact("^abc$", "abc").is_some());
-        assert!(matches_exact("^bcd", "bcde").is_some());
-        assert!(matches_exact("^bcd", "abcd").is_none());
-        assert!(matches_exact("abc$", "abc").is_some());
-        assert!(matches_exact("abc$", "abcd").is_none());
-
-        assert!(matches_exact(r".*\(^\|a\)c", "c").is_some());
-        assert!(matches_exact(r".*\(^\|a\)c", "ac").is_some());
-        assert!(matches_exact(r".*\(^\|a\)c", "bc").is_none());
-
-        // Tests if ^ can be repeated without issues
-        assert!(matches_exact(".*^^a", "helloabc").is_none());
-        assert!(matches_exact(".*^^a", "abc").is_some());
-    }
-    #[test]
-    fn word_boundaries() {
-        assert!(matches_exact(r"hello\>.world", "hello world").is_some());
-        assert!(matches_exact(r"hello\>.world", "hello!world").is_some());
-        assert!(matches_exact(r"hello\>.world", "hellooworld").is_none());
-
-        assert!(matches_exact(r"hello.\<world", "hello world").is_some());
-        assert!(matches_exact(r"hello.\<world", "hello!world").is_some());
-        assert!(matches_exact(r"hello.\<world", "hellooworld").is_none());
-
-        assert!(matches_exact(r".*\<hello\>", "hihello").is_none());
-        assert!(matches_exact(r".*\<hello\>", "hi_hello").is_none());
-        assert!(matches_exact(r".*\<hello\>", "hi hello").is_some());
-    }
-    #[test]
-    fn groups() {
-        assert!(matches_exact(r"\(hello\) world", "hello world").is_some());
-        assert!(matches_exact(r"\(a*\|b\|c\)d", "d").is_some());
-        assert!(matches_exact(r"\(a*\|b\|c\)d", "aaaad").is_some());
-        assert!(matches_exact(r"\(a*\|b\|c\)d", "bd").is_some());
-        assert!(matches_exact(r"\(a*\|b\|c\)d", "bbbbbd").is_none());
-    }
-    #[test]
-    fn repeating_groups() {
-        assert!(matches_exact(r"\(a\|b\|c\)*d", "d").is_some());
-        assert!(matches_exact(r"\(a\|b\|c\)*d", "aaaad").is_some());
-        assert!(matches_exact(r"\(a\|b\|c\)*d", "bbbbd").is_some());
-        assert!(matches_exact(r"\(a\|b\|c\)*d", "aabbd").is_some());
-
-        assert!(matches_exact(r"\(a\|b\|c\)\{1,2\}d", "d").is_none());
-        assert!(matches_exact(r"\(a\|b\|c\)\{1,2\}d", "ad").is_some());
-        assert!(matches_exact(r"\(a\|b\|c\)\{1,2\}d", "abd").is_some());
-        assert!(matches_exact(r"\(a\|b\|c\)\{1,2\}d", "abcd").is_none());
-        assert!(matches_exact(r"\(\(a\|b\|c\)\)\{1,2\}d", "abd").is_some());
-        assert!(matches_exact(r"\(\(a\|b\|c\)\)\{1,2\}d", "abcd").is_none());
-
-        assert!(matches_exact(r"\(a\|b\|c\)\{4\}d", "ababad").is_none());
-        assert!(matches_exact(r"\(a\|b\|c\)\{4\}d", "ababd").is_some());
-        assert!(matches_exact(r"\(a\|b\|c\)\{4\}d", "abad").is_none());
-
-        assert!(matches_exact(r"\(\([abc]\)\)\{3\}", "abcTRAILING").is_some());
-        assert!(matches_exact(r"\(\([abc]\)\)\{3\}", "abTRAILING").is_none());
-    }
-    #[test]
-    fn case_insensitive() {
-        assert!(compile(r"abc[de]")
-            .case_insensitive(true)
-            .matches_exact(b"ABCD")
-            .is_some());
-        assert!(compile(r"abc[de]")
-            .case_insensitive(true)
-            .matches_exact(b"ABCF")
-            .is_none());
-    }
-    #[test]
-    fn newline() {
-        assert_eq!(compile(r"^hello$")
-            .newline(true)
-            .matches(b"hi\nhello\ngreetings", None)
-            .len(), 1);
-        assert!(compile(r"^hello$")
-            .newline(true)
-            .matches(b"hi\ngood day\ngreetings", None)
-            .is_empty());
-    }
-    #[test]
-    fn no_start_end() {
-        assert!(compile(r"^hello")
-            .no_start(true)
-            .matches_exact(b"hello")
-            .is_none());
-        assert!(compile(r"hello$")
-            .no_end(true)
-            .matches_exact(b"hello")
-            .is_none());
-    }
-
-    #[cfg(feature = "bench")]
-    #[bench]
-    fn speed_matches_exact(b: &mut Bencher) {
-        b.iter(|| {
-            assert!(matches_exact(r"\(\(a*\|b\|c\) test\|yee\)", "aaaaa test").is_some());
-        })
-    }
-    #[cfg(feature = "bench")]
-    #[bench]
-    fn speed_matches(b: &mut Bencher) {
-        b.iter(|| {
-            assert_eq!(matches(r"\(\(a*\|b\|c\) test\|yee\)", "oooo aaaaa test").len(), 1);
-        })
-    }
-}

+ 0 - 54
dlibc/src/unix/c_vec.rs

@@ -233,57 +233,3 @@ impl WriteByte for CVec<u8> {
     }
 }
 
-#[cfg(test)]
-mod tests {
-    use super::CVec;
-
-    #[test]
-    fn push_pop() {
-        let mut vec = CVec::new();
-        vec.push(1).unwrap();
-        vec.push(2).unwrap();
-        vec.push(3).unwrap();
-        assert_eq!(&vec[..], &[1, 2, 3]);
-        assert_eq!(vec.pop().unwrap(), 3);
-        assert_eq!(&vec[..], &[1, 2]);
-    }
-    #[test]
-    fn extend_from_slice() {
-        use core_io::Write;
-
-        let mut vec = CVec::new();
-        vec.extend_from_slice(&[1, 2, 3]).unwrap();
-        vec.extend_from_slice(&[4, 5, 6]).unwrap();
-        assert_eq!(&vec[..], &[1, 2, 3, 4, 5, 6]);
-        assert_eq!(vec.write(&[7, 8, 9]).unwrap(), 3);
-        assert_eq!(&vec[..], &[1, 2, 3, 4, 5, 6, 7, 8, 9]);
-    }
-    #[test]
-    fn dropped() {
-        use alloc::rc::Rc;
-
-        let counter = Rc::new(());
-        let mut vec = CVec::with_capacity(3).unwrap();
-        vec.push(Rc::clone(&counter)).unwrap();
-        vec.push(Rc::clone(&counter)).unwrap();
-        vec.push(Rc::clone(&counter)).unwrap();
-        assert_eq!(Rc::strong_count(&counter), 4);
-
-        let popped = vec.pop().unwrap();
-        assert_eq!(Rc::strong_count(&counter), 4);
-        drop(popped);
-        assert_eq!(Rc::strong_count(&counter), 3);
-
-        vec.push(Rc::clone(&counter)).unwrap();
-        vec.push(Rc::clone(&counter)).unwrap();
-        vec.push(Rc::clone(&counter)).unwrap();
-
-        assert_eq!(vec.len(), 5);
-        assert_eq!(Rc::strong_count(&counter), 6);
-        vec.truncate(1);
-        assert_eq!(Rc::strong_count(&counter), 2);
-
-        drop(vec);
-        assert_eq!(Rc::strong_count(&counter), 1);
-    }
-}

+ 0 - 1
dlibc/src/unix/mod.rs

@@ -11,7 +11,6 @@ pub type uint8_t = u8;
 pub type uint16_t = u16;
 pub type uint32_t = u32;
 pub type uint64_t = u64;
-
 pub type c_schar = i8;
 pub type c_uchar = u8;
 pub type c_short = i16;

+ 79 - 0
src/lib.rs

@@ -84,6 +84,81 @@
 #![feature(panic_info_message)]
 #![feature(panic_can_unwind)]
 #![feature(const_mut_refs)]
+#![feature(std_internals)]
+#![feature(extend_one)]
+#![feature(exact_size_is_empty)]
+#![feature(core_panic)]
+#![feature(char_internals)]
+#![feature(str_internals)]
+#![feature(error_in_core)]
+#![feature(error_generic_member_access)]
+#![feature(saturating_int_impl)]
+#![feature(edition_panic)]
+#![feature(custom_test_frameworks)]
+#![feature(alloc_error_handler)]
+#![feature(concat_bytes)]
+#![feature(trace_macros)]
+#![feature(log_syntax)]
+#![feature(format_args_nl)]
+#![feature(concat_idents)]
+#![feature(ip_in_core)]
+#![feature(ip)]
+#![feature(cfg_eval)]
+#![feature(cfg_accessible)]
+#![feature(derive_const)]
+#![feature(strict_provenance)]
+#![feature(slice_concat_trait)]
+#![feature(deprecated_suggestion)]
+#![feature(prelude_2024)]
+#![feature(exclusive_wrapper)]
+#![feature(never_type)]
+#![feature(dropck_eyepatch)]
+#![feature(must_not_suspend)]
+#![feature(negative_impls)]
+#![feature(let_chains)]
+#![feature(rustc_attrs)]
+#![feature(allow_internal_unstable)]
+#![feature(type_alias_impl_trait)]
+#![feature(specialization)]
+#![feature(decl_macro)]
+#![feature(doc_notable_trait)]
+#![feature(doc_cfg)]
+#![feature(ascii_char)]
+#![feature(type_ascription)]
+#![feature(if_let_guard)]
+#![feature(prelude_import)]
+#![feature(doc_masked)]
+#![feature(rustdoc_internals)]
+#![feature(async_iterator)]
+#![feature(assert_matches)]
+#![feature(const_format_args)]
+#![feature(portable_simd)]
+#![feature(slice_internals)]
+#![feature(utf8_chunks)]
+#![feature(stmt_expr_attributes)]
+#![feature(cfg_target_thread_local)]
+#![feature(hashmap_internals)]
+#![feature(try_reserve_kind)]
+#![feature(hasher_prefixfree_extras)]
+#![feature(inline_const)]
+#![feature(allow_internal_unsafe)]
+#![feature(raw_os_nonzero)]
+#![feature(try_blocks)]
+#![feature(offset_of)]
+#![feature(btree_extract_if)]
+#![feature(panic_internals)]
+#![feature(slice_ptr_get)]
+#![feature(alloc_layout_extra)]
+#![feature(pointer_byte_offsets)]
+#![feature(new_uninit)]
+#![feature(get_mut_unchecked)]
+#![feature(error_iter)]
+#![feature(maybe_uninit_slice)]
+#![feature(ptr_as_uninit)]
+#![feature(maybe_uninit_write_slice)]
+#![feature(panic_info_message)]
+#![feature(panic_can_unwind)]
+#![feature(const_mut_refs)]
 
 #[macro_use]
 extern crate alloc;
@@ -95,8 +170,12 @@ extern crate memoffset;
 #[cfg(target_os = "dragonos")]
 #[macro_use]
 extern crate dsc;
+
 pub mod std;
+pub use self::std::*;
 
+#[cfg(target_os = "dragonos")]
+#[macro_use]
 pub use dlibc::{eprint, eprintln, print, println};
 
 // use core::panic::PanicInfo;

+ 0 - 23
src/std/io/buffered/tests.rs

@@ -524,29 +524,6 @@ fn panic_in_write_doesnt_flush_in_drop() {
     assert_eq!(WRITES.load(Ordering::SeqCst), 1);
 }
 
-#[bench]
-fn bench_buffered_reader(b: &mut test::Bencher) {
-    b.iter(|| BufReader::new(io::empty()));
-}
-
-#[bench]
-fn bench_buffered_reader_small_reads(b: &mut test::Bencher) {
-    let data = (0..u8::MAX).cycle().take(1024 * 4).collect::<Vec<_>>();
-    b.iter(|| {
-        let mut reader = BufReader::new(&data[..]);
-        let mut buf = [0u8; 4];
-        for _ in 0..1024 {
-            reader.read_exact(&mut buf).unwrap();
-            core::hint::black_box(&buf);
-        }
-    });
-}
-
-#[bench]
-fn bench_buffered_writer(b: &mut test::Bencher) {
-    b.iter(|| BufWriter::new(io::sink()));
-}
-
 /// A simple `Write` target, designed to be wrapped by `LineWriter` /
 /// `BufWriter` / etc, that can have its `write` & `flush` behavior
 /// configured

+ 0 - 135
src/std/io/copy/tests.rs

@@ -3,19 +3,6 @@ use crate::std::collections::VecDeque;
 use crate::std::io;
 use crate::std::io::*;
 
-#[test]
-fn copy_copies() {
-    let mut r = repeat(0).take(4);
-    let mut w = sink();
-    assert_eq!(copy(&mut r, &mut w).unwrap(), 4);
-
-    let mut r = repeat(0).take(1 << 17);
-    assert_eq!(
-        copy(&mut r as &mut dyn Read, &mut w as &mut dyn Write).unwrap(),
-        1 << 17
-    );
-}
-
 struct ShortReader {
     cap: usize,
     read_size: usize,
@@ -45,125 +32,3 @@ impl Write for WriteObserver {
         Ok(())
     }
 }
-
-#[test]
-fn copy_specializes_bufwriter() {
-    let cap = 117 * 1024;
-    let buf_sz = 16 * 1024;
-    let mut r = ShortReader {
-        cap,
-        observed_buffer: 0,
-        read_size: 1337,
-    };
-    let mut w = BufWriter::with_capacity(buf_sz, WriteObserver { observed_buffer: 0 });
-    assert_eq!(
-        copy(&mut r, &mut w).unwrap(),
-        cap as u64,
-        "expected the whole capacity to be copied"
-    );
-    assert_eq!(
-        r.observed_buffer, buf_sz,
-        "expected a large buffer to be provided to the reader"
-    );
-    assert!(
-        w.get_mut().observed_buffer > DEFAULT_BUF_SIZE,
-        "expected coalesced writes"
-    );
-}
-
-#[test]
-fn copy_specializes_bufreader() {
-    let mut source = vec![0; 768 * 1024];
-    source[1] = 42;
-    let mut buffered = BufReader::with_capacity(256 * 1024, Cursor::new(&mut source));
-
-    let mut sink = Vec::new();
-    assert_eq!(
-        crate::std::io::copy(&mut buffered, &mut sink).unwrap(),
-        source.len() as u64
-    );
-    assert_eq!(source.as_slice(), sink.as_slice());
-
-    let buf_sz = 71 * 1024;
-    assert!(buf_sz > DEFAULT_BUF_SIZE, "test precondition");
-
-    let mut buffered = BufReader::with_capacity(buf_sz, Cursor::new(&mut source));
-    let mut sink = WriteObserver { observed_buffer: 0 };
-    assert_eq!(
-        crate::std::io::copy(&mut buffered, &mut sink).unwrap(),
-        source.len() as u64
-    );
-    assert_eq!(
-        sink.observed_buffer, buf_sz,
-        "expected a large buffer to be provided to the writer"
-    );
-}
-
-#[test]
-fn copy_specializes_to_vec() {
-    let cap = 123456;
-    let mut source = ShortReader {
-        cap,
-        observed_buffer: 0,
-        read_size: 1337,
-    };
-    let mut sink = Vec::new();
-    assert_eq!(cap as u64, io::copy(&mut source, &mut sink).unwrap());
-    assert!(
-        source.observed_buffer > DEFAULT_BUF_SIZE,
-        "expected a large buffer to be provided to the reader"
-    );
-}
-
-#[test]
-fn copy_specializes_from_vecdeque() {
-    let mut source = VecDeque::with_capacity(100 * 1024);
-    for _ in 0..20 * 1024 {
-        source.push_front(0);
-    }
-    for _ in 0..20 * 1024 {
-        source.push_back(0);
-    }
-    let mut sink = WriteObserver { observed_buffer: 0 };
-    assert_eq!(40 * 1024u64, io::copy(&mut source, &mut sink).unwrap());
-    assert_eq!(20 * 1024, sink.observed_buffer);
-}
-
-#[test]
-fn copy_specializes_from_slice() {
-    let mut source = [1; 60 * 1024].as_slice();
-    let mut sink = WriteObserver { observed_buffer: 0 };
-    assert_eq!(60 * 1024u64, io::copy(&mut source, &mut sink).unwrap());
-    assert_eq!(60 * 1024, sink.observed_buffer);
-}
-
-#[cfg(unix)]
-mod io_benches {
-    use crate::std::fs::File;
-    use crate::std::fs::OpenOptions;
-    use crate::std::io::prelude::*;
-    use crate::std::io::BufReader;
-
-    use test::Bencher;
-
-    #[bench]
-    fn bench_copy_buf_reader(b: &mut Bencher) {
-        let mut file_in = File::open("/dev/zero").expect("opening /dev/zero failed");
-        // use dyn to avoid specializations unrelated to readbuf
-        let dyn_in = &mut file_in as &mut dyn Read;
-        let mut reader = BufReader::with_capacity(256 * 1024, dyn_in.take(0));
-        let mut writer = OpenOptions::new()
-            .write(true)
-            .open("/dev/null")
-            .expect("opening /dev/null failed");
-
-        const BYTES: u64 = 1024 * 1024;
-
-        b.bytes = BYTES;
-
-        b.iter(|| {
-            reader.get_mut().set_limit(BYTES);
-            crate::std::io::copy(&mut reader, &mut writer).unwrap()
-        });
-    }
-}

+ 0 - 36
src/std/io/cursor/tests.rs

@@ -576,39 +576,3 @@ fn const_cursor() {
     const _: &&[u8] = CURSOR.get_ref();
     const _: u64 = CURSOR.position();
 }
-
-#[bench]
-fn bench_write_vec(b: &mut test::Bencher) {
-    let slice = &[1; 128];
-
-    b.iter(|| {
-        let mut buf = b"some random data to overwrite".to_vec();
-        let mut cursor = Cursor::new(&mut buf);
-
-        let _ = cursor.write_all(slice);
-        test::black_box(&cursor);
-    })
-}
-
-#[bench]
-fn bench_write_vec_vectored(b: &mut test::Bencher) {
-    let slices = [
-        IoSlice::new(&[1; 128]),
-        IoSlice::new(&[2; 256]),
-        IoSlice::new(&[3; 512]),
-        IoSlice::new(&[4; 1024]),
-        IoSlice::new(&[5; 2048]),
-        IoSlice::new(&[6; 4096]),
-        IoSlice::new(&[7; 8192]),
-        IoSlice::new(&[8; 8192 * 2]),
-    ];
-
-    b.iter(|| {
-        let mut buf = b"some random data to overwrite".to_vec();
-        let mut cursor = Cursor::new(&mut buf);
-
-        let mut slices = slices;
-        let _ = cursor.write_all_vectored(&mut slices);
-        test::black_box(&cursor);
-    })
-}

+ 0 - 2
src/std/io/impls.rs

@@ -1,5 +1,3 @@
-#[cfg(test)]
-mod tests;
 
 use crate::std::cmp;
 use crate::std::collections::VecDeque;

+ 0 - 31
src/std/io/tests.rs

@@ -333,17 +333,6 @@ fn chain_zero_length_read_is_not_eof() {
     assert_eq!("AB", s);
 }
 
-#[bench]
-#[cfg_attr(target_os = "emscripten", ignore)]
-#[cfg_attr(miri, ignore)] // Miri isn't fast...
-fn bench_read_to_end(b: &mut test::Bencher) {
-    b.iter(|| {
-        let mut lr = repeat(1).take(10000000);
-        let mut vec = Vec::with_capacity(1024);
-        super::default_read_to_end(&mut lr, &mut vec, None)
-    });
-}
-
 #[test]
 fn seek_len() -> io::Result<()> {
     let mut c = Cursor::new(vec![0; 15]);
@@ -644,23 +633,3 @@ fn test_take_wrong_length() {
     // Primed the `Limit` by lying about the read size.
     let _ = reader.read(&mut buffer[..]);
 }
-
-#[bench]
-fn bench_take_read(b: &mut test::Bencher) {
-    b.iter(|| {
-        let mut buf = [0; 64];
-
-        [255; 128].take(64).read(&mut buf).unwrap();
-    });
-}
-
-#[bench]
-fn bench_take_read_buf(b: &mut test::Bencher) {
-    b.iter(|| {
-        let buf: &mut [_] = &mut [MaybeUninit::uninit(); 64];
-
-        let mut buf: BorrowedBuf<'_> = buf.into();
-
-        [255; 128].take(64).read_buf(buf.unfilled()).unwrap();
-    });
-}

+ 0 - 3
src/std/sys/common/mod.rs

@@ -13,6 +13,3 @@
 pub mod alloc;
 pub mod small_c_string;
 pub mod thread_local;
-
-#[cfg(test)]
-mod tests;

+ 0 - 2
src/std/sys/unix/kernel_copy.rs

@@ -65,8 +65,6 @@ use dlibc::sendfile as sendfile64;
 #[cfg(all(target_os = "linux", target_env = "gnu"))]
 use dlibc::sendfile64;
 use dlibc::{EBADF, EINVAL, ENOSYS, EOPNOTSUPP, EOVERFLOW, EPERM, EXDEV};
-#[cfg(test)]
-mod tests;
 
 pub(crate) fn copy_spec<R: Read + ?Sized, W: Write + ?Sized>(
     read: &mut R,