Skip to content

Proc-Macro Dependency with Dependencies #361

@daxpedda

Description

@daxpedda

I noticed that while proc-macro dependencies in dependencies are supported, a direct dependency being a proc-macro fails on finding its dependencies.

Example:

/Cargo.toml:

[workspace]
members = ["a", "b"]

/a/Cargo.toml:

[package]
edition = "2021"
name = "a"
version = "0.0.0"

[lib]
proc-macro = true

[dependencies]
b = { version = "0.0.0", path = "../b" }

[[test]]
harness = false
name = "ui"

/a/tests/ui.rs:

use ui_test::color_eyre::Result;
use ui_test::dependencies::DependencyBuilder;
use ui_test::Config;

fn main() -> Result<()> {
	let mut config = Config::rustc("tests/ui");
	config
		.comment_defaults
		.base()
		.set_custom("dependencies", DependencyBuilder::default());

	ui_test::run_tests(config)
}

/b/Cargo.toml

[package]
edition = "2021"
name = "b"
version = "0.0.0"

This fails with:

thread '<unnamed>' (123) panicked at /.../ui_test-0.30.4/src/dependencies.rs:324:29:
no artifact found for `b`(`path+file:///b#0.0.0`):`
{"reason":"compiler-artifact","package_id":"path+file:///b#0.0.0","manifest_path":"/b/Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"b","src_path":"/b/src/lib.rs","edition":"2021","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["/a/target/ui/0/debug/deps/libb-123.rlib","/a/target/ui/0/debug/deps/libb-123.rmeta"],"executable":null,"fresh":true}
{"reason":"compiler-artifact","package_id":"path+file:///a#0.0.0","manifest_path":"/a/Cargo.toml","target":{"kind":["proc-macro"],"crate_types":["proc-macro"],"name":"a","src_path":"/a/src/lib.rs","edition":"2021","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["/a/target/ui/0/debug/liba.so"],"executable":null,"fresh":false}
{"reason":"build-finished","success":true}

Simply removing proc-macro = true from crate a makes everything work.
Removing the dependency on crate b also makes everything work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions