432: Clippy lints in 1.48 r=koivunej a=koivunej

Minor fixes.

Co-authored-by: Joonas Koivunen <joonas.koivunen@gmail.com>
This commit is contained in:
bors[bot] 2020-12-08 14:45:57 +00:00 committed by GitHub
commit d3a3c6921e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 11 deletions

View File

@ -136,7 +136,7 @@ fn parse_format(s: &str) -> Result<Vec<FormattedPart>, FormatError> {
let remaining = chars.as_str();
let end = remaining
.find('>')
.ok_or_else(|| FormatError::UnterminatedTag(index))?;
.ok_or(FormatError::UnterminatedTag(index))?;
// the use of string indices here is ok as the angle brackets are ascii and
// cannot be in the middle of multibyte char boundaries

View File

@ -129,13 +129,13 @@ where
.decode_utf8()
.map_err(AddError::InvalidFilename)?;
let filename = if filename.starts_with('/') {
let filename = if let Some(relative) = filename.strip_prefix('/') {
// normalize single first slash; seems similar to what js-ipfs does: filesystem
// test cases post with paths '/some-directory/...' and others post with
// 'some-directory/...'.
// since slash is a single code point, we can just do
filename[1..].to_owned()
relative.to_owned()
} else {
filename.into_owned()
};

View File

@ -44,8 +44,8 @@ impl Future for DnsLinkFuture {
let txt = record?;
let bytes: &[u8] = txt.data().as_flat_slice().unwrap_or(b"");
let string = String::from_utf8_lossy(&bytes).to_string();
if string.starts_with("dnslink=") {
let path = IpfsPath::from_str(&string[8..])?;
if let Some(path) = string.strip_prefix("dnslink=") {
let path = IpfsPath::from_str(path)?;
return Poll::Ready(Ok(path));
}
}

View File

@ -919,7 +919,7 @@ impl<Types: IpfsTypes> Ipfs<Types> {
.await?;
match rx.await? {
Either::Left(addrs) if !addrs.is_empty() => return Ok(addrs),
Either::Left(addrs) if !addrs.is_empty() => Ok(addrs),
Either::Left(_) => unreachable!(),
Either::Right(future) => {
future.await?;
@ -932,8 +932,8 @@ impl<Types: IpfsTypes> Ipfs<Types> {
.await?;
match rx.await? {
Either::Left(addrs) if !addrs.is_empty() => return Ok(addrs),
_ => return Err(anyhow!("couldn't find peer {}", peer_id)),
Either::Left(addrs) if !addrs.is_empty() => Ok(addrs),
_ => Err(anyhow!("couldn't find peer {}", peer_id)),
}
}
}

View File

@ -41,7 +41,7 @@ pub struct Behaviour<Types: IpfsTypes> {
pub enum KadResult {
/// The query has been exhausted.
Complete,
/// The query successfully returns `GetClosestPeers` or `GetProviders` results.
/// The query successfully returns `GetClosestPeers` or `GetProviders` results.
Peers(Vec<PeerId>),
/// The query successfully returns a `GetRecord` result.
Records(Vec<Record>),
@ -333,7 +333,6 @@ impl<Types: IpfsTypes> NetworkBehaviourEventProcess<BitswapEvent> for Behaviour<
peer_id.to_base58(),
e
);
return;
}
};
});

View File

@ -393,7 +393,7 @@ fn update_full_path(
if let Some(name) = name {
if !full_path.is_empty() {
full_path.push_str("/");
full_path.push('/');
}
full_path.push_str(name);
*old_depth += 1;