Skip to content

Commit e398b2c

Browse files
committed
Appease clippy
This commit appeases clippy by fixing all of the issues it flagged.
1 parent 9f438e8 commit e398b2c

File tree

7 files changed

+11
-17
lines changed

7 files changed

+11
-17
lines changed

idna/src/uts46.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ fn passes_bidi(label: &str, is_bidi_domain: bool) -> bool {
156156
// LTR label
157157
BidiClass::L => {
158158
// Rule 5
159-
while let Some(c) = chars.next() {
159+
for c in chars.by_ref() {
160160
if !matches!(
161161
bidi_class(c),
162162
BidiClass::L
@@ -396,7 +396,7 @@ fn processing(
396396
}
397397

398398
if !errors.is_err() {
399-
if !is_nfc(&decoded_label) {
399+
if !is_nfc(decoded_label) {
400400
errors.nfc = true;
401401
} else {
402402
check_validity(decoded_label, non_transitional, &mut errors);

idna/tests/uts46.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ pub fn collect_tests<F: FnMut(String, TestFn)>(add_test: &mut F) {
2525
};
2626

2727
let mut pieces = line.split(';').map(|x| x.trim()).collect::<Vec<&str>>();
28-
let source = unescape(&pieces.remove(0));
28+
let source = unescape(pieces.remove(0));
2929

3030
// ToUnicode
31-
let mut to_unicode = unescape(&pieces.remove(0));
31+
let mut to_unicode = unescape(pieces.remove(0));
3232
if to_unicode.is_empty() {
3333
to_unicode = source.clone();
3434
}

url/src/host.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl Host<String> {
162162
/// convert domain with idna
163163
#[cfg(feature = "idna")]
164164
fn domain_to_ascii(domain: &str) -> Result<String, ParseError> {
165-
idna::domain_to_ascii(&domain).map_err(Into::into)
165+
idna::domain_to_ascii(domain).map_err(Into::into)
166166
}
167167

168168
/// checks domain is ascii

url/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ impl Url {
13611361
}
13621362

13631363
fn mutate<F: FnOnce(&mut Parser<'_>) -> R, R>(&mut self, f: F) -> R {
1364-
let mut parser = Parser::for_setter(mem::replace(&mut self.serialization, String::new()));
1364+
let mut parser = Parser::for_setter(mem::take(&mut self.serialization));
13651365
let result = f(&mut parser);
13661366
self.serialization = parser.serialization;
13671367
result

url/src/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,7 @@ impl<'a> Parser<'a> {
12931293
//FIXME: log violation
12941294
let path = self.serialization.split_off(path_start);
12951295
self.serialization.push('/');
1296-
self.serialization.push_str(&path.trim_start_matches('/'));
1296+
self.serialization.push_str(path.trim_start_matches('/'));
12971297
}
12981298

12991299
input

url/src/quirks.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,8 @@ pub fn set_host(url: &mut Url, new_host: &str) -> Result<(), ()> {
139139
}
140140
}
141141
// Make sure we won't set an empty host to a url with a username or a port
142-
if host == Host::Domain("".to_string()) {
143-
if !username(&url).is_empty() {
142+
if host == Host::Domain("".to_string()) && (!username(url).is_empty() || matches!(opt_port, Some(Some(_))) || url.port().is_some()) {
144143
return Err(());
145-
} else if let Some(Some(_)) = opt_port {
146-
return Err(());
147-
} else if url.port().is_some() {
148-
return Err(());
149-
}
150144
}
151145
url.set_host_internal(host, opt_port);
152146
Ok(())
@@ -178,10 +172,10 @@ pub fn set_hostname(url: &mut Url, new_hostname: &str) -> Result<(), ()> {
178172
// Empty host on special not file url
179173
if SchemeType::from(url.scheme()) == SchemeType::SpecialNotFile
180174
// Port with an empty host
181-
||!port(&url).is_empty()
175+
||!port(url).is_empty()
182176
// Empty host that includes credentials
183177
|| !url.username().is_empty()
184-
|| !url.password().unwrap_or(&"").is_empty()
178+
|| !url.password().unwrap_or("").is_empty()
185179
{
186180
return Err(());
187181
}

url/tests/unit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ fn test_make_relative() {
10961096
base, uri, relative
10971097
);
10981098
assert_eq!(
1099-
base_uri.join(&relative).unwrap().as_str(),
1099+
base_uri.join(relative).unwrap().as_str(),
11001100
*uri,
11011101
"base: {}, uri: {}, relative: {}",
11021102
base,

0 commit comments

Comments
 (0)