Skip to content

Commit d080411

Browse files
authored
Merge pull request #2936 from hi-rustin/rustin-patch-clippy
Make clippy happy
2 parents cc6c7d0 + d9406b6 commit d080411

File tree

14 files changed

+32
-39
lines changed

14 files changed

+32
-39
lines changed

download/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ pub mod curl {
162162
EASY.with(|handle| {
163163
let mut handle = handle.borrow_mut();
164164

165-
handle.url(&url.to_string())?;
165+
handle.url(url.as_ref())?;
166166
handle.follow_location(true)?;
167167

168168
if resume_from > 0 {

src/cli/rustup_mode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,7 +1671,7 @@ fn output_completion_script(shell: Shell, command: CompletionCommand) -> Result<
16711671
}
16721672
CompletionCommand::Cargo => {
16731673
if let Shell::Zsh = shell {
1674-
writeln!(&mut term2::stdout(), "#compdef cargo")?;
1674+
writeln!(term2::stdout(), "#compdef cargo")?;
16751675
}
16761676

16771677
let script = match shell {
@@ -1687,7 +1687,7 @@ fn output_completion_script(shell: Shell, command: CompletionCommand) -> Result<
16871687
};
16881688

16891689
writeln!(
1690-
&mut term2::stdout(),
1690+
term2::stdout(),
16911691
"if command -v rustc >/dev/null 2>&1; then\n\
16921692
\tsource \"$(rustc --print sysroot)\"{}\n\
16931693
fi",

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl PgpPublicKey {
203203
.with_policy(&p, None)?
204204
.primary_userid()
205205
.map(|u| u.userid().to_string())
206-
.unwrap_or("<No User ID>".into());
206+
.unwrap_or_else(|_| "<No User ID>".into());
207207
ret.push(format!(" {:?}/{} - {}", algo, keyid, uid0));
208208
ret.push(format!(" Fingerprint: {}", fpr));
209209
Ok(ret)

src/diskio/immediate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ impl IncrementalFileWriter {
204204
fn write(&mut self, chunk: Vec<u8>) -> std::result::Result<bool, io::Error> {
205205
let mut state = self.state.lock().unwrap();
206206
if let Some(ref mut state) = *state {
207-
if let Some(ref mut file) = (&mut self.file).as_mut() {
207+
if let Some(ref mut file) = self.file.as_mut() {
208208
// Length 0 vector is used for clean EOF signalling.
209209
if chunk.is_empty() {
210210
trace_scoped!("close", "name:": self.path_display);

src/diskio/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn test_incremental_file(io_threads: &str) -> Result<()> {
5050
for work in io_executor.completed().collect::<Vec<_>>() {
5151
match work {
5252
super::CompletedIo::Chunk(size) => written += size,
53-
super::CompletedIo::Item(item) => unreachable!(format!("{:?}", item)),
53+
super::CompletedIo::Item(item) => unreachable!("{:?}", item),
5454
}
5555
}
5656
if written == 20 {
@@ -117,7 +117,7 @@ fn test_complete_file(io_threads: &str) -> Result<()> {
117117
for work in io_executor.execute(item).collect::<Vec<_>>() {
118118
// The file might complete immediately
119119
match work {
120-
super::CompletedIo::Chunk(size) => unreachable!(format!("{:?}", size)),
120+
super::CompletedIo::Chunk(size) => unreachable!("{:?}", size),
121121
super::CompletedIo::Item(item) => {
122122
check_item(item);
123123
finished = true;
@@ -128,7 +128,7 @@ fn test_complete_file(io_threads: &str) -> Result<()> {
128128
loop {
129129
for work in io_executor.completed().collect::<Vec<_>>() {
130130
match work {
131-
super::CompletedIo::Chunk(size) => unreachable!(format!("{:?}", size)),
131+
super::CompletedIo::Chunk(size) => unreachable!("{:?}", size),
132132
super::CompletedIo::Item(item) => {
133133
check_item(item);
134134
finished = true;

src/dist/dist.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ fn components_missing_msg(cs: &[Component], manifest: &ManifestV2, toolchain: &s
8888
#[derive(Debug, ThisError)]
8989
enum DistError {
9090
#[error("{}", components_missing_msg(.0, .1, .2))]
91-
ToolchainComponentsMissing(Vec<Component>, ManifestV2, String),
91+
ToolchainComponentsMissing(Vec<Component>, Box<ManifestV2>, String),
9292
#[error("no release found for '{0}'")]
9393
MissingReleaseForToolchain(String),
9494
}
@@ -822,7 +822,7 @@ fn try_update_from_dist_<'a>(
822822
let rust_package = m.get_package("rust")?;
823823
let rust_target_package = rust_package.get_target(Some(&toolchain.target.clone()))?;
824824

825-
for component in components.iter().copied() {
825+
for component in components {
826826
let mut component =
827827
Component::new(component.to_string(), Some(toolchain.target.clone()), false);
828828
if let Some(renamed) = m.rename_component(&component) {
@@ -878,7 +878,7 @@ fn try_update_from_dist_<'a>(
878878
toolchain,
879879
}) => Err(anyhow!(DistError::ToolchainComponentsMissing(
880880
components.to_owned(),
881-
manifest.to_owned(),
881+
Box::new(manifest.to_owned()),
882882
toolchain.to_owned(),
883883
))),
884884
Some(_) | None => Err(err),

src/dist/download.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'a> DownloadCfg<'a> {
5252
let cached_result = file_hash(&target_file, self.notify_handler)?;
5353
if hash == cached_result {
5454
(self.notify_handler)(Notification::FileAlreadyDownloaded);
55-
(self.notify_handler)(Notification::ChecksumValid(&url.to_string()));
55+
(self.notify_handler)(Notification::ChecksumValid(url.as_ref()));
5656
return Ok(File { path: target_file });
5757
} else {
5858
(self.notify_handler)(Notification::CachedFileChecksumFailed);
@@ -93,7 +93,7 @@ impl<'a> DownloadCfg<'a> {
9393
if hash != actual_hash {
9494
// Incorrect hash
9595
if partial_file_existed {
96-
self.clean(&[hash.to_string() + &".partial".to_string()])?;
96+
self.clean(&[hash.to_string() + ".partial"])?;
9797
Err(anyhow!(RustupError::BrokenPartialFile))
9898
} else {
9999
Err(RustupError::ChecksumFailed {
@@ -104,7 +104,7 @@ impl<'a> DownloadCfg<'a> {
104104
.into())
105105
}
106106
} else {
107-
(self.notify_handler)(Notification::ChecksumValid(&url.to_string()));
107+
(self.notify_handler)(Notification::ChecksumValid(url.as_ref()));
108108

109109
utils::rename_file(
110110
"downloaded",

src/dist/signatures.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,13 @@ impl VerificationHelper for Helper<'_> {
5656
for layer in structure.into_iter() {
5757
match layer {
5858
MessageLayer::SignatureGroup { results } => {
59-
for result in results {
60-
match result {
61-
Ok(GoodChecksum { ka, .. }) => {
62-
// A good signature! Find the index
63-
// of the singer key and return
64-
// success.
65-
self.index = self.certs.iter().position(|c| c.cert() == ka.cert());
66-
assert!(self.index.is_some());
67-
return Ok(());
68-
}
69-
_ => {
70-
// We ignore any errors.
71-
}
72-
}
59+
// We ignore any errors for now.
60+
for GoodChecksum { ka, .. } in results.into_iter().flatten() {
61+
// A good signature! Find the index
62+
// of the signer key and return
63+
// success.
64+
self.index = self.certs.iter().position(|c| c.cert() == ka.cert());
65+
assert!(self.index.is_some());
7366
}
7467
}
7568
MessageLayer::Compression { .. } => {

src/utils/raw.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub(crate) fn filter_file<F: FnMut(&str) -> bool>(
7979
for result in io::BufRead::lines(&mut reader) {
8080
let line = result?;
8181
if filter(&line) {
82-
writeln!(&mut writer, "{}", &line)?;
82+
writeln!(writer, "{}", &line)?;
8383
} else {
8484
removed += 1;
8585
}
@@ -97,7 +97,7 @@ pub fn append_file(dest: &Path, line: &str) -> io::Result<()> {
9797
.create(true)
9898
.open(dest)?;
9999

100-
writeln!(&mut dest_file, "{}", line)?;
100+
writeln!(dest_file, "{}", line)?;
101101

102102
dest_file.sync_data()?;
103103

src/utils/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ pub(crate) fn format_path_for_display(path: &str) -> String {
536536
}
537537
}
538538

539-
pub(crate) fn toolchain_sort<T: AsRef<str>>(v: &mut Vec<T>) {
539+
pub(crate) fn toolchain_sort<T: AsRef<str>>(v: &mut [T]) {
540540
use semver::{Identifier, Version};
541541

542542
fn special_version(ord: u64, s: &str) -> Version {
@@ -557,7 +557,7 @@ pub(crate) fn toolchain_sort<T: AsRef<str>>(v: &mut Vec<T>) {
557557
} else if s.starts_with("nightly") {
558558
special_version(2, s)
559559
} else {
560-
Version::parse(&s.replace("_", "-")).unwrap_or_else(|_| special_version(3, s))
560+
Version::parse(&s.replace('_', "-")).unwrap_or_else(|_| special_version(3, s))
561561
}
562562
}
563563

0 commit comments

Comments
 (0)