Skip to content

Commit

Permalink
chore: update toolchain and fix lint errors (#5022)
Browse files Browse the repository at this point in the history
* Update nix flake

* Update Rust to 1.81.0

* Fix compiler warning for unused errors

We keep these around for documentation purposes.

* Fix clippy warnings

* Update wasm-bindgen to match the version in Nix

* Update WASM toolchain to nightly-2024-09-01 (corresponds to Rust 1.82.0)

* Fix deprecation warning on Rust 1.82

* Update rust overlay in nix

* Update Rust to 1.82.0

* Fix clippy warnings
  • Loading branch information
aqrln authored Oct 18, 2024
1 parent b9903dc commit 155af62
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/include/rust-wasm-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ runs:
shell: bash
run: |
cargo binstall -y \
[email protected].92 \
[email protected].93 \
[email protected]
- name: Install bc
Expand Down
21 changes: 11 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ serde_repr = { version = "0.1.17" }
serde-wasm-bindgen = { version = "0.5" }
tracing = { version = "0.1" }
tsify = { version = "0.4.5" }
wasm-bindgen = { version = "0.2.92" }
wasm-bindgen = { version = "0.2.93" }
wasm-bindgen-futures = { version = "0.4" }
wasm-rs-dbg = { version = "0.1.2", default-features = false, features = ["console-error"] }
wasm-bindgen-test = { version = "0.3.0" }
Expand Down
29 changes: 12 additions & 17 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
inputs = {
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
Expand Down
6 changes: 3 additions & 3 deletions libs/user-facing-errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ impl Error {
}
}

/// Construct a new UnknownError from a `PanicInfo` in a panic hook. `UnknownError`s created
/// with this constructor will have a proper, useful backtrace.
pub fn new_in_panic_hook(panic_info: &std::panic::PanicInfo<'_>) -> Self {
/// Construct a new UnknownError from a [`PanicHookInfo`] in a panic hook. [`UnknownError`]s
/// created with this constructor will have a proper, useful backtrace.
pub fn new_in_panic_hook(panic_info: &std::panic::PanicHookInfo<'_>) -> Self {
let message = panic_info
.payload()
.downcast_ref::<&str>()
Expand Down
6 changes: 5 additions & 1 deletion libs/user-facing-errors/src/schema_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,29 @@ pub struct DatabaseCreationFailed {
code = "P3001",
message = "Migration possible with destructive changes and possible data loss: {destructive_details}"
)]
#[allow(dead_code)]
pub struct DestructiveMigrationDetected {
pub destructive_details: String,
}

/// No longer used.
#[derive(Debug, UserFacingError, Serialize)]
#[user_facing(
code = "P3002",
message = "The attempted migration was rolled back: {database_error}"
)]
#[allow(dead_code)]
struct MigrationRollback {
pub database_error: String,
}

// No longer used.
/// No longer used.
#[derive(Debug, SimpleUserFacingError)]
#[user_facing(
code = "P3003",
message = "The format of migrations changed, the saved migrations are no longer valid. To solve this problem, please follow the steps at: https://pris.ly/d/migrate"
)]
#[allow(dead_code)]
pub struct DatabaseMigrationFormatChanged;

#[derive(Debug, UserFacingError, Serialize)]
Expand Down
9 changes: 3 additions & 6 deletions query-engine/connector-test-kit-rs/qe-setup/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,11 @@ fn parse_configuration(datamodel: &str) -> ConnectorResult<(Datasource, String,
/// (rather than just the Schema Engine), this function will call [`ExternalInitializer::init_with_migration`].
/// Otherwise, it will call [`ExternalInitializer::init`], and then proceed with the standard
/// setup based on the Schema Engine.
pub async fn setup_external<'a, EI>(
pub async fn setup_external<'a>(
driver_adapter: DriverAdapter,
initializer: EI,
initializer: impl ExternalInitializer<'a>,
db_schemas: &[&str],
) -> ConnectorResult<InitResult>
where
EI: ExternalInitializer<'a> + ?Sized,
{
) -> ConnectorResult<InitResult> {
let prisma_schema = initializer.datamodel();
let (source, url, _preview_features) = parse_configuration(prisma_schema)?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ fn to_aggregation_rows(

for field in fields {
let meta = selection_meta.get(field.db_name()).unwrap();
let bson = doc.remove(&format!("count_{}", field.db_name())).unwrap();
let bson = doc.remove(format!("count_{}", field.db_name())).unwrap();
let field_val = value_from_bson(bson, meta)?;

row.push(AggregationResult::Count(Some(field.clone()), field_val));
Expand All @@ -117,7 +117,7 @@ fn to_aggregation_rows(
AggregationSelection::Average(fields) => {
for field in fields {
let meta = selection_meta.get(field.db_name()).unwrap();
let bson = doc.remove(&format!("avg_{}", field.db_name())).unwrap();
let bson = doc.remove(format!("avg_{}", field.db_name())).unwrap();
let field_val = value_from_bson(bson, meta)?;

row.push(AggregationResult::Average(field.clone(), field_val));
Expand All @@ -126,7 +126,7 @@ fn to_aggregation_rows(
AggregationSelection::Sum(fields) => {
for field in fields {
let meta = selection_meta.get(field.db_name()).unwrap();
let bson = doc.remove(&format!("sum_{}", field.db_name())).unwrap();
let bson = doc.remove(format!("sum_{}", field.db_name())).unwrap();
let field_val = value_from_bson(bson, meta)?;

row.push(AggregationResult::Sum(field.clone(), field_val));
Expand All @@ -135,7 +135,7 @@ fn to_aggregation_rows(
AggregationSelection::Min(fields) => {
for field in fields {
let meta = selection_meta.get(field.db_name()).unwrap();
let bson = doc.remove(&format!("min_{}", field.db_name())).unwrap();
let bson = doc.remove(format!("min_{}", field.db_name())).unwrap();
let field_val = value_from_bson(bson, meta)?;

row.push(AggregationResult::Min(field.clone(), field_val));
Expand All @@ -144,7 +144,7 @@ fn to_aggregation_rows(
AggregationSelection::Max(fields) => {
for field in fields {
let meta = selection_meta.get(field.db_name()).unwrap();
let bson = doc.remove(&format!("max_{}", field.db_name())).unwrap();
let bson = doc.remove(format!("max_{}", field.db_name())).unwrap();
let field_val = value_from_bson(bson, meta)?;

row.push(AggregationResult::Max(field.clone(), field_val));
Expand Down
2 changes: 1 addition & 1 deletion query-engine/query-engine-wasm/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "nightly-2024-05-25"
channel = "nightly-2024-09-01"
components = ["clippy", "rustfmt", "rust-src"]
targets = [
"wasm32-unknown-unknown",
Expand Down
5 changes: 1 addition & 4 deletions query-engine/query-engine/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,7 @@ async fn metrics_handler(cx: Arc<PrismaContext>, req: Request<Body>) -> Result<R
// block and buffer request until the request has completed
let full_body = hyper::body::to_bytes(body_start).await?;

let global_labels: HashMap<String, String> = match serde_json::from_slice(full_body.as_ref()) {
Ok(map) => map,
Err(_e) => HashMap::new(),
};
let global_labels: HashMap<String, String> = serde_json::from_slice(full_body.as_ref()).unwrap_or_default();

let response = if requested_json {
let metrics = cx.metrics.to_json(global_labels);
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "1.80.1"
channel = "1.82.0"
components = ["clippy", "rustfmt", "rust-src"]
targets = [
# WASM target for serverless and edge environments.
Expand Down
20 changes: 8 additions & 12 deletions schema-engine/sql-migration-tests/src/assertions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,11 @@ impl SchemaAssertion {
}

fn print_context(&self) {
match &self.context {
Some(context) => println!("Test failure with context <{}>", context.red()),
None => {}
if let Some(context) = &self.context {
println!("Test failure with context <{}>", context.red())
}
match &self.description {
Some(description) => println!("{}: {}", "Description".bold(), description.italic()),
None => {}
if let Some(description) = &self.description {
println!("{}: {}", "Description".bold(), description.italic())
}
}

Expand Down Expand Up @@ -325,13 +323,11 @@ pub struct TableAssertion<'a> {

impl<'a> TableAssertion<'a> {
fn print_context(&self) {
match &self.context {
Some(context) => println!("Test failure with context <{}>", context.red()),
None => {}
if let Some(context) = &self.context {
println!("Test failure with context <{}>", context.red())
}
match &self.description {
Some(description) => println!("{}: {}", "Description".bold(), description.italic()),
None => {}
if let Some(description) = &self.description {
println!("{}: {}", "Description".bold(), description.italic())
}
}

Expand Down
10 changes: 4 additions & 6 deletions schema-engine/sql-migration-tests/src/commands/schema_push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,11 @@ impl SchemaPushAssertion {
}

pub fn print_context(&self) {
match &self.context {
Some(context) => println!("Test failure with context <{}>", context.red()),
None => {}
if let Some(context) = &self.context {
println!("Test failure with context <{}>", context.red())
}
match &self.description {
Some(description) => println!("{}: {}", "Description".bold(), description.italic()),
None => {}
if let Some(description) = &self.description {
println!("{}: {}", "Description".bold(), description.italic())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ fn mssql_apply_migrations_error_output(api: TestApi) {
.split_terminator(" 0: ")
.next()
.unwrap()
.trim_end_matches(|c| c == '\n' || c == ' ');
.trim_end_matches(['\n', ' ']);

expectation.assert_eq(first_segment)
}
Expand Down

0 comments on commit 155af62

Please sign in to comment.