From 5edd2a53f22aa4120f237a8a1516886812ad7201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= Date: Mon, 23 Dec 2024 23:01:52 +0100 Subject: [PATCH] fix: take stdin --- diesel_cli/src/print_schema.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/diesel_cli/src/print_schema.rs b/diesel_cli/src/print_schema.rs index 7dd37bc9248e..6882bf49c002 100644 --- a/diesel_cli/src/print_schema.rs +++ b/diesel_cli/src/print_schema.rs @@ -5,7 +5,7 @@ use crate::infer_schema_internals::*; use serde::{Deserialize, Serialize}; use std::collections::HashSet; use std::fmt::{self, Display, Formatter, Write}; -use std::io::{Read, Write as IoWrite}; +use std::io::Write as IoWrite; use std::process; const SCHEMA_HEADER: &str = "// @generated automatically by Diesel CLI.\n"; @@ -306,7 +306,7 @@ pub fn output_schema( pub fn format_schema(schema: &str) -> Result { use crate::errors::Error; // Inject schema through rustfmt stdin and get the formatted output - let child = process::Command::new("rustfmt") + let mut child = process::Command::new("rustfmt") .stdin(process::Stdio::piped()) .stdout(process::Stdio::piped()) .stderr(process::Stdio::piped()) @@ -316,6 +316,7 @@ pub fn format_schema(schema: &str) -> Result { { let mut stdin = child .stdin + .take() .expect("we can always get the stdin from the child process"); stdin.write_all(schema.as_bytes()).map_err(|err| {