Skip to content

Commit

Permalink
Address clippy::must_use_candidate in template (#1740)
Browse files Browse the repository at this point in the history
This addresses `clippy::must_use_candidate` and applies a minor
optimization: it removes a Vec realloc by simply taking the existing
one, instead of cloning and clearing it.

---------

Co-authored-by: Jubilee <[email protected]>
  • Loading branch information
nyurik and workingjubilee authored Jun 29, 2024
1 parent 7556ad7 commit b0b6ca6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions cargo-pgrx/src/templates/lib_rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub mod pg_test {{
// perform one-off initialization when the pg_test framework starts
}}

#[must_use]
pub fn postgresql_conf_options() -> Vec<&'static str> {{
// return any postgresql.conf settings that are required for your tests
vec![]
Expand Down
5 changes: 2 additions & 3 deletions pgrx-macros/src/rewriter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
extern crate proc_macro;

use quote::{format_ident, quote, quote_spanned};
use std::mem;
use std::ops::Deref;
use std::str::FromStr;
use syn::punctuated::Punctuated;
Expand All @@ -35,8 +36,7 @@ pub fn item_fn_without_rewrite(mut func: ItemFn) -> syn::Result<proc_macro2::Tok
let input_func_name = func.sig.ident.to_string();
let sig = func.sig.clone();
let vis = func.vis.clone();
let attrs = func.attrs.clone();

let mut attrs = mem::take(&mut func.attrs);
let generics = func.sig.generics.clone();

if attrs.iter().any(|attr| attr.path().is_ident("no_mangle"))
Expand All @@ -52,7 +52,6 @@ pub fn item_fn_without_rewrite(mut func: ItemFn) -> syn::Result<proc_macro2::Tok
// but for the inner function (the one we're wrapping) we don't need any kind of
// abi classification
func.sig.abi = None;
func.attrs.clear();

// nor do we need a visibility beyond "private"
func.vis = Visibility::Inherited;
Expand Down

0 comments on commit b0b6ca6

Please sign in to comment.