Skip to content

Commit

Permalink
Make clippy behave slightly more reasonably
Browse files Browse the repository at this point in the history
  • Loading branch information
Thom Chiovoloni authored and thomcc committed Apr 16, 2020
1 parent 418ef10 commit 1207a7c
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/util/sqlite_string.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
// This is used when either vtab or modern-sqlite is on. Different methods are
// used in each feature. Avoid having to track this for each function. We will
// still warn for anything that's not used by either, though.
#![cfg_attr(
not(all(feature = "vtab", feature = "modern-sqlite")),
allow(dead_code)
)]
use crate::ffi;
use std::marker::PhantomData;
use std::os::raw::{c_char, c_int};
Expand All @@ -8,16 +15,16 @@ use std::ptr::NonNull;
/// on it. If constructed from a rust string, `sqlite3_malloc` is used.
///
/// It has identical representation to a nonnull `*mut c_char`, so you can use
/// it transparently as one. It's nonnull, so Option<SqliteMallocString> is a
/// nullable one.
/// it transparently as one. It's nonnull, so Option<SqliteMallocString> can be
/// used for nullable ones (it's still just one pointer).
///
/// Note that this is for Strings we manage that are owned by SQLite, like
/// `sqlite3_extended_sql` results, some error message pointers. Most strings
/// are not this! Misuse is extremely dangerous!
/// Most strings shouldn't use this! Only places where the string needs to be
/// freed with `sqlite3_free`. This includes `sqlite3_extended_sql` results,
/// some error message pointers... Note that misuse is extremely dangerous!
///
/// Note that this is not a lossless interface. Incoming strings with internal
/// Note that this is *not* a lossless interface. Incoming strings with internal
/// NULs are modified, and outgoing strings which are non-UTF8 are modified.
/// This seems unavoidable.
/// This seems unavoidable -- it tries very hard to not panic.
#[repr(transparent)]
pub(crate) struct SqliteMallocString {
ptr: NonNull<c_char>,
Expand Down Expand Up @@ -93,7 +100,7 @@ impl SqliteMallocString {
/// call `handle_alloc_error` which aborts the program after calling a
/// global hook.
///
/// This means it's safe to use in extern "C" functions outside of
/// This means it's safe to use in extern "C" functions even outside of
/// catch_unwind.
pub(crate) fn from_str(s: &str) -> Self {
use std::convert::TryFrom;
Expand Down

0 comments on commit 1207a7c

Please sign in to comment.