From 46c36a00cd1119b16015f2ecb32ea0e82f404baa Mon Sep 17 00:00:00 2001 From: Johannes Hupe Date: Sat, 9 Mar 2024 18:26:11 +0100 Subject: [PATCH] fix: pass path with impl AsRef instead of Pathbuf. when the sqlx_macros_unstable cfg is activated path would have moved otherwise. --- sqlx-core/src/migrate/source.rs | 3 ++- sqlx-macros-core/src/migrate.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sqlx-core/src/migrate/source.rs b/sqlx-core/src/migrate/source.rs index b5e4b816c7..9f03f0055b 100644 --- a/sqlx-core/src/migrate/source.rs +++ b/sqlx-core/src/migrate/source.rs @@ -54,7 +54,8 @@ pub struct ResolveError { // FIXME: paths should just be part of `Migration` but we can't add a field backwards compatibly // since it's `#[non_exhaustive]`. -pub fn resolve_blocking(path: PathBuf) -> Result, ResolveError> { +pub fn resolve_blocking(path: impl AsRef) -> Result, ResolveError> { + let path = path.as_ref().to_path_buf(); let mut s = fs::read_dir(&path).map_err(|e| ResolveError { message: format!("error reading migration directory {}: {e}", path.display()), source: Some(e), diff --git a/sqlx-macros-core/src/migrate.rs b/sqlx-macros-core/src/migrate.rs index ff0eb9f937..eace5c2e61 100644 --- a/sqlx-macros-core/src/migrate.rs +++ b/sqlx-macros-core/src/migrate.rs @@ -101,7 +101,7 @@ pub(crate) fn expand_migrator(path: &Path) -> crate::Result { })?; // Use the same code path to resolve migrations at compile time and runtime. - let migrations = sqlx_core::migrate::resolve_blocking(path)? + let migrations = sqlx_core::migrate::resolve_blocking(&path)? .into_iter() .map(|(migration, path)| QuoteMigration { migration, path });