Uh oh!
There was an error while loading. Please reload this page.
Stabilize use_extern_macros - #50911
Conversation
rust-highfive
commented
May 20, 2018
r? @cramertj (rust_highfive has picked a reviewer for you, use r? to override) |
petrochenkov
commented
May 20, 2018
r? @kennytm |
petrochenkov
commented
May 20, 2018
@bors try |
bors
commented
May 20, 2018
⌛ Trying commit 66dfde18bfdfe1f9ae1c516e56228c77284a90b5 with merge ea32c49808849674e3d126b5732b2abfba9ed226... |
bors
commented
May 20, 2018
☀️ Test successful - status-travis |
cc @rust-lang/infra Crater run (check only) requested. |
emilyalbini
commented
May 21, 2018
Crater run (check only) started. |
emilyalbini
commented
May 24, 2018
Hi @kennytm (crater requester, PR reviewer)! Crater results are at: http://cargobomb-reports.s3.amazonaws.com/pr-50911/index.html. 'Blacklisted' crates (spurious failures etc) can be found here. If you see any spurious failures not on the list, please make a PR against that file. (interested observers: Crater is a tool for testing the impact of changes on the crates.io ecosystem. You can find out more at the repo if you're curious) |
6 regressions.
Relevant source code in npbot-1.0.0[dependencies]
structopt = "0.2.5"#[macro_use]externcrate quicli;// ...use structopt::StructOpt;use quicli::prelude::*;// ...#[derive(StructOpt)]pub(crate)structOpt{#[structopt(short = "d", long = "debug", help = "only use the local, println!() sink")]debug:bool,#[structopt(long = "verbose", short = "v", parse(from_occurrences))]verbose:u8,// for the SoundTouch source#[structopt(long = "soundtouch-host")]soundtouch_host:Option<String>,// for the last.fm source#[structopt(long = "lastfm-api-key")]lastfm_api_key:Option<String>,#[structopt(long = "lastfm-username")]lastfm_username:Option<String>,}Note the lack of Error log |
petrochenkov
commented
May 24, 2018
I'll look what happens with |
There was a problem hiding this comment.
FIXME: possible_time_travel is now unused
petrochenkov
commented
May 28, 2018
It looks like So the error should be something like "cannot determine resolution for the derive macro However, due to a scary hole in our macro resolution checking such dummy expansions can happen silently without generating any errors. |
petrochenkov
commented
May 29, 2018
Fixed in #51145 |
use_extern_macrosuse_extern_macrospetrochenkov
commented
May 30, 2018
resolve: Some macro resolution refactoring Work towards completing #50911 (comment) The last commit also fixes#53269 by not using `def_id()` on `Def::Err` and also fixes#53512.
resolve: Future proof resolutions for potentially built-in attributes Based on #53778 This is not full "pass all attributes through name resolution", but a more conservative solution. If built-in attribute is ambiguous with any other macro in scope, then an error is reported. TODO: Explain what complications arise with the full solution. cc #50911 (comment)Closes#53531
Feature gate non-builtin attributes in inner attribute position Closes item 3 from #50911 (comment)
resolve: Future proof resolutions for potentially built-in attributes This is not full "pass all attributes through name resolution", but a more conservative solution. If built-in attribute is ambiguous with any other macro in scope, then an error is reported. What complications arise with the full solution - #53913 (comment). cc #50911 (comment) cc #52269Closes#53531
Temporarily prohibit proc macro attributes placed after derives ... and also proc macro attributes used together with `#[test]`/`#[bench]`. Addresses item 6 from #50911 (comment). The end goal is straightforward predictable left-to-right expansion order for attributes. Right now derives are expanded last regardless of their relative ordering with macro attributes and right now it's simpler to temporarily prohibit macro attributes placed after derives than changing the expansion order. I'm not sure whether the new beta is already released or not, but if it's released, then this patch needs to be backported, so the solution needs to be minimal. How to fix broken code (derives): - Move macro attributes above derives. This won't change expansion order, they are expanded before derives anyway. Using attribute macros on same items with `#[test]` and `#[bench]` is prohibited for similar expansion order reasons, but this one is going to be reverted much sooner than restrictions on derives. How to fix broken code (test/bench): - Enable `#![feature(plugin)]` (don't ask why). r? @ghost
softprops
commented
Oct 26, 2018
The 1.30.0 release notes for Where can I find more documentation on this feature? So far I've tried local_inner_macros in two cases where a crate's macros depended on anothers and it didn't work in either case. |
petrochenkov
commented
Oct 26, 2018
@softprops It will be available at https://rust-lang-nursery.github.io/edition-guide/rust-2018/macros/macro-changes.html when merged. |
softprops
commented
Oct 26, 2018
@petrochenkov thanks! I'll take a look and report back if it looks like what I'm trying to do, re-export transitive dependency crates macros` is actually what this new feature supports. |
@petrochenkov l need to do a bit more testing but I worked it out, at least enough to get a fork of rust crowbar to compile. I still need to test a crate that uses that fork before I can call this 👍 'd It may not be clear to new rust users that for foreign macros, you'll also need namespace the macro's path. In my case I just needed to prefix crowbars use of cpython's macros with |
softprops
commented
Oct 26, 2018
found a potential bug but I'm not sure if its by design when experimenting with the with externcrate crowbar;
crowbar::lambda!(...)however with externcrate crowbar;
crowbar::lambda!(...)interestingly though I can do the following with externcrate crowbar;use crowbar::lambda;lambda!(...)this feels a bit inconsistent in the way the newer system attempts to line up with what you can do with path references for non macro items. |
@softprops This way the first iteration |
softprops
commented
Oct 26, 2018
@petrochenkov 100%. that was it. thanks! |
Signed-off-by: JmPotato <ghzpotato@gmail.com> ### What problem does this PR solve? Import macros from other crates with the `use` syntax. ### What is changed and how it works? rust-lang/rust#50911 ### Check List <!--REMOVE the items that are not applicable--> Tests <!-- At least one of them must be included. --> - Unit test - Integration test ### Release note <!-- bugfixes or new feature need a release note --> * No release note.
Closes#35896