Rust: Duplicate crate macros failing to differentiate

Created on 17 Apr 2020  路  7Comments  路  Source: rust-lang/rust

Here is a reproduction:

https://github.com/LucioFranco/rustc-duplicate-macro-bug/

I've added comments on how to trigger the bug. But it looks like if we have one crate but two versions imported into the same project. Aka using cargo's rename feature, then rust picks up that if we use one of the macros that the other one even if its from a different version is the same. Commenting out the tower01 assert_request_eq allows the second one to compile properly. If its not commented out the tower03 version will fail to compile because it is attempting to use the tower01 version which doesn't await the inner future.

Meta

This happens currently on rustc 1.42.0 (b8cedc004 2020-03-09) but not on a newer nightly cargo 1.44.0-nightly (390e8f245 2020-04-07). So this has probably been fixed but I couldn't find any issue for this specific problem.


A-macros C-bug E-needs-test T-compiler

Most helpful comment

No idea how this happened and I don't remember fixing anything similar.

This look like a serious bug, it would be great to bisect this to find out what made it disappear.
Perhaps it was just masked and not really fixed.

All 7 comments

Since, this has been fixed on nightly, I assume we can close it. I thought I'd open for reference reasons.

Sounds like something @petrochenkov might know about

No idea how this happened and I don't remember fixing anything similar.

This look like a serious bug, it would be great to bisect this to find out what made it disappear.
Perhaps it was just masked and not really fixed.

@rustbot ping bisect

Hey Cleanup Crew ICE-breakers! This bug has been identified as a good
"Cleanup ICE-breaking candidate". In case it's useful, here are some
[instructions] for tackling these sorts of bugs. Maybe take a look?
Thanks! <3

cc @AminArria @chrissimpkins @contrun @DutchGhost @elshize @ethanboxx @h-michael @HallerPatrick @hdhoang @hellow554 @imtsuki @jakevossen5 @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @senden9 @shekohex @sinato @spastorino @turboladen @woshilapin @yerke

bisect-rustc points to 15812785344d913d779d9738fe3cca8de56f71d5, PR #66364

@robjtede
Thanks!

Before #66364 in this line

https://github.com/rust-lang/rust/pull/66364/files#diff-2b18e583c8286c5f266dcc0aea004e91L426

two assert_request_eq macros had the same source_name so the second macro hit the cache inside new_source_file and returned the string for the first macro instead of its own.

So #66364 indeed fixed the issue and not masked it.

The condition for the test is that two library crates should have the same name and should export macros with the same name.
Then any crate using these two macros together will hit the issue.

Was this page helpful?
0 / 5 - 0 ratings