Skip to content

Commit ba37a4e

Browse files
Restore so-called needless lifetimes (pgcentralfoundation#2167)
These were removed in pgcentralfoundation#2097 but some instances wound up erasing deliberate, meaningful names for lifetimes. Eliding them as technically-meaningless at some use-sites is unhelpful.
1 parent 4ba35f0 commit ba37a4e

7 files changed

Lines changed: 20 additions & 16 deletions

File tree

pgrx/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ clippy.missing_safety_doc = "allow"
7272
clippy.too_many_arguments = "allow"
7373
clippy.type_complexity = "allow"
7474
clippy.unnecessary_cast = "allow"
75+
clippy.needless_lifetime = "allow"
7576

7677
[lints.rust]
7778
unsafe-op-in-unsafe-fn = "allow" # repo-wide issue

pgrx/src/callconv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ unsafe impl<T: Copy> BoxRet for PgVarlena<T> {
609609
}
610610
}
611611

612-
unsafe impl<A> BoxRet for PgHeapTuple<'_, A>
612+
unsafe impl<'mcx, A> BoxRet for PgHeapTuple<'mcx, A>
613613
where
614614
A: WhoAllocated,
615615
{
@@ -861,7 +861,7 @@ impl<'fcx> FcInfo<'fcx> {
861861
// TODO: rebadge this as AnyElement
862862
pub struct Arg<'a, 'fcx>(&'a FcInfo<'fcx>, usize, &'a pg_sys::NullableDatum);
863863

864-
impl<'fcx> Arg<'_, 'fcx> {
864+
impl<'a, 'fcx> Arg<'a, 'fcx> {
865865
/// # Performance note
866866
/// This uses an FFI call to obtain the Oid, so avoid calling it if not necessary.
867867
pub fn raw_oid(&self) -> pg_sys::Oid {

pgrx/src/heap_tuple.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ impl<'mcx> PgHeapTuple<'mcx, AllocatedByRust> {
423423
}
424424
}
425425

426-
impl<AllocatedBy: WhoAllocated> IntoDatum for PgHeapTuple<'_, AllocatedBy> {
426+
impl<'mcx, AllocatedBy: WhoAllocated> IntoDatum for PgHeapTuple<'mcx, AllocatedBy> {
427427
// Delegate to `into_composite_datum()` as this will normally be used with composite types.
428428
// See `into_trigger_datum()` if using as a trigger.
429429
fn into_datum(self) -> Option<pg_sys::Datum> {
@@ -449,7 +449,7 @@ impl<AllocatedBy: WhoAllocated> IntoDatum for PgHeapTuple<'_, AllocatedBy> {
449449
}
450450
}
451451

452-
impl<AllocatedBy: WhoAllocated> PgHeapTuple<'_, AllocatedBy> {
452+
impl<'mcx, AllocatedBy: WhoAllocated> PgHeapTuple<'mcx, AllocatedBy> {
453453
/// Consume this [`PgHeapTuple`] and return a composite Datum representation, containing the tuple
454454
/// data and the corresponding tuple descriptor information.
455455
pub fn into_composite_datum(self) -> Option<pg_sys::Datum> {

pgrx/src/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl<T: Enlist> List<'_, T> {
132132
}
133133
}
134134

135-
impl<T> List<'_, T> {
135+
impl<'cx, T> List<'cx, T> {
136136
#[inline]
137137
pub fn len(&self) -> usize {
138138
match self {

pgrx/src/list/flat_list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ pub struct Drain<'a, 'cx, T> {
361361
raw: *mut pg_sys::List,
362362
}
363363

364-
impl<T> Drop for Drain<'_, '_, T> {
364+
impl<'a, 'cx, T> Drop for Drain<'a, 'cx, T> {
365365
fn drop(&mut self) {
366366
if self.raw.is_null() {
367367
return;

pgrx/src/spi/query.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ pub trait PreparableQuery<'conn>: Query<'conn> {
6464
) -> SpiResult<PreparedStatement<'conn>>;
6565
}
6666

67-
fn execute<'conn>(
67+
fn execute<'conn, 'mcx>(
6868
cmd: &CStr,
69-
args: &[DatumWithOid<'_>],
69+
args: &[DatumWithOid<'mcx>],
7070
limit: Option<libc::c_long>,
7171
) -> SpiResult<SpiTupleTable<'conn>> {
7272
// SAFETY: no concurrent access
@@ -100,7 +100,10 @@ fn execute<'conn>(
100100
SpiClient::prepare_tuple_table(status_code)
101101
}
102102

103-
fn open_cursor<'conn>(cmd: &CStr, args: &[DatumWithOid<'_>]) -> SpiResult<SpiCursor<'conn>> {
103+
fn open_cursor<'conn, 'mcx>(
104+
cmd: &CStr,
105+
args: &[DatumWithOid<'mcx>],
106+
) -> SpiResult<SpiCursor<'conn>> {
104107
let nargs = args.len();
105108
let (mut argtypes, mut datums, nulls) = args_to_datums(args);
106109

@@ -122,8 +125,8 @@ fn open_cursor<'conn>(cmd: &CStr, args: &[DatumWithOid<'_>]) -> SpiResult<SpiCur
122125
Ok(SpiCursor { ptr, __marker: PhantomData })
123126
}
124127

125-
fn args_to_datums(
126-
args: &[DatumWithOid<'_>],
128+
fn args_to_datums<'mcx>(
129+
args: &[DatumWithOid<'mcx>],
127130
) -> (Vec<pg_sys::Oid>, Vec<pg_sys::Datum>, Vec<c_char>) {
128131
let mut argtypes = Vec::with_capacity(args.len());
129132
let mut datums = Vec::with_capacity(args.len());
@@ -140,7 +143,7 @@ fn args_to_datums(
140143
(argtypes, datums, nulls)
141144
}
142145

143-
fn prepare_datum(datum: &DatumWithOid<'_>) -> (pg_sys::Datum, std::os::raw::c_char) {
146+
fn prepare_datum<'mcx>(datum: &DatumWithOid<'mcx>) -> (pg_sys::Datum, std::os::raw::c_char) {
144147
match datum.datum() {
145148
Some(datum) => (datum.sans_lifetime(), ' ' as std::os::raw::c_char),
146149
None => (pg_sys::Datum::from(0usize), 'n' as std::os::raw::c_char),
@@ -296,7 +299,7 @@ impl<'conn> Query<'conn> for OwnedPreparedStatement {
296299
}
297300
}
298301

299-
impl PreparedStatement<'_> {
302+
impl<'conn> PreparedStatement<'conn> {
300303
/// Converts prepared statement into an owned prepared statement
301304
///
302305
/// These statements have static lifetime and are freed only when dropped
@@ -314,9 +317,9 @@ impl PreparedStatement<'_> {
314317
})
315318
}
316319

317-
fn args_to_datums(
320+
fn args_to_datums<'mcx>(
318321
&self,
319-
args: &[DatumWithOid<'_>],
322+
args: &[DatumWithOid<'mcx>],
320323
) -> SpiResult<(Vec<pg_sys::Datum>, Vec<std::os::raw::c_char>)> {
321324
let actual = args.len();
322325
let expected = unsafe { pg_sys::SPI_getargcount(self.plan.as_ptr()) } as usize;

pgrx/src/spi/tuple.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ impl<'conn> SpiHeapTupleData<'conn> {
458458
}
459459
}
460460

461-
impl SpiHeapTupleDataEntry<'_> {
461+
impl<'conn> SpiHeapTupleDataEntry<'conn> {
462462
pub fn value<T: IntoDatum + FromDatum>(&self) -> SpiResult<Option<T>> {
463463
match self.datum.as_ref() {
464464
Some(datum) => unsafe {

0 commit comments

Comments
 (0)