Sfoglia il codice sorgente

Merge branch 'master' into fix_testdata_runner

crowlkats 4 anni fa
parent
commit
a18a2a3c2b

+ 4 - 4
.github/workflows/codecov.yml

@@ -2,7 +2,7 @@ name: Coverage
 
 on:
   push:
-    branches: ['master']
+    branches: ["master"]
   pull_request:
 
 jobs:
@@ -16,9 +16,9 @@ jobs:
           toolchain: stable
           override: true
       - uses: actions-rs/tarpaulin@v0.1
-      - uses: codecov/codecov-action@v1.0.2
-        with:
-          token: ${{secrets.CODECOV_TOKEN}}
+      - uses: codecov/codecov-action@v2.1.0
+        # A codecov token is not needed for public repos if the repo is linked
+        # on codecov.io. See https://docs.codecov.com/docs/frequently-asked-questions#where-is-the-repository-upload-token-found
       - uses: actions/upload-artifact@v1
         with:
           name: code-coverage-report

+ 6 - 6
.github/workflows/main.yml

@@ -2,7 +2,7 @@ name: CI
 
 on:
   push:
-    branches: ['master']
+    branches: ["master"]
   pull_request:
 
 jobs:
@@ -10,12 +10,12 @@ jobs:
     strategy:
       matrix:
         os: [ubuntu-latest, macos-latest, windows-latest]
-        rust: [1.36.0, stable, beta, nightly]
+        rust: [1.45.0, stable, beta, nightly]
         exclude:
           - os: macos-latest
-            rust: 1.36.0
+            rust: 1.45.0
           - os: windows-latest
-            rust: 1.36.0
+            rust: 1.45.0
           - os: macos-latest
             rust: beta
           - os: windows-latest
@@ -81,5 +81,5 @@ jobs:
   Audit:
     runs-on: ubuntu-latest
     steps:
-    - uses: actions/checkout@v1
-    - uses: EmbarkStudios/cargo-deny-action@v1
+      - uses: actions/checkout@v1
+      - uses: EmbarkStudios/cargo-deny-action@v1

+ 1 - 1
LICENSE-MIT

@@ -1,4 +1,4 @@
-Copyright (c) 2013-2016 The rust-url developers
+Copyright (c) 2013-2022 The rust-url developers
 
 Permission is hereby granted, free of charge, to any
 person obtaining a copy of this software and associated

+ 2 - 1
data-url/Cargo.toml

@@ -7,12 +7,13 @@ repository = "https://github.com/servo/rust-url"
 license = "MIT OR Apache-2.0"
 edition = "2018"
 autotests = false
+rust-version = "1.45"
 
 [dependencies]
 matches = "0.1"
 
 [dev-dependencies]
-rustc-test = "0.3"
+tester = "0.9"
 serde = {version = "1.0", features = ["derive"]}
 serde_json = "1.0"
 

+ 3 - 4
data-url/src/mime.rs

@@ -62,7 +62,6 @@ fn split2(s: &str, separator: char) -> (&str, Option<&str>) {
     (first, iter.next())
 }
 
-#[allow(clippy::manual_strip)] // introduced in 1.45, MSRV is 1.36
 fn parse_parameters(s: &str, parameters: &mut Vec<(String, String)>) {
     let mut semicolon_separated = s.split(';');
 
@@ -73,10 +72,10 @@ fn parse_parameters(s: &str, parameters: &mut Vec<(String, String)>) {
             continue;
         }
         if let Some(value) = value {
-            let value = if value.starts_with('"') {
-                let max_len = value.len().saturating_sub(2); // without start or end quotes
+            let value = if let Some(stripped) = value.strip_prefix('"') {
+                let max_len = stripped.len().saturating_sub(1); // without end quote
                 let mut unescaped_value = String::with_capacity(max_len);
-                let mut chars = value[1..].chars();
+                let mut chars = stripped.chars();
                 'until_closing_quote: loop {
                     while let Some(c) = chars.next() {
                         match c {

+ 22 - 14
data-url/tests/wpt.rs

@@ -1,3 +1,5 @@
+use tester as test;
+
 #[macro_use]
 extern crate serde;
 
@@ -32,7 +34,7 @@ fn run_data_url(
 
 fn collect_data_url<F>(add_test: &mut F)
 where
-    F: FnMut(String, bool, rustc_test::TestFn),
+    F: FnMut(String, bool, test::TestFn),
 {
     let known_failures = ["data://test:test/,X"];
 
@@ -53,9 +55,9 @@ where
         add_test(
             format!("data: URL {:?}", input),
             should_panic,
-            rustc_test::TestFn::dyn_test_fn(move || {
+            test::TestFn::DynTestFn(Box::new(move || {
                 run_data_url(input, expected_mime, expected_body, should_panic)
-            }),
+            })),
         );
     }
 }
@@ -72,7 +74,7 @@ fn run_base64(input: String, expected: Option<Vec<u8>>) {
 
 fn collect_base64<F>(add_test: &mut F)
 where
-    F: FnMut(String, bool, rustc_test::TestFn),
+    F: FnMut(String, bool, test::TestFn),
 {
     let known_failures = [];
 
@@ -83,7 +85,7 @@ where
         add_test(
             format!("base64 {:?}", input),
             should_panic,
-            rustc_test::TestFn::dyn_test_fn(move || run_base64(input, expected)),
+            test::TestFn::DynTestFn(Box::new(move || run_base64(input, expected))),
         );
     }
 }
@@ -100,7 +102,7 @@ fn run_mime(input: String, expected: Option<String>) {
 
 fn collect_mime<F>(add_test: &mut F)
 where
-    F: FnMut(String, bool, rustc_test::TestFn),
+    F: FnMut(String, bool, test::TestFn),
 {
     let known_failures = [];
 
@@ -136,7 +138,7 @@ where
                 format!("MIME type {:?}", input)
             },
             should_panic,
-            rustc_test::TestFn::dyn_test_fn(move || run_mime(input, expected)),
+            test::TestFn::DynTestFn(Box::new(move || run_mime(input, expected))),
         );
     }
 }
@@ -144,16 +146,22 @@ where
 fn main() {
     let mut tests = Vec::new();
     {
-        let mut add_one = |name: String, should_panic: bool, run: rustc_test::TestFn| {
-            let mut desc = rustc_test::TestDesc::new(rustc_test::DynTestName(name));
-            if should_panic {
-                desc.should_panic = rustc_test::ShouldPanic::Yes
-            }
-            tests.push(rustc_test::TestDescAndFn { desc, testfn: run })
+        let mut add_one = |name: String, should_panic: bool, run: test::TestFn| {
+            let desc = test::TestDesc {
+                name: test::DynTestName(name),
+                ignore: false,
+                should_panic: match should_panic {
+                    true => test::ShouldPanic::Yes,
+                    false => test::ShouldPanic::No,
+                },
+                allow_fail: false,
+                test_type: test::TestType::Unknown,
+            };
+            tests.push(test::TestDescAndFn { desc, testfn: run })
         };
         collect_data_url(&mut add_one);
         collect_base64(&mut add_one);
         collect_mime(&mut add_one);
     }
-    rustc_test::test_main(&std::env::args().collect::<Vec<_>>(), tests)
+    test::test_main(&std::env::args().collect::<Vec<_>>(), tests, None)
 }

+ 1 - 0
form_urlencoded/Cargo.toml

@@ -6,6 +6,7 @@ description = "Parser and serializer for the application/x-www-form-urlencoded s
 repository = "https://github.com/servo/rust-url"
 license = "MIT/Apache-2.0"
 edition = "2018"
+rust-version = "1.45"
 
 [lib]
 test = false

+ 2 - 1
idna/Cargo.toml

@@ -7,6 +7,7 @@ repository = "https://github.com/servo/rust-url/"
 license = "MIT/Apache-2.0"
 autotests = false
 edition = "2018"
+rust-version = "1.45"
 
 [lib]
 doctest = false
@@ -21,7 +22,7 @@ name = "unit"
 [dev-dependencies]
 assert_matches = "1.3"
 bencher = "0.1"
-rustc-test = "0.3"
+tester = "0.9"
 serde_json = "1.0"
 
 [dependencies]

+ 2 - 3
idna/src/uts46.rs

@@ -319,7 +319,6 @@ fn check_validity(label: &str, config: Config, errors: &mut Errors) {
 }
 
 /// http://www.unicode.org/reports/tr46/#Processing
-#[allow(clippy::manual_strip)] // introduced in 1.45, MSRV is 1.36
 fn processing(
     domain: &str,
     config: Config,
@@ -384,8 +383,8 @@ fn processing(
             output.push('.');
         }
         first = false;
-        if label.starts_with(PUNYCODE_PREFIX) {
-            match decoder.decode(&label[PUNYCODE_PREFIX.len()..]) {
+        if let Some(remainder) = label.strip_prefix(PUNYCODE_PREFIX) {
+            match decoder.decode(remainder) {
                 Ok(decode) => {
                     let start = output.len();
                     output.extend(decode);

+ 2 - 2
idna/tests/punycode.rs

@@ -63,9 +63,9 @@ pub fn collect_tests<F: FnMut(String, TestFn)>(add_test: &mut F) {
                         };
                         add_test(
                             test_name,
-                            TestFn::dyn_test_fn(move || {
+                            TestFn::DynTestFn(Box::new(move || {
                                 one_test(get_string(&o, "decoded"), get_string(&o, "encoded"))
-                            }),
+                            })),
                         )
                     }
                     _ => panic!(),

+ 9 - 3
idna/tests/tests.rs

@@ -1,4 +1,4 @@
-use rustc_test as test;
+use tester as test;
 
 mod punycode;
 mod uts46;
@@ -8,12 +8,18 @@ fn main() {
     {
         let mut add_test = |name, run| {
             tests.push(test::TestDescAndFn {
-                desc: test::TestDesc::new(test::DynTestName(name)),
+                desc: test::TestDesc {
+                    name: test::DynTestName(name),
+                    ignore: false,
+                    should_panic: test::ShouldPanic::No,
+                    allow_fail: false,
+                    test_type: test::TestType::Unknown,
+                },
                 testfn: run,
             })
         };
         punycode::collect_tests(&mut add_test);
         uts46::collect_tests(&mut add_test);
     }
-    test::test_main(&std::env::args().collect::<Vec<_>>(), tests)
+    test::test_main(&std::env::args().collect::<Vec<_>>(), tests, None)
 }

+ 2 - 2
idna/tests/uts46.rs

@@ -65,7 +65,7 @@ pub fn collect_tests<F: FnMut(String, TestFn)>(add_test: &mut F) {
         let test_name = format!("UTS #46 line {}", i + 1);
         add_test(
             test_name,
-            TestFn::dyn_test_fn(move || {
+            TestFn::DynTestFn(Box::new(move || {
                 let config = idna::Config::default()
                     .use_std3_ascii_rules(true)
                     .verify_dns_length(true)
@@ -109,7 +109,7 @@ pub fn collect_tests<F: FnMut(String, TestFn)>(add_test: &mut F) {
                     to_ascii_t_result,
                     |e| e.starts_with('C') || e == "V2",
                 );
-            }),
+            })),
         )
     }
 }

+ 1 - 0
percent_encoding/Cargo.toml

@@ -6,6 +6,7 @@ description = "Percent encoding and decoding"
 repository = "https://github.com/servo/rust-url/"
 license = "MIT/Apache-2.0"
 edition = "2018"
+rust-version = "1.45"
 
 [features]
 default = ["alloc"]

+ 1 - 0
url/Cargo.toml

@@ -14,6 +14,7 @@ categories = ["parser-implementations", "web-programming", "encoding"]
 license = "MIT/Apache-2.0"
 include = ["src/**/*", "LICENSE-*", "README.md", "tests/**"]
 edition = "2018"
+rust-version = "1.45"
 
 [badges]
 travis-ci = { repository = "servo/rust-url" }

+ 2 - 8
url/src/lib.rs

@@ -1244,14 +1244,9 @@ impl Url {
     /// # }
     /// # run().unwrap();
     /// ```
-    #[allow(clippy::manual_strip)] // introduced in 1.45, MSRV is 1.36
     pub fn path_segments(&self) -> Option<str::Split<'_, char>> {
         let path = self.path();
-        if path.starts_with('/') {
-            Some(path[1..].split('/'))
-        } else {
-            None
-        }
+        path.strip_prefix('/').map(|remainder| remainder.split('/'))
     }
 
     /// Return this URL’s query string, if any, as a percent-encoded ASCII string.
@@ -1361,8 +1356,7 @@ impl Url {
     }
 
     fn mutate<F: FnOnce(&mut Parser<'_>) -> R, R>(&mut self, f: F) -> R {
-        #[allow(clippy::mem_replace_with_default)] // introduced in 1.40, MSRV is 1.36
-        let mut parser = Parser::for_setter(mem::replace(&mut self.serialization, String::new()));
+        let mut parser = Parser::for_setter(mem::take(&mut self.serialization));
         let result = f(&mut parser);
         self.serialization = parser.serialization;
         result

+ 2 - 14
url/src/parser.rs

@@ -52,15 +52,12 @@ macro_rules! simple_enum_error {
         ///
         /// This may be extended in the future so exhaustive matching is
         /// discouraged with an unused variant.
-        #[allow(clippy::manual_non_exhaustive)] // introduced in 1.40, MSRV is 1.36
         #[derive(PartialEq, Eq, Clone, Copy, Debug)]
+        #[non_exhaustive]
         pub enum ParseError {
             $(
                 $name,
             )+
-            /// Unused variant enable non-exhaustive matching
-            #[doc(hidden)]
-            __FutureProof,
         }
 
         impl fmt::Display for ParseError {
@@ -69,9 +66,6 @@ macro_rules! simple_enum_error {
                     $(
                         ParseError::$name => fmt.write_str($description),
                     )+
-                    ParseError::__FutureProof => {
-                        unreachable!("Don't abuse the FutureProof!");
-                    }
                 }
             }
         }
@@ -106,15 +100,12 @@ macro_rules! syntax_violation_enum {
         ///
         /// This may be extended in the future so exhaustive matching is
         /// discouraged with an unused variant.
-        #[allow(clippy::manual_non_exhaustive)] // introduced in 1.40, MSRV is 1.36
         #[derive(PartialEq, Eq, Clone, Copy, Debug)]
+        #[non_exhaustive]
         pub enum SyntaxViolation {
             $(
                 $name,
             )+
-            /// Unused variant enable non-exhaustive matching
-            #[doc(hidden)]
-            __FutureProof,
         }
 
         impl SyntaxViolation {
@@ -123,9 +114,6 @@ macro_rules! syntax_violation_enum {
                     $(
                         SyntaxViolation::$name => $description,
                     )+
-                    SyntaxViolation::__FutureProof => {
-                        unreachable!("Don't abuse the FutureProof!");
-                    }
                 }
             }
         }

+ 1 - 3
url/tests/data.rs

@@ -8,7 +8,6 @@
 
 //! Data-driven tests
 
-use std::ops::Deref;
 use std::str::FromStr;
 
 use serde_json::Value;
@@ -120,7 +119,6 @@ fn urltestdata() {
     assert!(passed)
 }
 
-#[allow(clippy::option_as_ref_deref)] // introduced in 1.40, MSRV is 1.36
 #[test]
 fn setters_tests() {
     let mut json = Value::from_str(include_str!("setters_tests.json"))
@@ -149,7 +147,7 @@ fn setters_tests() {
             let mut expected = test.take_key("expected").unwrap();
 
             let mut url = Url::parse(&href).unwrap();
-            let comment_ref = comment.as_ref().map(|s| s.deref());
+            let comment_ref = comment.as_deref();
             passed &= check_invariants(&url, &name, comment_ref);
             let _ = set(&mut url, attr, &new_value);