Skip to content

Commit c68b46b

Browse files
authored
Forbid unsafe code (#930)
## Changes - [x] `#![forbid(unsafe_code)]` in all workspace crates. Now that we don't have that weird `PartialEq` impl, we can do this and advertise it.
1 parent 50d2029 commit c68b46b

File tree

9 files changed

+45
-6
lines changed

9 files changed

+45
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Enhancements
1111

12+
* `#![forbid(unsafe_code)]` in all workspace crates.
13+
1214
* Removed unnecessary `'static` bounds from type signatures.
1315

1416
### New features

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ See [examples](https://github.com/SeaQL/sea-query/blob/master/examples) for usag
2424

2525
SeaQuery is the foundation of [SeaORM](https://github.com/SeaQL/sea-orm), an async & dynamic ORM for Rust.
2626

27+
SeaQuery is written in 100% safe Rust. All workspace crates `#![forbid(unsafe_code)]`.
28+
2729
[![GitHub stars](https://img.shields.io/github/stars/SeaQL/sea-query.svg?style=social&label=Star&maxAge=1)](https://github.com/SeaQL/sea-query/stargazers/)
2830
If you like what we do, consider starring, commenting, sharing and contributing!
2931

sea-query-binder/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![forbid(unsafe_code)]
2+
13
//! Driver library for using SeaQuery with SQLx
24
//!
35
//! This library introduces various traits that add methods to the query types from `sea-query`.

sea-query-derive/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![forbid(unsafe_code)]
2+
13
use std::convert::{TryFrom, TryInto};
24

35
use darling::FromMeta;

sea-query-diesel/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![forbid(unsafe_code)]
2+
13
use diesel::backend::Backend;
24
use diesel::result::QueryResult;
35
use sea_query::{DeleteStatement, InsertStatement, SelectStatement, UpdateStatement, WithQuery};

sea-query-postgres/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![forbid(unsafe_code)]
2+
13
use std::error::Error;
24

35
use bytes::BytesMut;

sea-query-rbatis/src/lib.rs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
use rbs::to_value;
1+
#![forbid(unsafe_code)]
2+
23
use rbs::Value as RbValue;
4+
use rbs::to_value;
35
use sea_query::*;
46
pub trait SqlxBinder {
57
fn build_rbs<T: QueryBuilder>(&self, query_builder: T) -> (String, Vec<rbs::Value>);
@@ -79,19 +81,35 @@ fn to_rb_values(values: Values) -> Vec<rbs::Value> {
7981
}
8082
#[cfg(feature = "with-chrono")]
8183
Value::ChronoDateTime(t) => {
82-
args.push(Value::ChronoDateTime(t).chrono_as_naive_utc_in_string().to());
84+
args.push(
85+
Value::ChronoDateTime(t)
86+
.chrono_as_naive_utc_in_string()
87+
.to(),
88+
);
8389
}
8490
#[cfg(feature = "with-chrono")]
8591
Value::ChronoDateTimeUtc(t) => {
86-
args.push(Value::ChronoDateTimeUtc(t).chrono_as_naive_utc_in_string().to());
92+
args.push(
93+
Value::ChronoDateTimeUtc(t)
94+
.chrono_as_naive_utc_in_string()
95+
.to(),
96+
);
8797
}
8898
#[cfg(feature = "with-chrono")]
8999
Value::ChronoDateTimeLocal(t) => {
90-
args.push(Value::ChronoDateTimeLocal(t).chrono_as_naive_utc_in_string().to());
100+
args.push(
101+
Value::ChronoDateTimeLocal(t)
102+
.chrono_as_naive_utc_in_string()
103+
.to(),
104+
);
91105
}
92106
#[cfg(feature = "with-chrono")]
93107
Value::ChronoDateTimeWithTimeZone(t) => {
94-
args.push(Value::ChronoDateTimeWithTimeZone(t).chrono_as_naive_utc_in_string().to());
108+
args.push(
109+
Value::ChronoDateTimeWithTimeZone(t)
110+
.chrono_as_naive_utc_in_string()
111+
.to(),
112+
);
95113
}
96114
#[cfg(feature = "with-time")]
97115
Value::TimeDate(t) => {
@@ -107,7 +125,11 @@ fn to_rb_values(values: Values) -> Vec<rbs::Value> {
107125
}
108126
#[cfg(feature = "with-time")]
109127
Value::TimeDateTimeWithTimeZone(t) => {
110-
args.push(Value::TimeDateTimeWithTimeZone(t).time_as_naive_utc_in_string().to());
128+
args.push(
129+
Value::TimeDateTimeWithTimeZone(t)
130+
.time_as_naive_utc_in_string()
131+
.to(),
132+
);
111133
}
112134
#[cfg(feature = "with-uuid")]
113135
Value::Uuid(uuid) => {

sea-query-rusqlite/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![forbid(unsafe_code)]
2+
13
use rusqlite::{
24
Result, ToSql,
35
types::{Null, ToSqlOutput},

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![cfg_attr(docsrs, feature(doc_cfg))]
22
#![deny(missing_debug_implementations)]
3+
#![forbid(unsafe_code)]
34

45
//! <div align="center">
56
//!
@@ -25,6 +26,8 @@
2526
//! [postgres](https://crates.io/crates/postgres) and [rusqlite](https://crates.io/crates/rusqlite).
2627
//! See [examples](https://github.com/SeaQL/sea-query/blob/master/examples) for usage.
2728
//!
29+
//! SeaQuery is written in 100% safe Rust. All workspace crates `#![forbid(unsafe_code)]`.
30+
//!
2831
//! SeaQuery is the foundation of [SeaORM](https://github.com/SeaQL/sea-orm), an async & dynamic ORM for Rust.
2932
//!
3033
//! [![GitHub stars](https://img.shields.io/github/stars/SeaQL/sea-query.svg?style=social&label=Star&maxAge=1)](https://github.com/SeaQL/sea-query/stargazers/)

0 commit comments

Comments
 (0)