Skip to content

fix new clippy warnings #1690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2022
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
4 changes: 2 additions & 2 deletions src/docbuilder/rustwide_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ mod tests {
fn test_build_crate() {
wrapper(|env| {
let crate_ = DUMMY_CRATE_NAME;
let crate_path = crate_.replace("-", "_");
let crate_path = crate_.replace('-', "_");
let version = DUMMY_CRATE_VERSION;
let default_target = "x86_64-unknown-linux-gnu";

Expand Down Expand Up @@ -1020,7 +1020,7 @@ mod tests {
assert!(storage.exists(&source_archive)?, "{}", source_archive);

let target = "x86_64-unknown-linux-gnu";
let crate_path = crate_.replace("-", "_");
let crate_path = crate_.replace('-', "_");
let target_docs_present = storage.exists_in_archive(
&doc_archive,
&format!("{}/{}/index.html", target, crate_path),
Expand Down
2 changes: 1 addition & 1 deletion src/storage/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ impl<'a> StorageTransaction for S3StorageTransaction<'a> {

let to_delete = list
.contents
.unwrap_or_else(Vec::new)
.unwrap_or_default()
.into_iter()
.filter_map(|o| o.key)
.map(|key| ObjectIdentifier {
Expand Down
1 change: 1 addition & 0 deletions src/web/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ impl Routes {
pattern.to_string(),
Box::new(RequestRecorder::new(
SimpleRedirect::new(|url| {
#[allow(clippy::unnecessary_to_owned)]
url.set_path(&url.path().trim_end_matches('/').to_string())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, why doesn't removing to_string work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error[E0502]: cannot borrow `*url` as mutable because it is also borrowed as immutable
   --> src/web/routes.rs:273:25
    |
273 |                         url.set_path(&url.path().trim_end_matches('/'))
    |                         ^^^^--------^^----------^^^^^^^^^^^^^^^^^^^^^^^
    |                         |   |         |
    |                         |   |         immutable borrow occurs here
    |                         |   immutable borrow later used by call
    |                         mutable borrow occurs here

if I'm not missing anything, we cannot get around this, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, makes sense - maybe report this upstream to clippy as a bug?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do that, when I can use clippy locally again and prepare a proper issue.

( I'm a victim of rust-lang/rust-clippy#8470 )

}),
pattern,
Expand Down
2 changes: 1 addition & 1 deletion src/web/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ mod test {
.name(name)
.version(version)
.archive_storage(archive_storage)
.rustdoc_file(&(name.replace("-", "_") + "/index.html"))
.rustdoc_file(&(name.replace('-', "_") + "/index.html"))
.create()?;
}

Expand Down