diff --git a/diesel/src/pg/connection/result.rs b/diesel/src/pg/connection/result.rs index eaa84791c90c..a5542d0a51ce 100644 --- a/diesel/src/pg/connection/result.rs +++ b/diesel/src/pg/connection/result.rs @@ -108,9 +108,10 @@ impl PgResult { } pub(super) fn num_rows(&self) -> usize { - self.row_count - .try_into() - .expect("Diesel expects to run on at a least 32 bit OS") + self.row_count.try_into().expect( + "Diesel expects to run on a >= 32 bit OS \ + (or libpq is giving out negative row count)", + ) } pub(super) fn get_row(self: Rc, idx: usize) -> PgRow { @@ -149,7 +150,7 @@ impl PgResult { } pub(in crate::pg) fn column_type(&self, col_idx: usize) -> NonZeroU32 { - let col_idx = col_idx + let col_idx: i32 = col_idx .try_into() .expect("Column indices are expected to fit into 32 bit"); let type_oid = unsafe { PQftype(self.internal_result.as_ptr(), col_idx) }; @@ -191,9 +192,10 @@ impl PgResult { } pub(super) fn column_count(&self) -> usize { - self.column_count - .try_into() - .expect("Diesel expects to run on a at least 32 bit OS") + self.column_count.try_into().expect( + "Diesel expects to run on a >= 32 bit OS \ + (or libpq is giving out negative column count)", + ) } } diff --git a/diesel/src/pg/connection/stmt/mod.rs b/diesel/src/pg/connection/stmt/mod.rs index 85fcb5d60ca6..624574a7b973 100644 --- a/diesel/src/pg/connection/stmt/mod.rs +++ b/diesel/src/pg/connection/stmt/mod.rs @@ -36,7 +36,7 @@ impl Statement { .map(|data| data.as_ref().map(|d| d.len().try_into()).unwrap_or(Ok(0))) .collect::, _>>() .map_err(|e| crate::result::Error::SerializationError(Box::new(e)))?; - let param_count = params_pointer + let param_count: libc::c_int = params_pointer .len() .try_into() .map_err(|e| crate::result::Error::SerializationError(Box::new(e)))?; @@ -71,7 +71,7 @@ impl Statement { .map_err(|e| crate::result::Error::SerializationError(Box::new(e)))?; let internal_result = unsafe { - let param_count = param_types + let param_count: libc::c_int = param_types .len() .try_into() .map_err(|e| crate::result::Error::SerializationError(Box::new(e)))?; diff --git a/diesel/src/sqlite/connection/raw.rs b/diesel/src/sqlite/connection/raw.rs index 255dea08f9d6..57d6a5fbcf40 100644 --- a/diesel/src/sqlite/connection/raw.rs +++ b/diesel/src/sqlite/connection/raw.rs @@ -420,7 +420,7 @@ where static NULL_CTX_ERR: &str = "We've written the aggregator to the aggregate context, but it could not be retrieved."; - let n_bytes = std::mem::size_of::>() + let n_bytes: i32 = std::mem::size_of::>() .try_into() .expect("Aggregate context should be larger than 2^32"); let aggregate_context = unsafe { @@ -525,7 +525,7 @@ extern "C" fn run_aggregator_final_function