Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for `macro_reexport` feature #29638
Comments
aturon
added
T-lang
B-unstable
labels
Nov 5, 2015
This comment has been minimized.
This comment has been minimized.
|
Any opinions on whether this should be stabilized? I would love to see it stabilized. Currently, a crate A which exports a macro whose expansion references a macro from crate B cannot express that dependency: it is pushed onto the user of crate A, even though otherwise they wouldn't have to know about the implementation detail. If crate A could reexport the macro from crate B, it would be a better situation. |
This comment has been minimized.
This comment has been minimized.
|
cc @rust-lang/lang, particularly @nrc. In the long run this will be able to go through the normal Nominating for discussion in next lang meeting. |
aturon
added
the
I-nominated
label
Mar 5, 2016
nikomatsakis
added
the
final-comment-period
label
Mar 11, 2016
This comment has been minimized.
This comment has been minimized.
|
Hear ye, hear ye. This issue is hereby promoted to final comment period. The discussion is whether to stabilize this feature beginning in the next release cycle. |
This comment has been minimized.
This comment has been minimized.
|
I think we should stabilise. As @aturon says, eventually it should be replaced, but having it in the short/medium term is a big win. |
This comment has been minimized.
This comment has been minimized.
|
Some serious bugs and downsides of
I personally see this as a half-baked feature that was just nice to reduce duplication in std/core, it doesn't seem like it fits the normal high standard we might have for language features. There's certainly an argument that I'd be fine deprecating and removing this while just copying the macros between core/std to have the same source. |
This comment has been minimized.
This comment has been minimized.
|
The first bug seems possible to fix -- if the mangled source of a macro is stored in crate metadata, the unmangled source can be too. I agree the second one is a downside, but it can be mitigated by |
This comment has been minimized.
This comment has been minimized.
|
We should fix both the bugs that @alexcrichton points out before stabilising (I was not aware of them). Are there issues filed for those? |
This comment has been minimized.
This comment has been minimized.
|
Unfortunately not that I know of :( Sorry I meant to write these thoughts down when the initial tracking issue was made, but I guess I forgot... |
This comment has been minimized.
This comment has been minimized.
|
The mangled-source issue is #20923. |
This comment has been minimized.
This comment has been minimized.
|
Making Also, if |
aturon
removed
the
I-nominated
label
Mar 17, 2016
nikomatsakis
removed
the
final-comment-period
label
Apr 22, 2016
This comment has been minimized.
This comment has been minimized.
|
After discussion in the @rust-lang/lang meeting, we decided not to stabilize this feature just yet (and hopefully not ever). The key points of discussion already appear in this thread:
|
This comment has been minimized.
This comment has been minimized.
|
I agree that it's only practical for a facade pattern, but sometimes that's I'm confused by your last bullet. Can you elaborate on how Cargo features
|
This comment has been minimized.
This comment has been minimized.
|
On Sat, Apr 23, 2016 at 08:00:26AM -0700, Alex Burka wrote:
I meant that cargo features can be used in preference to the facade pattern. |
This comment has been minimized.
This comment has been minimized.
|
Sorry for being thick... I just don't see what the relation is between On Wed, Apr 27, 2016 at 1:55 PM, Niko Matsakis notifications@github.com
|
This comment has been minimized.
This comment has been minimized.
|
It can also be useful to re-export things from crates maintained by other people / in other repositories. |
This comment has been minimized.
This comment has been minimized.
|
Since 1.15.0, extern crate somelib;
pub use somelib::*;As far as I’m concerned this removes the need for this feature. Test case: set -e
cargo new aa
cargo new bb
cargo new cc
echo 'bb = {path = "../bb"}' >> aa/Cargo.toml
echo 'cc = {path = "../cc"}' >> bb/Cargo.toml
echo '#[macro_use] extern crate bb;' > aa/src/lib.rs
echo '#[test] fn a() { assert_eq!(c!(), 42) }' >> aa/src/lib.rs
echo '#[macro_use] extern crate cc;' > bb/src/lib.rs
echo 'pub use cc::*;' >> bb/src/lib.rs
echo '#[macro_export] macro_rules! c { () => { 42 } }' > cc/src/lib.rs
(cd aa && cargo +1.15.0 test)
rm -r aa bb cc |
This comment has been minimized.
This comment has been minimized.
|
I'm not sure whether that is a full replacement of the feature, as you can refine by doing |
This comment has been minimized.
This comment has been minimized.
Isn’t that a bug to fix? |
This comment has been minimized.
This comment has been minimized.
lol apparently the reverse is true, the glob use feature is a bug, and should be feature gated. Also cc #35896 |
This comment has been minimized.
This comment has been minimized.
|
Maybe this should have been feature-gated but it hasn’t been for three release cycles. |
Mark-Simulacrum
added
the
C-tracking-issue
label
Jul 22, 2017
This comment has been minimized.
This comment has been minimized.
|
Is this the tracking issue for use_extern_macros or is there a separate tracking issue for that? How are these two features different / related? |
This comment has been minimized.
This comment has been minimized.
|
@withoutboats the two features are different. I'd say they both implement the same thing but in different ways. macro_reexport: #![crate_type = "dylib"]
#![feature(macro_reexport)]
#[macro_reexport(reexported)]
#[macro_use] #[no_link]
extern crate macro_reexport_1;use_extern_macros: #![feature(use_extern_macros)]
extern crate two_macros;
::two_macros::macro_one!();
two_macros::macro_one!();
mod foo { pub use two_macros::macro_one as bar; }The tracking issue for I would guess that the intention is that |
This comment has been minimized.
This comment has been minimized.
|
@jseyfried From the discussion here and in #40768 (comment) it sounds like you think the feature is ready and are in favor of stabilizing. Is that correct? |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@cramertj What I am in favor of stabilizing is extern crate macros;
pub use macros::{foo, bar};
|
This comment has been minimized.
This comment has been minimized.
|
@jseyfried As far as I can tell, there is not a separate tracking issue for |
aturon commentedNov 5, 2015
Tracking for stabilization of
#[macro_reexport].