Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
matrix.rust == '1.63.0'
run: |
cargo update -p idna_adapter --precise 1.1.0
cargo update -p getopts --precise 0.2.22
cargo update -p unicode-width --precise 0.1.12
- name: Add `aarch64-unknown-none` toolchain for `no_std` tests
if: |
matrix.os == 'ubuntu-latest' &&
Expand Down
10 changes: 5 additions & 5 deletions url/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1909,7 +1909,7 @@ impl Url {
(_, Some(new)) => {
let path_and_after = self.slice(self.path_start..).to_owned();
self.serialization.truncate(self.host_end as usize);
write!(&mut self.serialization, ":{}", new).unwrap();
write!(&mut self.serialization, ":{new}").unwrap();
let old_path_start = self.path_start;
let new_path_start = to_u32(self.serialization.len()).unwrap();
self.path_start = new_path_start;
Expand Down Expand Up @@ -2092,14 +2092,14 @@ impl Url {
self.username_end += 2;
self.host_start += 2;
}
write!(&mut self.serialization, "{}", host).unwrap();
write!(&mut self.serialization, "{host}").unwrap();
self.host_end = to_u32(self.serialization.len()).unwrap();
self.host = host.into();

if let Some(new_port) = opt_new_port {
self.port = new_port;
if let Some(port) = new_port {
write!(&mut self.serialization, ":{}", port).unwrap();
write!(&mut self.serialization, ":{port}").unwrap();
}
}
let new_suffix_pos = to_u32(self.serialization.len()).unwrap();
Expand Down Expand Up @@ -2926,7 +2926,7 @@ impl<'de> serde::Deserialize<'de> for Url {
where
E: Error,
{
Url::parse(s).map_err(|err| Error::custom(format!("{}: {:?}", err, s)))
Url::parse(s).map_err(|err| Error::custom(format!("{err}: {s:?}")))
}
}

Expand Down Expand Up @@ -3013,7 +3013,7 @@ fn path_to_file_url_segments_windows(
}
Prefix::UNC(server, share) | Prefix::VerbatimUNC(server, share) => {
let host = Host::parse_cow(server.to_str().ok_or(())?.into()).map_err(|_| ())?;
write!(serialization, "{}", host).unwrap();
write!(serialization, "{host}").unwrap();
host_end = to_u32(serialization.len()).unwrap();
host_internal = host.into();
serialization.push('/');
Expand Down
8 changes: 4 additions & 4 deletions url/src/origin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ impl Origin {
Self::Opaque(_) => "null".to_owned(),
Self::Tuple(ref scheme, ref host, port) => {
if default_port(scheme) == Some(port) {
format!("{}://{}", scheme, host)
format!("{scheme}://{host}")
} else {
format!("{}://{}:{}", scheme, host, port)
format!("{scheme}://{host}:{port}")
}
}
}
Expand All @@ -101,9 +101,9 @@ impl Origin {
_ => host.clone(),
};
if default_port(scheme) == Some(port) {
format!("{}://{}", scheme, host)
format!("{scheme}://{host}")
} else {
format!("{}://{}:{}", scheme, host, port)
format!("{scheme}://{host}:{port}")
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions url/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ impl Parser<'_> {
scheme_type: SchemeType,
) -> ParseResult<(u32, HostInternal, Option<u16>, Input<'i>)> {
let (host, remaining) = Parser::parse_host(input, scheme_type)?;
write!(&mut self.serialization, "{}", host).unwrap();
write!(&mut self.serialization, "{host}").unwrap();
let host_end = to_u32(self.serialization.len())?;
if let Host::Domain(h) = &host {
if h.is_empty() {
Expand Down Expand Up @@ -1070,7 +1070,7 @@ impl Parser<'_> {
HostInternal::None
}
host => {
write!(&mut self.serialization, "{}", host).unwrap();
write!(&mut self.serialization, "{host}").unwrap();
has_host = true;
host.into()
}
Expand Down
10 changes: 3 additions & 7 deletions url/tests/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1247,16 +1247,12 @@ fn test_make_relative() {
let make_relative = base_uri.make_relative(&relative_uri).unwrap();
assert_eq!(
make_relative, *relative,
"base: {}, uri: {}, relative: {}",
base, uri, relative
"base: {base}, uri: {uri}, relative: {relative}"
);
assert_eq!(
base_uri.join(relative).unwrap().as_str(),
*uri,
"base: {}, uri: {}, relative: {}",
base,
uri,
relative
"base: {base}, uri: {uri}, relative: {relative}"
);
}

Expand All @@ -1271,7 +1267,7 @@ fn test_make_relative() {
let base_uri = url::Url::parse(base).unwrap();
let relative_uri = url::Url::parse(uri).unwrap();
let make_relative = base_uri.make_relative(&relative_uri);
assert_eq!(make_relative, None, "base: {}, uri: {}", base, uri);
assert_eq!(make_relative, None, "base: {base}, uri: {uri}");
}
}

Expand Down
59 changes: 20 additions & 39 deletions url/tests/wpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ fn main() {
if should_skip(&name, filter.as_deref()) {
continue;
}
print!("{} ... ", name);
print!("{name} ... ");

let res = run_url_test(url_test);
report(name, res, &mut errors, &mut expected_failures);
Expand All @@ -189,7 +189,7 @@ fn main() {
continue;
}

print!("{} ... ", name);
print!("{name} ... ");

let res = run_setter_test(&kind, test);
report(name, res, &mut errors, &mut expected_failures);
Expand All @@ -205,8 +205,8 @@ fn main() {
println!();

for (name, err) in errors {
println!(" name: {}", name);
println!(" err: {}", err);
println!(" name: {name}");
println!(" err: {err}");
println!();
}

Expand All @@ -223,7 +223,7 @@ fn main() {
println!();

for name in expected_failures {
println!(" {}", name);
println!(" {name}");
}

println!();
Expand Down Expand Up @@ -278,8 +278,7 @@ fn run_url_test(
) -> Result<(), String> {
let base = match base {
Some(base) => {
let base =
Url::parse(&base).map_err(|e| format!("errored while parsing base: {}", e))?;
let base = Url::parse(&base).map_err(|e| format!("errored while parsing base: {e}"))?;
Some(base)
}
None => None,
Expand All @@ -288,7 +287,7 @@ fn run_url_test(
let res = Url::options()
.base_url(base.as_ref())
.parse(&input)
.map_err(|e| format!("errored while parsing input: {}", e));
.map_err(|e| format!("errored while parsing input: {e}"));

match result {
UrlTestResult::Ok(ok) => check_url_ok(res, ok),
Expand All @@ -307,7 +306,7 @@ fn check_url_ok(res: Result<Url, String>, ok: UrlTestOk) -> Result<(), String> {
let url = match res {
Ok(url) => url,
Err(err) => {
return Err(format!("expected success, but errored: {:?}", err));
return Err(format!("expected success, but errored: {err:?}"));
}
};

Expand Down Expand Up @@ -390,7 +389,7 @@ fn run_setter_test(
expected,
}: SetterTest,
) -> Result<(), String> {
let mut url = Url::parse(&href).map_err(|e| format!("errored while parsing href: {}", e))?;
let mut url = Url::parse(&href).map_err(|e| format!("errored while parsing href: {e}"))?;

match kind {
"protocol" => {
Expand All @@ -415,26 +414,22 @@ fn run_setter_test(
"search" => url::quirks::set_search(&mut url, &new_value),
"hash" => url::quirks::set_hash(&mut url, &new_value),
_ => {
return Err(format!("unknown setter kind: {:?}", kind));
return Err(format!("unknown setter kind: {kind:?}"));
}
}

if let Some(expected_href) = expected.href {
let href = url::quirks::href(&url);
if href != expected_href {
return Err(format!(
"expected href {:?}, but got {:?}",
expected_href, href
));
return Err(format!("expected href {expected_href:?}, but got {href:?}"));
}
}

if let Some(expected_protocol) = expected.protocol {
let protocol = url::quirks::protocol(&url);
if protocol != expected_protocol {
return Err(format!(
"expected protocol {:?}, but got {:?}",
expected_protocol, protocol
"expected protocol {expected_protocol:?}, but got {protocol:?}"
));
}
}
Expand All @@ -443,8 +438,7 @@ fn run_setter_test(
let username = url::quirks::username(&url);
if username != expected_username {
return Err(format!(
"expected username {:?}, but got {:?}",
expected_username, username
"expected username {expected_username:?}, but got {username:?}"
));
}
}
Expand All @@ -453,48 +447,39 @@ fn run_setter_test(
let password = url::quirks::password(&url);
if password != expected_password {
return Err(format!(
"expected password {:?}, but got {:?}",
expected_password, password
"expected password {expected_password:?}, but got {password:?}"
));
}
}

if let Some(expected_host) = expected.host {
let host = url::quirks::host(&url);
if host != expected_host {
return Err(format!(
"expected host {:?}, but got {:?}",
expected_host, host
));
return Err(format!("expected host {expected_host:?}, but got {host:?}"));
}
}

if let Some(expected_hostname) = expected.hostname {
let hostname = url::quirks::hostname(&url);
if hostname != expected_hostname {
return Err(format!(
"expected hostname {:?}, but got {:?}",
expected_hostname, hostname
"expected hostname {expected_hostname:?}, but got {hostname:?}"
));
}
}

if let Some(expected_port) = expected.port {
let port = url::quirks::port(&url);
if port != expected_port {
return Err(format!(
"expected port {:?}, but got {:?}",
expected_port, port
));
return Err(format!("expected port {expected_port:?}, but got {port:?}"));
}
}

if let Some(expected_pathname) = expected.pathname {
let pathname = url::quirks::pathname(&url);
if pathname != expected_pathname {
return Err(format!(
"expected pathname {:?}, but got {:?}",
expected_pathname, pathname
"expected pathname {expected_pathname:?}, but got {pathname:?}"
));
}
}
Expand All @@ -503,19 +488,15 @@ fn run_setter_test(
let search = url::quirks::search(&url);
if search != expected_search {
return Err(format!(
"expected search {:?}, but got {:?}",
expected_search, search
"expected search {expected_search:?}, but got {search:?}"
));
}
}

if let Some(expected_hash) = expected.hash {
let hash = url::quirks::hash(&url);
if hash != expected_hash {
return Err(format!(
"expected hash {:?}, but got {:?}",
expected_hash, hash
));
return Err(format!("expected hash {expected_hash:?}, but got {hash:?}"));
}
}

Expand Down
Loading