Merge remote-tracking branch 'upstream/master' into debug_row

This commit is contained in:
gwenn
2022-10-30 09:03:17 +01:00
13 changed files with 53 additions and 53 deletions

View File

@@ -245,7 +245,7 @@ impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
Error::SqliteFailure(ref err, None) => err.fmt(f),
Error::SqliteFailure(_, Some(ref s)) => write!(f, "{}", s),
Error::SqliteFailure(_, Some(ref s)) => write!(f, "{s}"),
Error::SqliteSingleThreadedMode => write!(
f,
"SQLite was compiled or configured for single-threaded use only"
@@ -263,21 +263,21 @@ impl fmt::Display for Error {
}
Error::IntegralValueOutOfRange(col, val) => {
if col != UNKNOWN_COLUMN {
write!(f, "Integer {} out of range at index {}", val, col)
write!(f, "Integer {val} out of range at index {col}")
} else {
write!(f, "Integer {} out of range", val)
write!(f, "Integer {val} out of range")
}
}
Error::Utf8Error(ref err) => err.fmt(f),
Error::NulError(ref err) => err.fmt(f),
Error::InvalidParameterName(ref name) => write!(f, "Invalid parameter name: {}", name),
Error::InvalidParameterName(ref name) => write!(f, "Invalid parameter name: {name}"),
Error::InvalidPath(ref p) => write!(f, "Invalid path: {}", p.to_string_lossy()),
Error::ExecuteReturnedResults => {
write!(f, "Execute returned results - did you mean to call query?")
}
Error::QueryReturnedNoRows => write!(f, "Query returned no rows"),
Error::InvalidColumnIndex(i) => write!(f, "Invalid column index: {}", i),
Error::InvalidColumnName(ref name) => write!(f, "Invalid column name: {}", name),
Error::InvalidColumnIndex(i) => write!(f, "Invalid column index: {i}"),
Error::InvalidColumnName(ref name) => write!(f, "Invalid column name: {name}"),
Error::InvalidColumnType(i, ref name, ref t) => write!(
f,
"Invalid column type {} at index: {}, name: {}",
@@ -288,22 +288,22 @@ impl fmt::Display for Error {
"Wrong number of parameters passed to query. Got {}, needed {}",
i1, n1
),
Error::StatementChangedRows(i) => write!(f, "Query changed {} rows", i),
Error::StatementChangedRows(i) => write!(f, "Query changed {i} rows"),
#[cfg(feature = "functions")]
Error::InvalidFunctionParameterType(i, ref t) => {
write!(f, "Invalid function parameter type {} at index {}", t, i)
write!(f, "Invalid function parameter type {t} at index {i}")
}
#[cfg(feature = "vtab")]
Error::InvalidFilterParameterType(i, ref t) => {
write!(f, "Invalid filter parameter type {} at index {}", t, i)
write!(f, "Invalid filter parameter type {t} at index {i}")
}
#[cfg(feature = "functions")]
Error::UserFunctionError(ref err) => err.fmt(f),
Error::ToSqlConversionFailure(ref err) => err.fmt(f),
Error::InvalidQuery => write!(f, "Query is not read-only"),
#[cfg(feature = "vtab")]
Error::ModuleError(ref desc) => write!(f, "{}", desc),
Error::ModuleError(ref desc) => write!(f, "{desc}"),
#[cfg(feature = "functions")]
Error::UnwindingPanic => write!(f, "unwinding panic"),
#[cfg(feature = "functions")]
@@ -317,7 +317,7 @@ impl fmt::Display for Error {
offset,
ref sql,
..
} => write!(f, "{} in {} at offset {}", msg, sql, offset),
} => write!(f, "{msg} in {sql} at offset {offset}"),
}
}
}

View File

@@ -105,7 +105,7 @@ impl InnerConnection {
{
e = Error::SqliteFailure(
ffi::Error::new(r),
Some(format!("{}: {}", msg, c_path.to_string_lossy())),
Some(format!("{msg}: {}", c_path.to_string_lossy())),
);
}
ffi::sqlite3_close(db);
@@ -325,7 +325,7 @@ impl InnerConnection {
1 => Ok(true),
-1 => Err(Error::SqliteFailure(
ffi::Error::new(ffi::SQLITE_MISUSE),
Some(format!("{:?} is not the name of a database", db_name)),
Some(format!("{db_name:?} is not the name of a database")),
)),
_ => Err(error_from_sqlite_code(
r,
@@ -351,7 +351,7 @@ impl InnerConnection {
2 => Ok(super::transaction::TransactionState::Write),
-1 => Err(Error::SqliteFailure(
ffi::Error::new(ffi::SQLITE_MISUSE),
Some(format!("{:?} is not the name of a valid schema", db_name)),
Some(format!("{db_name:?} is not the name of a valid schema")),
)),
_ => Err(error_from_sqlite_code(
r,
@@ -375,7 +375,7 @@ impl Drop for InnerConnection {
if let Err(e) = self.close() {
if panicking() {
eprintln!("Error while closing SQLite connection: {:?}", e);
eprintln!("Error while closing SQLite connection: {e:?}");
} else {
panic!("Error while closing SQLite connection: {:?}", e);
}

View File

@@ -1616,7 +1616,7 @@ mod test {
db.execute_batch("CREATE TABLE foo(x INTEGER);")?;
let err = db.prepare("SELECT * FROM does_not_exist").unwrap_err();
assert!(format!("{}", err).contains("does_not_exist"));
assert!(format!("{err}").contains("does_not_exist"));
Ok(())
}
@@ -1669,7 +1669,7 @@ mod test {
let query = "SELECT 12345";
let stmt = db.prepare(query)?;
assert!(format!("{:?}", stmt).contains(query));
assert!(format!("{stmt:?}").contains(query));
Ok(())
}
@@ -1703,7 +1703,7 @@ mod test {
let minor = (n % 1_000_000) / 1_000;
let patch = n % 1_000;
assert!(version().contains(&format!("{}.{}.{}", major, minor, patch)));
assert!(version().contains(&format!("{major}.{minor}.{patch}")));
}
#[test]
@@ -1810,7 +1810,7 @@ mod test {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
match *self {
CustomError::SomeError => write!(f, "my custom error"),
CustomError::Sqlite(ref se) => write!(f, "my custom error: {}", se),
CustomError::Sqlite(ref se) => write!(f, "my custom error: {se}"),
}
}
}

View File

@@ -37,7 +37,7 @@ impl Sql {
} else {
Err(Error::SqliteFailure(
ffi::Error::new(ffi::SQLITE_MISUSE),
Some(format!("Invalid keyword \"{}\"", keyword)),
Some(format!("Invalid keyword \"{keyword}\"")),
))
}
}
@@ -67,14 +67,14 @@ impl Sql {
ToSqlOutput::ZeroBlob(_) => {
return Err(Error::SqliteFailure(
ffi::Error::new(ffi::SQLITE_MISUSE),
Some(format!("Unsupported value \"{:?}\"", value)),
Some(format!("Unsupported value \"{value:?}\"")),
));
}
#[cfg(feature = "array")]
ToSqlOutput::Array(_) => {
return Err(Error::SqliteFailure(
ffi::Error::new(ffi::SQLITE_MISUSE),
Some(format!("Unsupported value \"{:?}\"", value)),
Some(format!("Unsupported value \"{value:?}\"")),
));
}
};
@@ -92,7 +92,7 @@ impl Sql {
_ => {
return Err(Error::SqliteFailure(
ffi::Error::new(ffi::SQLITE_MISUSE),
Some(format!("Unsupported value \"{:?}\"", value)),
Some(format!("Unsupported value \"{value:?}\"")),
));
}
};

View File

@@ -255,7 +255,7 @@ impl Savepoint<'_> {
name: T,
) -> Result<Savepoint<'_>> {
let name = name.into();
conn.execute_batch(&format!("SAVEPOINT {}", name))
conn.execute_batch(&format!("SAVEPOINT {name}"))
.map(|_| Savepoint {
conn,
name,
@@ -267,7 +267,7 @@ impl Savepoint<'_> {
#[inline]
fn with_depth(conn: &Connection, depth: u32) -> Result<Savepoint<'_>> {
let name = format!("_rusqlite_sp_{}", depth);
let name = format!("_rusqlite_sp_{depth}");
Savepoint::with_depth_and_name(conn, depth, name)
}

View File

@@ -52,7 +52,7 @@ impl fmt::Display for FromSqlError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
FromSqlError::InvalidType => write!(f, "Invalid type"),
FromSqlError::OutOfRange(i) => write!(f, "Value {} out of range", i),
FromSqlError::OutOfRange(i) => write!(f, "Value {i} out of range"),
FromSqlError::InvalidBlobSize {
expected_size,
blob_size,

View File

@@ -212,7 +212,7 @@ mod test {
let mut v = vec![];
for i in 0..1000 {
v.push(SqliteMallocString::from_str(&i.to_string()).into_raw());
v.push(SqliteMallocString::from_str(&format!("abc {} 😀", i)).into_raw());
v.push(SqliteMallocString::from_str(&format!("abc {i} 😀")).into_raw());
}
unsafe {
for (i, s) in v.chunks_mut(2).enumerate() {
@@ -224,7 +224,7 @@ mod test {
);
assert_eq!(
std::ffi::CStr::from_ptr(s1).to_str().unwrap(),
&format!("abc {} 😀", i)
&format!("abc {i} 😀")
);
let _ = SqliteMallocString::from_raw(s0).unwrap();
let _ = SqliteMallocString::from_raw(s1).unwrap();

View File

@@ -208,13 +208,13 @@ unsafe impl<'vtab> VTab<'vtab> for CsvTab {
let mut record = csv::ByteRecord::new();
if reader.read_byte_record(&mut record)? {
for (i, _) in record.iter().enumerate() {
cols.push(format!("c{}", i));
cols.push(format!("c{i}"));
}
}
}
} else if let Some(n_col) = n_col {
for i in 0..n_col {
cols.push(format!("c{}", i));
cols.push(format!("c{i}"));
}
}

View File

@@ -499,7 +499,7 @@ impl IndexInfo {
if collation.is_null() {
return Err(Error::SqliteFailure(
ffi::Error::new(ffi::SQLITE_MISUSE),
Some(format!("{} is out of range", constraint_idx)),
Some(format!("{constraint_idx} is out of range")),
));
}
Ok(unsafe { CStr::from_ptr(collation) }.to_str()?)
@@ -924,7 +924,7 @@ pub fn parameter(c_slice: &[u8]) -> Result<(&str, &str)> {
return Ok((param, value));
}
}
Err(Error::ModuleError(format!("illegal argument: '{}'", arg)))
Err(Error::ModuleError(format!("illegal argument: '{arg}'")))
}
// FIXME copy/paste from function.rs

View File

@@ -153,7 +153,7 @@ impl<'vtab> CreateVTab<'vtab> for VTabLog {
impl<'vtab> UpdateVTab<'vtab> for VTabLog {
fn delete(&mut self, arg: ValueRef<'_>) -> Result<()> {
println!("VTabLog::delete({}, {:?})", self.i_inst, arg);
println!("VTabLog::delete({}, {arg:?})", self.i_inst);
Ok(())
}
@@ -246,7 +246,7 @@ unsafe impl VTabCursor for VTabLogCursor<'_> {
self.row_id
)
} else {
format!("{}{}", i, self.row_id)
format!("{i}{}", self.row_id)
};
println!(
"VTabLogCursor::column(tab={}, cursor={}, i={}): {}",