diesel: Importing Diesel macros (Rust 2018)
In the 2018 edition, #[macro_use] is going away (kinda’), as use works with macros. Unfortunately, Diesel doesn’t seem to play well with that, as a lot of macros are hard to find (e.g. no_arg_sql_function_body), or seem not to work even after being imported (although it’s quite possible that I used a wrong path).
https://www.reddit.com/r/rust/comments/8tbah2/my_problems_with_understanding_rust_edition_2018/e166pdp/ suggests a simple work-around, but that might require a minimum compiler version bump.
#[macro_use] is probably still going to be supported, but it might be worth fixing this.
Related: https://github.com/rust-lang/rust/issues/35896#issuecomment-394553992.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 9
- Comments: 19 (8 by maintainers)
@kamirr It’s my understanding that the contributors’ stance on issues like this is that, if there is an “easy enough” resolution, it should not be prioritized. This is similar with deprecation warnings with the
Queryablederive macro. In my opinion, this does make the project feel less idiomatic and “hacky” compared to e.g.serdewhere you can justuse serde::{Deserialize, Serialize};in the modern way. This crate will come with the caveats of “don’t forget to set this crate attribute and import all of its macros, unlike all of your other dependencies”, which may not be a hard thing to accommodate as a user, but will negatively impact the image of the crate’s polish and maintenance.I personally don’t care to discuss these issues if the maintainers don’t care about it, but there are only so many times a project can brush off these requests before it builds up to a serious issue.
@kdubovikov As you already figured out from the linked PR’s it is already implemented on master, so there is no need to discuss anything else here. Additionally you can see there was no new major release since those PR’s where merged, therefore no current diesel release supports this. (Please don’t ask for a timeline for the next major release…)
Beside of that: Our issue tracker is a place for us developers to track thinks we are working on, not a place to answer support questions or anything like that. (Use our gitter channel or forum for that). A open issue here indicts that this is something someone could start working on, a closed issue is something that cannot be worked on for whatever reason.
I’m using
edition = "2018"which will be hitting Stable Rust in 2 days (6 December, 2018). The current version ofdiesel_cliprints aschema.rsfile without the necessary macrosused, meaning I have to add it manually on each migration.I think this merits fixing, as builds will start failing once people start migrating to Edition 2018. Thank you.
@weiznich Thanks, I have read it before raising the question. I understand that this is not a documentation issue. The problem is that this ticket was closed without mentioning the final decision:
@mitermayer also asks the same question.
The last comment I see is:
#1956 is closed and merged. I have also found #2248, which seems to be closely related to this issue. This pull request is also merged into the master branch. Does this mean that diesel already supports new-style macro imports, but this feature is not yet included in current stable release?
Thanks a lot for being supportive and answering on all questions in a very timely manner 👍🏻
It would be really beneficial if the recommended documentation such as http://diesel.rs/guides/getting-started/ didn’t lead you astray. The examples that are in the source tree (at the same tag) are helpful, but it’s not obvious that the getting started guide will lead you to errors that are one or two steps removed from the origin source (e.g. “cannot find
__diesel_parse_table!”)@rakenodiax @kamirr AFAIK all of the diesel warnings are fixed in master and will at some point be found in a future release. If you want a solution now, please use the diesel master branch.
I must have started from another post, then stumbled upon the getting started later and was selectively trying to “patch” my code to work. You’re correct though, following the guide strictly does work. I apologize.
absolutely.
Sorry for the noise.
@jonringer I don’t know why you feel that the getting started guide leads you astray, as it has a
#[macro_use] extern crate diesel;in literally the first rust code block on that page. Anyway if you have some concrete suggestions for improvements: You will find the source code here, just open a PR with your improvements there.@derekdreery There is already #1956. The only thing missing there is putting all macros exports in the right place.
@kdubovikov Please take the time to read to whole thread. The latest released diesel version just does not support importing macros without
#[macro_use]as it’s not just a documentation issue, but needs quite a lot of support from the crate offering the macros.@weiznich , you have closed my issue #2386 with the reference to this issue. My apologies for opening a duplicate. This issue seems to be closed, however, there is still no way (at least in the docs) to use diesel without
#[macro_use]. Should this be reopened, or am I missing something in the docs/examples?This issue seems to have been closed a while ago, has it been fixed or just marked as wont fix ?