Skip to content

Remove unnecessary derefs #5070

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
Aug 12, 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/boot/categories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ pub fn sync_with_connection(toml_str: &str, conn: &PgConnection) -> Result<()> {
description.eq(excluded(description)),
))
.returning(slug)
.get_results(&*conn)?;
.get_results(conn)?;

diesel::delete(categories)
.filter(slug.ne(all(slugs)))
.execute(&*conn)?;
.execute(conn)?;
Ok(())
})
}
2 changes: 1 addition & 1 deletion src/controllers/krate/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ pub fn add_dependencies(

// Match only identical names to ensure the index always references the original crate name
let krate:Crate = Crate::by_exact_name(&dep.name)
.first(&*conn)
.first(conn)
.map_err(|_| cargo_err(&format_args!("no known crate named `{}`", &*dep.name)))?;

if let Ok(version_req) = semver::VersionReq::parse(&dep.version_req.0) {
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/version/downloads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub fn download(req: &mut dyn RequestExt) -> EndpointResult {
.app()
.config
.uploader()
.crate_location(&crate_name, &*version);
.crate_location(&crate_name, version);

if req.wants_json() {
Ok(req.json(&json!({ "url": redirect_url })))
Expand Down
4 changes: 2 additions & 2 deletions src/models/crate_owner_invitation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ impl CrateOwnerInvitation {
pub fn find_by_id(user_id: i32, crate_id: i32, conn: &PgConnection) -> AppResult<Self> {
Ok(crate_owner_invitations::table
.find((user_id, crate_id))
.first::<Self>(&*conn)?)
.first::<Self>(conn)?)
}

pub fn find_by_token(token: &str, conn: &PgConnection) -> AppResult<Self> {
Ok(crate_owner_invitations::table
.filter(crate_owner_invitations::token.eq(token))
.first::<Self>(&*conn)?)
.first::<Self>(conn)?)
}

pub fn accept(self, conn: &PgConnection, config: &config::Server) -> AppResult<()> {
Expand Down
2 changes: 1 addition & 1 deletion src/models/keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl Keyword {
pub fn find_by_keyword(conn: &PgConnection, name: &str) -> QueryResult<Keyword> {
keywords::table
.filter(keywords::keyword.eq(lower(name)))
.first(&*conn)
.first(conn)
}

pub fn find_or_create_all(conn: &PgConnection, names: &[&str]) -> QueryResult<Vec<Keyword>> {
Expand Down
4 changes: 2 additions & 2 deletions src/models/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ impl User {
Email::belonging_to(self)
.select(emails::email)
.filter(emails::verified.eq(true))
.first(&*conn)
.first(conn)
.optional()
}

/// Queries for the email belonging to a particular user
pub fn email(&self, conn: &PgConnection) -> AppResult<Option<String>> {
Ok(Email::belonging_to(self)
.select(emails::email)
.first(&*conn)
.first(conn)
.optional()?)
}
}
2 changes: 1 addition & 1 deletion src/tests/krate/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn uploading_new_version_touches_crate() {
app.db(|conn| {
diesel::update(crates::table)
.set(crates::updated_at.eq(crates::updated_at - 1.hour()))
.execute(&*conn)
.execute(conn)
.unwrap();
});

Expand Down
8 changes: 4 additions & 4 deletions src/tests/krate/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,19 +336,19 @@ fn exact_match_on_queries_with_sort() {
// Set the updated at column for each crate
update(&krate1)
.set(crates::updated_at.eq(now - 3.weeks()))
.execute(&*conn)
.execute(conn)
.unwrap();
update(&krate2)
.set(crates::updated_at.eq(now - 5.days()))
.execute(&*conn)
.execute(conn)
.unwrap();
update(&krate3)
.set(crates::updated_at.eq(now - 10.seconds()))
.execute(&*conn)
.execute(conn)
.unwrap();
update(&krate4)
.set(crates::updated_at.eq(now))
.execute(&*conn)
.execute(conn)
.unwrap();
});

Expand Down
2 changes: 1 addition & 1 deletion src/tests/krate/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn summary_new_crates() {
// set total_downloads global value for `num_downloads` prop
update(metadata::table)
.set(metadata::total_downloads.eq(6000))
.execute(&*conn)
.execute(conn)
.unwrap();
});

Expand Down
6 changes: 3 additions & 3 deletions src/tests/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ fn github_with_email_does_not_overwrite_email() {
let original_email: String = app.db(|conn| {
Email::belonging_to(model)
.select(emails::email)
.first(&*conn)
.first(conn)
.unwrap()
});

Expand Down Expand Up @@ -573,7 +573,7 @@ fn test_confirm_user_email() {
let email_token: String = app.db(|conn| {
Email::belonging_to(user_model)
.select(emails::token)
.first(&*conn)
.first(conn)
.unwrap()
});

Expand Down Expand Up @@ -747,7 +747,7 @@ fn test_update_email_notifications_not_owned() {
crate_owners::table
.select(crate_owners::email_notifications)
.filter(crate_owners::crate_id.eq(not_my_crate.id))
.first(&*conn)
.first(conn)
})
.unwrap();

Expand Down
2 changes: 1 addition & 1 deletion src/worker/readmes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn render_and_upload_readme(
.find(version_id)
.inner_join(crates::table)
.select((crates::name, versions::num))
.first(&*conn)?;
.first(conn)?;
env.uploader
.upload_readme(env.http_client(), &crate_name, &vers, rendered)?;
Ok(())
Expand Down