Skip to content

Commit c8d8e6d

Browse files
committed
Cleanup Errors in tests
1 parent d43506b commit c8d8e6d

File tree

5 files changed

+50
-122
lines changed

5 files changed

+50
-122
lines changed

idna/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ name = "unit"
2929
assert_matches = "1.3"
3030
bencher = "0.1"
3131
tester = "0.9"
32-
serde_json = { version = "1.0" }
32+
serde_json = "1.0"
3333

3434
[dependencies]
3535
unicode-bidi = { version = "0.3.10", default-features = false, features = ["hardcoded-data"] }

idna/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
//! > that minimizes the impact of this transition for client software,
3333
//! > allowing client software to access domains that are valid under either system.
3434
#![no_std]
35+
3536
// For forwards compatibility
3637
#[cfg(feature = "std")]
3738
extern crate std;

url/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ wasm-bindgen-test = "0.3"
2828
form_urlencoded = { version = "1.2.1", path = "../form_urlencoded", default-features = false, features = ["alloc"] }
2929
idna = { version = "0.5.0", path = "../idna", default-features = false, features = ["alloc"] }
3030
percent-encoding = { version = "2.3.1", path = "../percent_encoding", default-features = false, features = ["alloc"] }
31-
serde = {version = "1.0", optional = true, features = ["derive"]}
31+
serde = { version = "1.0", optional = true, features = ["derive"] }
3232

3333
[features]
3434
default = ["std"]

url/src/lib.rs

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,22 +1384,12 @@ impl Url {
13841384
/// ```
13851385
/// use url::Url;
13861386
///
1387-
/// # use url::ParseError;
1388-
/// # #[derive(Debug)]
1389-
/// # /// A simple wrapper error struct for `no_std` support
1390-
/// # struct TestError;
1391-
/// # impl From<ParseError> for TestError {
1392-
/// # fn from(value: ParseError) -> Self {
1393-
/// # TestError {}
1394-
/// # }
1395-
/// # }
1396-
/// # impl From<&str> for TestError {
1397-
/// # fn from(value: &str) -> Self {
1398-
/// # TestError {}
1399-
/// # }
1400-
/// # }
1387+
/// # #[cfg(feature = "std")]
1388+
/// # use std::error::Error;
1389+
/// # #[cfg(not(feature = "std"))]
1390+
/// # use core::error::Error;
14011391
///
1402-
/// # fn run() -> Result<(), TestError> {
1392+
/// # fn run() -> Result<(), Box<dyn Error>> {
14031393
/// let url = Url::parse("https://example.com/foo/bar")?;
14041394
/// let mut path_segments = url.path_segments().ok_or_else(|| "cannot be base")?;
14051395
/// assert_eq!(path_segments.next(), Some("foo"));
@@ -1811,22 +1801,13 @@ impl Url {
18111801
///
18121802
/// ```
18131803
/// use url::Url;
1814-
/// # use url::ParseError;
1815-
/// # #[derive(Debug)]
1816-
/// # /// A simple wrapper error struct for `no_std` support
1817-
/// # struct TestError;
1818-
/// # impl From<ParseError> for TestError {
1819-
/// # fn from(value: ParseError) -> Self {
1820-
/// # TestError {}
1821-
/// # }
1822-
/// # }
1823-
/// # impl From<&str> for TestError {
1824-
/// # fn from(value: &str) -> Self {
1825-
/// # TestError {}
1826-
/// # }
1827-
/// # }
18281804
///
1829-
/// # fn run() -> Result<(), TestError> {
1805+
/// # #[cfg(feature = "std")]
1806+
/// # use std::error::Error;
1807+
/// # #[cfg(not(feature = "std"))]
1808+
/// # use core::error::Error;
1809+
///
1810+
/// # fn run() -> Result<(), Box<dyn Error>> {
18301811
/// let mut url = Url::parse("ssh://example.net:2048/")?;
18311812
///
18321813
/// url.set_port(Some(4096)).map_err(|_| "cannot be base")?;
@@ -1843,22 +1824,13 @@ impl Url {
18431824
///
18441825
/// ```rust
18451826
/// use url::Url;
1846-
/// # use url::ParseError;
1847-
/// # #[derive(Debug)]
1848-
/// # /// A simple wrapper error struct for `no_std` support
1849-
/// # struct TestError;
1850-
/// # impl From<ParseError> for TestError {
1851-
/// # fn from(value: ParseError) -> Self {
1852-
/// # TestError {}
1853-
/// # }
1854-
/// # }
1855-
/// # impl From<&str> for TestError {
1856-
/// # fn from(value: &str) -> Self {
1857-
/// # TestError {}
1858-
/// # }
1859-
/// # }
18601827
///
1861-
/// # fn run() -> Result<(), TestError> {
1828+
/// # #[cfg(feature = "std")]
1829+
/// # use std::error::Error;
1830+
/// # #[cfg(not(feature = "std"))]
1831+
/// # use core::error::Error;
1832+
///
1833+
/// # fn run() -> Result<(), Box<dyn Error>> {
18621834
/// let mut url = Url::parse("https://example.org/")?;
18631835
///
18641836
/// url.set_port(Some(443)).map_err(|_| "cannot be base")?;

url/src/path_segments.rs

Lines changed: 30 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,13 @@ use core::str;
2020
///
2121
/// ```rust
2222
/// use url::Url;
23-
/// # use url::ParseError;
24-
/// # #[derive(Debug)]
25-
/// # /// A simple wrapper error struct for `no_std` support
26-
/// # struct TestError;
27-
/// # impl From<ParseError> for TestError {
28-
/// # fn from(value: ParseError) -> Self {
29-
/// # TestError {}
30-
/// # }
31-
/// # }
32-
/// # impl From<&str> for TestError {
33-
/// # fn from(value: &str) -> Self {
34-
/// # TestError {}
35-
/// # }
36-
/// # }
3723
///
38-
/// # fn run() -> Result<(), TestError> {
24+
/// # #[cfg(feature = "std")]
25+
/// # use std::error::Error;
26+
/// # #[cfg(not(feature = "std"))]
27+
/// # use core::error::Error;
28+
///
29+
/// # fn run() -> Result<(), Box<dyn Error>> {
3930
/// let mut url = Url::parse("mailto:me@example.com")?;
4031
/// assert!(url.path_segments_mut().is_err());
4132
///
@@ -92,22 +83,13 @@ impl<'a> PathSegmentsMut<'a> {
9283
///
9384
/// ```rust
9485
/// use url::Url;
95-
/// # use url::ParseError;
96-
/// # #[derive(Debug)]
97-
/// # /// A simple wrapper error struct for `no_std` support
98-
/// # struct TestError;
99-
/// # impl From<ParseError> for TestError {
100-
/// # fn from(value: ParseError) -> Self {
101-
/// # TestError {}
102-
/// # }
103-
/// # }
104-
/// # impl From<&str> for TestError {
105-
/// # fn from(value: &str) -> Self {
106-
/// # TestError {}
107-
/// # }
108-
/// # }
10986
///
110-
/// # fn run() -> Result<(), TestError> {
87+
/// # #[cfg(feature = "std")]
88+
/// # use std::error::Error;
89+
/// # #[cfg(not(feature = "std"))]
90+
/// # use core::error::Error;
91+
///
92+
/// # fn run() -> Result<(), Box<dyn Error>> {
11193
/// let mut url = Url::parse("https://github.com/servo/rust-url/")?;
11294
/// url.path_segments_mut().map_err(|_| "cannot be base")?
11395
/// .clear().push("logout");
@@ -133,22 +115,13 @@ impl<'a> PathSegmentsMut<'a> {
133115
///
134116
/// ```rust
135117
/// use url::Url;
136-
/// # use url::ParseError;
137-
/// # #[derive(Debug)]
138-
/// # /// A simple wrapper error struct for `no_std` support
139-
/// # struct TestError;
140-
/// # impl From<ParseError> for TestError {
141-
/// # fn from(value: ParseError) -> Self {
142-
/// # TestError {}
143-
/// # }
144-
/// # }
145-
/// # impl From<&str> for TestError {
146-
/// # fn from(value: &str) -> Self {
147-
/// # TestError {}
148-
/// # }
149-
/// # }
150118
///
151-
/// # fn run() -> Result<(), TestError> {
119+
/// # #[cfg(feature = "std")]
120+
/// # use std::error::Error;
121+
/// # #[cfg(not(feature = "std"))]
122+
/// # use core::error::Error;
123+
///
124+
/// # fn run() -> Result<(), Box<dyn Error>> {
152125
/// let mut url = Url::parse("https://github.com/servo/rust-url/")?;
153126
/// url.path_segments_mut().map_err(|_| "cannot be base")?
154127
/// .push("pulls");
@@ -221,22 +194,13 @@ impl<'a> PathSegmentsMut<'a> {
221194
///
222195
/// ```rust
223196
/// use url::Url;
224-
/// # use url::ParseError;
225-
/// # #[derive(Debug)]
226-
/// # /// A simple wrapper error struct for `no_std` support
227-
/// # struct TestError;
228-
/// # impl From<ParseError> for TestError {
229-
/// # fn from(value: ParseError) -> Self {
230-
/// # TestError {}
231-
/// # }
232-
/// # }
233-
/// # impl From<&str> for TestError {
234-
/// # fn from(value: &str) -> Self {
235-
/// # TestError {}
236-
/// # }
237-
/// # }
238197
///
239-
/// # fn run() -> Result<(), TestError> {
198+
/// # #[cfg(feature = "std")]
199+
/// # use std::error::Error;
200+
/// # #[cfg(not(feature = "std"))]
201+
/// # use core::error::Error;
202+
///
203+
/// # fn run() -> Result<(), Box<dyn Error>> {
240204
/// let mut url = Url::parse("https://github.com/")?;
241205
/// let org = "servo";
242206
/// let repo = "rust-url";
@@ -254,22 +218,13 @@ impl<'a> PathSegmentsMut<'a> {
254218
///
255219
/// ```rust
256220
/// use url::Url;
257-
/// # use url::ParseError;
258-
/// # #[derive(Debug)]
259-
/// # /// A simple wrapper error struct for `no_std` support
260-
/// # struct TestError;
261-
/// # impl From<ParseError> for TestError {
262-
/// # fn from(value: ParseError) -> Self {
263-
/// # TestError {}
264-
/// # }
265-
/// # }
266-
/// # impl From<&str> for TestError {
267-
/// # fn from(value: &str) -> Self {
268-
/// # TestError {}
269-
/// # }
270-
/// # }
271221
///
272-
/// # fn run() -> Result<(), TestError> {
222+
/// # #[cfg(feature = "std")]
223+
/// # use std::error::Error;
224+
/// # #[cfg(not(feature = "std"))]
225+
/// # use core::error::Error;
226+
///
227+
/// # fn run() -> Result<(), Box<dyn Error>> {
273228
/// let mut url = Url::parse("https://github.com/servo")?;
274229
/// url.path_segments_mut().map_err(|_| "cannot be base")?
275230
/// .extend(&["..", "rust-url", ".", "pulls"]);

0 commit comments

Comments
 (0)