tests/run-make-cargo/same-crate-name-and-macro-name: New regression test

This commit is contained in:
Martin Nordholts
2025-12-17 11:20:44 +01:00
parent ec6f62244c
commit 60b616d338
7 changed files with 54 additions and 0 deletions
@@ -0,0 +1,10 @@
[package]
name = "consumer"
version = "0.1.0"
[dependencies]
mylib_v1 = { path = "../mylib_v1", package = "mylib" }
mylib_v2 = { path = "../mylib_v2", package = "mylib" }
# Avoid interference with root workspace when casually testing
[workspace]
@@ -0,0 +1,7 @@
fn main() {
let v1 = mylib_v1::my_macro!();
assert_eq!(v1, "version 1");
let v2 = mylib_v2::my_macro!();
assert_eq!(v2, "version 2");
}
@@ -0,0 +1,6 @@
[package]
name = "mylib"
version = "1.0.0"
# Avoid interference with root workspace when casually testing
[workspace]
@@ -0,0 +1,6 @@
#[macro_export]
macro_rules! my_macro {
() => {
"version 1"
};
}
@@ -0,0 +1,6 @@
[package]
name = "mylib"
version = "2.0.0"
# Avoid interference with root workspace when casually testing
[workspace]
@@ -0,0 +1,6 @@
#[macro_export]
macro_rules! my_macro {
() => {
"version 2"
};
}
@@ -0,0 +1,13 @@
//! Regression test for
//! <https://github.com/rust-lang/rust/issues/71259#issuecomment-615879925>
//! (that particular comment describes the issue well).
//!
//! We test that two library crates with the same name can export macros with
//! the same name without causing interference when both are used in another
//! crate.
use run_make_support::cargo;
fn main() {
cargo().current_dir("consumer").arg("run").run();
}