Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 3.0.1 #49

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "proc-macro-crate"
version = "3.0.0"
version = "3.1.0"
authors = ["Bastian Köcher <[email protected]>"]
edition = "2021"
categories = ["development-tools::procedural-macro-helpers"]
Expand Down
19 changes: 16 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,12 @@ pub fn crate_name(orig_name: &str) -> Result<FoundCrate, Error> {
&cache_entry.crate_names
},
btree_map::Entry::Vacant(entry) => {
let workspace_manifest_path = workspace_manifest_path(&manifest_path)?;
// If `workspace_manifest_path` returns `None`, we are probably in a vendored deps
// folder and cargo complaining that we have some package inside a workspace, that isn't
// part of the workspace. In this case we just use the `manifest_path` as the
// `workspace_manifest_path`.
let workspace_manifest_path =
workspace_manifest_path(&manifest_path)?.unwrap_or_else(|| manifest_path.clone());
let workspace_manifest_ts = cargo_toml_timestamp(&workspace_manifest_path)?;

let cache_entry = entry.insert(read_cargo_toml(
Expand All @@ -235,7 +240,7 @@ pub fn crate_name(orig_name: &str) -> Result<FoundCrate, Error> {
.clone())
}

fn workspace_manifest_path(cargo_toml_manifest: &Path) -> Result<PathBuf, Error> {
fn workspace_manifest_path(cargo_toml_manifest: &Path) -> Result<Option<PathBuf>, Error> {
let stdout = Command::new(env::var("CARGO").map_err(|_| Error::CargoEnvVariableNotSet)?)
.arg("locate-project")
.args(&["--workspace", "--message-format=plain"])
Expand All @@ -246,7 +251,15 @@ fn workspace_manifest_path(cargo_toml_manifest: &Path) -> Result<PathBuf, Error>

String::from_utf8(stdout)
.map_err(|_| Error::FailedGettingWorkspaceManifestPath)
.map(|s| s.trim().into())
.map(|s| {
let path = s.trim();

if path.is_empty() {
None
} else {
Some(path.into())
}
})
}

fn cargo_toml_timestamp(manifest_path: &Path) -> Result<SystemTime, Error> {
Expand Down
Loading