Skip to content

Commit 60b616d

Browse files
committed
tests/run-make-cargo/same-crate-name-and-macro-name: New regression test
1 parent ec6f622 commit 60b616d

File tree

7 files changed

+54
-0
lines changed

7 files changed

+54
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "consumer"
3+
version = "0.1.0"
4+
5+
[dependencies]
6+
mylib_v1 = { path = "../mylib_v1", package = "mylib" }
7+
mylib_v2 = { path = "../mylib_v2", package = "mylib" }
8+
9+
# Avoid interference with root workspace when casually testing
10+
[workspace]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn main() {
2+
let v1 = mylib_v1::my_macro!();
3+
assert_eq!(v1, "version 1");
4+
5+
let v2 = mylib_v2::my_macro!();
6+
assert_eq!(v2, "version 2");
7+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "mylib"
3+
version = "1.0.0"
4+
5+
# Avoid interference with root workspace when casually testing
6+
[workspace]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#[macro_export]
2+
macro_rules! my_macro {
3+
() => {
4+
"version 1"
5+
};
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "mylib"
3+
version = "2.0.0"
4+
5+
# Avoid interference with root workspace when casually testing
6+
[workspace]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#[macro_export]
2+
macro_rules! my_macro {
3+
() => {
4+
"version 2"
5+
};
6+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//! Regression test for
2+
//! <https://github.com/rust-lang/rust/issues/71259#issuecomment-615879925>
3+
//! (that particular comment describes the issue well).
4+
//!
5+
//! We test that two library crates with the same name can export macros with
6+
//! the same name without causing interference when both are used in another
7+
//! crate.
8+
9+
use run_make_support::cargo;
10+
11+
fn main() {
12+
cargo().current_dir("consumer").arg("run").run();
13+
}

0 commit comments

Comments
 (0)