diff --git a/sqlx-core/src/cursor.rs b/sqlx-core/src/cursor.rs index d98ccb69..95fb41ec 100644 --- a/sqlx-core/src/cursor.rs +++ b/sqlx-core/src/cursor.rs @@ -39,6 +39,7 @@ use crate::row::HasRow; /// /// [`Executor::fetch`]: crate::executor::Executor::fetch /// [`Query::fetch`]: crate::query::Query::fetch +#[must_use = "cursor must have `.next()` called to execute query"] pub trait Cursor<'c, 'q> where Self: Send + Unpin + private::Sealed, diff --git a/sqlx-core/src/query.rs b/sqlx-core/src/query.rs index 2eb2527d..09f05f39 100644 --- a/sqlx-core/src/query.rs +++ b/sqlx-core/src/query.rs @@ -14,6 +14,7 @@ use crate::row::HasRow; use crate::types::Type; /// Raw SQL query with bind parameters. Returned by [`query`][crate::query::query]. +#[must_use = "query must be executed to affect database"] pub struct Query<'q, DB> where DB: Database, @@ -31,6 +32,7 @@ where /// /// [Query::bind] is also omitted; stylistically we recommend placing your `.bind()` calls /// before `.try_map()` anyway. +#[must_use = "query must be executed to affect database"] pub struct Map<'q, DB, F> where DB: Database, diff --git a/sqlx-core/src/query_as.rs b/sqlx-core/src/query_as.rs index 4e86a7ec..3aed1d5c 100644 --- a/sqlx-core/src/query_as.rs +++ b/sqlx-core/src/query_as.rs @@ -9,6 +9,7 @@ use crate::types::Type; /// Raw SQL query with bind parameters, mapped to a concrete type /// using [`FromRow`](trait.FromRow.html). Returned /// by [`query_as`](fn.query_as.html). +#[must_use = "query must be executed to affect database"] pub struct QueryAs<'q, DB, O> where DB: Database, diff --git a/sqlx-core/src/transaction.rs b/sqlx-core/src/transaction.rs index 84f3286a..30002d21 100644 --- a/sqlx-core/src/transaction.rs +++ b/sqlx-core/src/transaction.rs @@ -33,6 +33,7 @@ use crate::runtime::spawn; /// [`rollback`]: #method.rollback // Transaction> // Transaction +#[must_use = "transaction rolls back if not explicitly `.commit()`ed"] pub struct Transaction where C: Connection,