diff --git a/cargo-pgrx/src/command/schema.rs b/cargo-pgrx/src/command/schema.rs index 985c28cab9..484c36fbbb 100644 --- a/cargo-pgrx/src/command/schema.rs +++ b/cargo-pgrx/src/command/schema.rs @@ -358,7 +358,7 @@ fn first_build( command.arg(arg); } - let command_str = format!("{:?}", command); + let command_str = format!("{command:?}"); eprintln!( "{} for SQL generation with features `{}`", " Building".bold().green(), @@ -367,7 +367,7 @@ fn first_build( tracing::debug!(command = %command_str, "Running"); let cargo_output = - command.output().wrap_err_with(|| format!("failed to spawn cargo: {}", command_str))?; + command.output().wrap_err_with(|| format!("failed to spawn cargo: {command_str}"))?; tracing::trace!(status_code = %cargo_output.status, command = %command_str, "Finished"); if !cargo_output.status.success() { @@ -522,7 +522,7 @@ fn second_build( command.env("PGRX_EMBED", embed_path.as_ref()); - let command_str = format!("{:?}", command); + let command_str = format!("{command:?}"); eprintln!( "{} {}, in debug mode, for SQL generation with features {}", " Rebuilding".bold().green(), @@ -532,7 +532,7 @@ fn second_build( tracing::debug!(command = %command_str, "Running"); let cargo_output = - command.output().wrap_err_with(|| format!("failed to spawn cargo: {}", command_str))?; + command.output().wrap_err_with(|| format!("failed to spawn cargo: {command_str}"))?; tracing::trace!(status_code = %cargo_output.status, command = %command_str, "Finished"); if !cargo_output.status.success() { @@ -559,11 +559,10 @@ fn compute_sql(package_name: &str, manifest: &Manifest) -> eyre::Result<()> { }); command.env("CARGO_PKG_VERSION", cargo_pkg_version); - let command_str = format!("{:?}", command); + let command_str = format!("{command:?}"); tracing::debug!(command = %command_str, "Running"); - let embed_output = command - .output() - .wrap_err_with(|| format!("failed to spawn pgrx_embed: {}", command_str))?; + let embed_output = + command.output().wrap_err_with(|| format!("failed to spawn pgrx_embed: {command_str}"))?; tracing::trace!(status_code = %embed_output.status, command = %command_str, "Finished"); if !embed_output.status.success() { diff --git a/pgrx-sql-entity-graph/src/aggregate/entity.rs b/pgrx-sql-entity-graph/src/aggregate/entity.rs index ab1740371e..a2effce6bd 100644 --- a/pgrx-sql-entity-graph/src/aggregate/entity.rs +++ b/pgrx-sql-entity-graph/src/aggregate/entity.rs @@ -178,7 +178,7 @@ impl ToSql for PgAggregateEntity { if let Some(value) = self.finalfunc { optional_attributes.push(( - format!("\tFINALFUNC = {}\"{}\"", schema, value), + format!("\tFINALFUNC = {schema}\"{value}\""), format!("/* {}::final */", self.full_path), )); } @@ -190,43 +190,43 @@ impl ToSql for PgAggregateEntity { } if let Some(value) = self.combinefunc { optional_attributes.push(( - format!("\tCOMBINEFUNC = {}\"{}\"", schema, value), + format!("\tCOMBINEFUNC = {schema}\"{value}\""), format!("/* {}::combine */", self.full_path), )); } if let Some(value) = self.serialfunc { optional_attributes.push(( - format!("\tSERIALFUNC = {}\"{}\"", schema, value), + format!("\tSERIALFUNC = {schema}\"{value}\""), format!("/* {}::serial */", self.full_path), )); } if let Some(value) = self.deserialfunc { optional_attributes.push(( - format!("\tDESERIALFUNC ={} \"{}\"", schema, value), + format!("\tDESERIALFUNC ={schema} \"{value}\""), format!("/* {}::deserial */", self.full_path), )); } if let Some(value) = self.initcond { optional_attributes.push(( - format!("\tINITCOND = '{}'", value), + format!("\tINITCOND = '{value}'"), format!("/* {}::INITIAL_CONDITION */", self.full_path), )); } if let Some(value) = self.msfunc { optional_attributes.push(( - format!("\tMSFUNC = {}\"{}\"", schema, value), + format!("\tMSFUNC = {schema}\"{value}\""), format!("/* {}::moving_state */", self.full_path), )); } if let Some(value) = self.minvfunc { optional_attributes.push(( - format!("\tMINVFUNC = {}\"{}\"", schema, value), + format!("\tMINVFUNC = {schema}\"{value}\""), format!("/* {}::moving_state_inverse */", self.full_path), )); } if let Some(value) = self.mfinalfunc { optional_attributes.push(( - format!("\tMFINALFUNC = {}\"{}\"", schema, value), + format!("\tMFINALFUNC = {schema}\"{value}\""), format!("/* {}::moving_state_finalize */", self.full_path), )); } @@ -238,13 +238,13 @@ impl ToSql for PgAggregateEntity { } if let Some(value) = self.minitcond { optional_attributes.push(( - format!("\tMINITCOND = '{}'", value), + format!("\tMINITCOND = '{value}'"), format!("/* {}::MOVING_INITIAL_CONDITION */", self.full_path), )); } if let Some(value) = self.sortop { optional_attributes.push(( - format!("\tSORTOP = \"{}\"", value), + format!("\tSORTOP = \"{value}\""), format!("/* {}::SORT_OPERATOR */", self.full_path), )); } @@ -290,7 +290,7 @@ impl ToSql for PgAggregateEntity { if let Some(value) = &self.mstype { let mstype_sql = map_ty(value).wrap_err("Mapping moving state type")?; optional_attributes.push(( - format!("\tMSTYPE = {}", mstype_sql), + format!("\tMSTYPE = {mstype_sql}"), format!("/* {}::MovingState = {} */", self.full_path, value.full_path), )); } @@ -348,7 +348,7 @@ impl ToSql for PgAggregateEntity { maybe_comma = if needs_comma { ", " } else { " " }, full_path = arg.used_ty.full_path, name = if let Some(name) = arg.name { - format!(r#""{}" "#, name) + format!(r#""{name}" "#) } else { "".to_string() }, ); args.push(buf); diff --git a/pgrx-sql-entity-graph/src/extension_sql/entity.rs b/pgrx-sql-entity-graph/src/extension_sql/entity.rs index ec9a4e589c..b058d0e898 100644 --- a/pgrx-sql-entity-graph/src/extension_sql/entity.rs +++ b/pgrx-sql-entity-graph/src/extension_sql/entity.rs @@ -72,8 +72,7 @@ impl ToSql for ExtensionSqlEntity { fn to_sql(&self, _context: &PgrxSql) -> eyre::Result { let ExtensionSqlEntity { file, line, sql, creates, requires, .. } = self; let creates = if !creates.is_empty() { - let joined = - creates.iter().map(|i| format!("-- {}", i)).collect::>().join("\n"); + let joined = creates.iter().map(|i| format!("-- {i}")).collect::>().join("\n"); format!( "\ -- creates:\n\ @@ -84,7 +83,7 @@ impl ToSql for ExtensionSqlEntity { }; let requires = if !requires.is_empty() { let joined = - requires.iter().map(|i| format!("-- {}", i)).collect::>().join("\n"); + requires.iter().map(|i| format!("-- {i}")).collect::>().join("\n"); format!( "\ -- requires:\n\ @@ -156,14 +155,14 @@ impl SqlDeclaredEntity { .ok_or_else(|| eyre::eyre!("Did not get SQL for `{}`", name))? .to_string(), name: name.to_string(), - option: format!("Option<{}>", name), - vec: format!("Vec<{}>", name), - vec_option: format!("Vec>", name), - option_vec: format!("Option>", name), - option_vec_option: format!("Option>", name), - array: format!("Array<{}>", name), - option_array: format!("Option<{}>", name), - varlena: format!("Varlena<{}>", name), + option: format!("Option<{name}>"), + vec: format!("Vec<{name}>"), + vec_option: format!("Vec>"), + option_vec: format!("Option>"), + option_vec_option: format!("Option>"), + array: format!("Array<{name}>"), + option_array: format!("Option<{name}>"), + varlena: format!("Varlena<{name}>"), pg_box: vec![ format!("pgrx::pgbox::PgBox<{}>", name), format!("pgrx::pgbox::PgBox<{}, pgrx::pgbox::AllocatedByRust>", name), diff --git a/pgrx-sql-entity-graph/src/extension_sql/mod.rs b/pgrx-sql-entity-graph/src/extension_sql/mod.rs index 57793be8a2..27fb783b4c 100644 --- a/pgrx-sql-entity-graph/src/extension_sql/mod.rs +++ b/pgrx-sql-entity-graph/src/extension_sql/mod.rs @@ -275,7 +275,7 @@ impl Parse for ExtensionSqlAttribute { other => { return Err(syn::Error::new( ident.span(), - format!("Unknown extension_sql attribute: {}", other), + format!("Unknown extension_sql attribute: {other}"), )) } }; diff --git a/pgrx-sql-entity-graph/src/extern_args.rs b/pgrx-sql-entity-graph/src/extern_args.rs index cfa0922240..379ccde57d 100644 --- a/pgrx-sql-entity-graph/src/extern_args.rs +++ b/pgrx-sql-entity-graph/src/extern_args.rs @@ -51,7 +51,7 @@ impl core::fmt::Display for ExternArgs { ExternArgs::NoGuard => Ok(()), ExternArgs::Schema(_) => Ok(()), ExternArgs::Name(_) => Ok(()), - ExternArgs::Cost(cost) => write!(f, "COST {}", cost), + ExternArgs::Cost(cost) => write!(f, "COST {cost}"), ExternArgs::Requires(_) => Ok(()), } } diff --git a/pgrx-sql-entity-graph/src/pg_extern/entity/mod.rs b/pgrx-sql-entity-graph/src/pg_extern/entity/mod.rs index 5c19a77fde..0b3b8349c8 100644 --- a/pgrx-sql-entity-graph/src/pg_extern/entity/mod.rs +++ b/pgrx-sql-entity-graph/src/pg_extern/entity/mod.rs @@ -103,7 +103,7 @@ impl ToSql for PgExternEntity { let module_pathname = &context.get_module_pathname(); let schema = self .schema - .map(|schema| format!("{}.", schema)) + .map(|schema| format!("{schema}.")) .unwrap_or_else(|| context.schema_prefix_for(&self_index)); let arguments = if !self.fn_args.is_empty() { let mut args = Vec::new(); @@ -130,7 +130,7 @@ impl ToSql for PgExternEntity { schema_prefix = context.schema_prefix_for(&graph_index), // First try to match on [`TypeId`] since it's most reliable. sql_type = argument_sql, - default = if let Some(def) = arg.used_ty.default { format!(" DEFAULT {}", def) } else { String::from("") }, + default = if let Some(def) = arg.used_ty.default { format!(" DEFAULT {def}") } else { String::from("") }, variadic = if metadata_argument.variadic { "VARIADIC " } else { "" }, maybe_comma = if needs_comma { ", " } else { " " }, type_name = metadata_argument.type_name, @@ -154,7 +154,7 @@ impl ToSql for PgExternEntity { schema_prefix = context.schema_prefix_for(&graph_index), // First try to match on [`TypeId`] since it's most reliable. sql_type = sql, - default = if let Some(def) = arg.used_ty.default { format!(" DEFAULT {}", def) } else { String::from("") }, + default = if let Some(def) = arg.used_ty.default { format!(" DEFAULT {def}") } else { String::from("") }, variadic = if metadata_argument.variadic { "VARIADIC " } else { "" }, maybe_comma = if needs_comma { ", " } else { " " }, type_name = metadata_argument.type_name, @@ -255,7 +255,7 @@ impl ToSql for PgExternEntity { ); items.push_str(&item); } - format!("RETURNS TABLE ({}\n)", items) + format!("RETURNS TABLE ({items}\n)") } PgExternReturnEntity::Trigger => String::from("RETURNS trigger"), }; @@ -307,7 +307,7 @@ impl ToSql for PgExternEntity { "-- requires:\n{}\n", requires_attrs .iter() - .map(|i| format!("-- {}", i)) + .map(|i| format!("-- {i}")) .collect::>() .join("\n") ) @@ -327,16 +327,16 @@ impl ToSql for PgExternEntity { if let Some(op) = &self.operator { let mut optionals = vec![]; if let Some(it) = op.commutator { - optionals.push(format!("\tCOMMUTATOR = {}", it)); + optionals.push(format!("\tCOMMUTATOR = {it}")); }; if let Some(it) = op.negator { - optionals.push(format!("\tNEGATOR = {}", it)); + optionals.push(format!("\tNEGATOR = {it}")); }; if let Some(it) = op.restrict { - optionals.push(format!("\tRESTRICT = {}", it)); + optionals.push(format!("\tRESTRICT = {it}")); }; if let Some(it) = op.join { - optionals.push(format!("\tJOIN = {}", it)); + optionals.push(format!("\tJOIN = {it}")); }; if op.hashes { optionals.push(String::from("\tHASHES")); @@ -423,7 +423,7 @@ impl ToSql for PgExternEntity { let schema = self .schema - .map(|schema| format!("{}.", schema)) + .map(|schema| format!("{schema}.")) .unwrap_or_else(|| context.schema_prefix_for(&self_index)); let operator_sql = format!("\n\n\ diff --git a/pgrx-sql-entity-graph/src/pgrx_sql.rs b/pgrx-sql-entity-graph/src/pgrx_sql.rs index 4c652b29dc..6afcd69497 100644 --- a/pgrx-sql-entity-graph/src/pgrx_sql.rs +++ b/pgrx-sql-entity-graph/src/pgrx_sql.rs @@ -262,7 +262,7 @@ impl PgrxSql { create_dir_all(parent)?; } let mut out = File::create(path)?; - write!(out, "{}", generated)?; + write!(out, "{generated}")?; Ok(()) } @@ -281,7 +281,7 @@ impl PgrxSql { #[cfg(not(feature = "syntax-highlighting"))] { - write!(*out, "{}", generated)?; + write!(*out, "{generated}")?; } Ok(()) @@ -382,7 +382,7 @@ impl PgrxSql { create_dir_all(parent)?; } let mut out = File::create(path)?; - write!(out, "{:?}", generated)?; + write!(out, "{generated:?}")?; Ok(()) } @@ -456,7 +456,7 @@ impl PgrxSql { let extname = &self.extension_name; let extver = &self.control.default_version; // Note: versioned so-name format must agree with cargo pgrx - format!("$libdir/{}-{}", extname, extver) + format!("$libdir/{extname}-{extver}") } else { String::from("MODULE_PATHNAME") } diff --git a/pgrx-sql-entity-graph/src/postgres_enum/entity.rs b/pgrx-sql-entity-graph/src/postgres_enum/entity.rs index 7fef1f0ca3..9b1fc9ec3b 100644 --- a/pgrx-sql-entity-graph/src/postgres_enum/entity.rs +++ b/pgrx-sql-entity-graph/src/postgres_enum/entity.rs @@ -83,7 +83,7 @@ impl ToSql for PostgresEnumEntity { variants = self .variants .iter() - .map(|variant| format!("\t'{}'", variant)) + .map(|variant| format!("\t'{variant}'")) .collect::>() .join(",\n") + "\n", diff --git a/pgrx-tests/tests/compile-fail/table-iterators-arent-immortal.stderr b/pgrx-tests/tests/compile-fail/table-iterators-arent-immortal.stderr index 5ab6cc763b..331cb9420c 100644 --- a/pgrx-tests/tests/compile-fail/table-iterators-arent-immortal.stderr +++ b/pgrx-tests/tests/compile-fail/table-iterators-arent-immortal.stderr @@ -1,3 +1,15 @@ +warning: elided lifetime has a name + --> tests/compile-fail/table-iterators-arent-immortal.rs:6:19 + | +6 | ) -> TableIterator<(name!(a, &'static str), name!(b, Option<&'static str>))> { + | ^ this elided lifetime gets resolved as `'static` + | + = note: `#[warn(elided_named_lifetimes)]` on by default +help: consider specifying it explicitly + | +6 | ) -> TableIterator<'static, (name!(a, &'static str), name!(b, Option<&'static str>))> { + | ++++++++ + error[E0521]: borrowed data escapes outside of function --> tests/compile-fail/table-iterators-arent-immortal.rs:6:78 | diff --git a/pgrx/src/datum/unbox.rs b/pgrx/src/datum/unbox.rs index 08f85679aa..2bbd140f46 100644 --- a/pgrx/src/datum/unbox.rs +++ b/pgrx/src/datum/unbox.rs @@ -122,6 +122,7 @@ unsafe impl UnboxDatum for str { } unsafe impl UnboxDatum for &str { + #[rustfmt::skip] type As<'src> = &'src str where Self: 'src; #[inline] unsafe fn unbox<'src>(datum: Datum<'src>) -> Self::As<'src> @@ -144,6 +145,7 @@ unsafe impl UnboxDatum for CStr { } unsafe impl UnboxDatum for &CStr { + #[rustfmt::skip] type As<'src> = &'src CStr where Self: 'src; #[inline] unsafe fn unbox<'src>(datum: Datum<'src>) -> Self::As<'src> @@ -166,6 +168,7 @@ unsafe impl UnboxDatum for [u8] { } unsafe impl UnboxDatum for &[u8] { + #[rustfmt::skip] type As<'src> = &'src [u8] where Self: 'src; #[inline] unsafe fn unbox<'src>(datum: Datum<'src>) -> Self::As<'src> @@ -293,6 +296,7 @@ unbox_with_fromdatum! { } unsafe impl UnboxDatum for PgHeapTuple<'_, crate::AllocatedByRust> { + #[rustfmt::skip] type As<'src> = PgHeapTuple<'src, AllocatedByRust> where Self: 'src; #[inline] unsafe fn unbox<'src>(d: Datum<'src>) -> Self::As<'src> @@ -304,6 +308,7 @@ unsafe impl UnboxDatum for PgHeapTuple<'_, crate::AllocatedByRust> { } unsafe impl UnboxDatum for Array<'_, T> { + #[rustfmt::skip] type As<'src> = Array<'src, T> where Self: 'src; unsafe fn unbox<'src>(d: Datum<'src>) -> Array<'src, T> where @@ -314,6 +319,7 @@ unsafe impl UnboxDatum for Array<'_, T> { } unsafe impl UnboxDatum for VariadicArray<'_, T> { + #[rustfmt::skip] type As<'src> = VariadicArray<'src, T> where Self: 'src; unsafe fn unbox<'src>(d: Datum<'src>) -> VariadicArray<'src, T> where @@ -324,6 +330,7 @@ unsafe impl UnboxDatum for VariadicArray<'_, T> { } unsafe impl UnboxDatum for Range { + #[rustfmt::skip] type As<'src> = Range where Self: 'src; unsafe fn unbox<'src>(d: Datum<'src>) -> Self::As<'src> where @@ -345,6 +352,7 @@ unsafe impl UnboxDatum for Numeric { } unsafe impl UnboxDatum for PgBox { + #[rustfmt::skip] type As<'src> = PgBox where Self: 'src; #[inline] unsafe fn unbox<'src>(d: Datum<'src>) -> Self::As<'src> @@ -356,6 +364,7 @@ unsafe impl UnboxDatum for PgBox { } unsafe impl UnboxDatum for Json { + #[rustfmt::skip] type As<'src> = Json where Self: 'src; #[inline] unsafe fn unbox<'src>(d: Datum<'src>) -> Self::As<'src> @@ -367,6 +376,7 @@ unsafe impl UnboxDatum for Json { } unsafe impl UnboxDatum for JsonB { + #[rustfmt::skip] type As<'src> = JsonB where Self: 'src; #[inline] unsafe fn unbox<'src>(d: Datum<'src>) -> Self::As<'src>