-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve derive syntax #2626
Improve derive syntax #2626
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks quite good 👍 Left a first bunch of comments. There are likely a few more things which need to change later on or I've missed now.
Still some work to do. I just wanted to create a draft PR to show some progress. You can see that the commits are from 2 months ago :) Regarding duplicated attributes, neither clap nor other repos which follow this overridable pattern has warnings. And I actually think it's good like that because it might open up some modularized use cases for end users. |
@pksunkara Are you interested in finishing this PR in the next few weeks? |
Yup, I was just rebasing this. |
Yes,
Sounds reasonable 👍 |
@weiznich Can you please give a preliminary look and see if you are okay with the format of the new attributes? Field attribute and Struct attribute |
CI is weird. I am locally on 1.48.0 and am unable to reproduce this error at all. Or the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done another round of review and left some comments on places where I have questions or small suggestions.
General points to discuss:
- As far as I see there is currently no way to emit a deprecation warning on a build not using rustc nightly. That's bad, we should find some way to "fix" that, even if that means to emit some "warnings" via
eprintln!
- The
get_parent()
error for the minimal rust version build is caused by-Z minimal-versions
, which just means that the minimal syn version that is specified do not have the corresponding method. This should be fixed by just increasing the minimal supported syn version to some version that has this method (at least syn 1.0.3 as far as I can see) - There are a few places the old deprecated attributes are not converted. The CI mostly did emit warnings for them, they should be fixed
- I'm not sure about the
spanned::Spanned
error, are you really sure that this trait is really needed in that scope for all backends?
diesel_compile_tests/tests/fail/as_changeset_bad_column_name_syntax.stderr
Outdated
Show resolved
Hide resolved
diesel_compile_tests/tests/fail/as_changeset_bad_primary_key_syntax.stderr
Outdated
Show resolved
Hide resolved
I haven't gone through the error/warning messages yet for the compile tests. I should have specifically said not to review those files inorder to save some time. |
So the Readme states:
which is unfortunate, as we really want to show the deprecated message everywhere. I see a few options around this:
|
Yeah, I am not exactly sure what we want to do regarding that. I am leaving it for the last thing to do though. Hopefully we will come up with something by then. |
@weiznich This is ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update 👍
This looks much better now. I left a few comments where I noticed small things. I think most of them should be easy to fix, some will likely require just a clarification.
diesel_compile_tests/tests/fail/derive_deprecated/deprecated_belongs_to.stderr
Outdated
Show resolved
Hide resolved
I should probably comment here to say that I've a rebased version of this locally, which also fixes at least some of the remarks. I can try to clean it up a bit tomorrow and push it afterwards. |
Oh, I was just about to do the rebase for the final push this week to get this merged. I will wait for you. Would you mind if you create a new commit for your changes instead of bundling them up with my rebased commits? |
I've pushed my rebased version. Hopefully this is a good starting point for fixing the remaining issues. |
I am not sold on the commit you pushed since we have the span already at I will be able to take a deeper look tomorrow and also address the last comment that's left. |
I think an important point to note here is that there are a few different spans involved here:
|
I am going to separate the I pulled the commit locally and saved it. |
Addressed all the comments now. The only question left from my original goal of the work is:
Can you please give a look at https://docs.rs/syn/latest/syn/enum.Type.html and tell me which of those variants do we allow for the above mentioned attributes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a bunch of minor notes. Those should be easy to fix. Otherwise I think this now looks really good 🎉.
One thing is still missing: A changelog entry + probably some draft section for the upgrade guide (Just some few words that we updated the attribute format…)
error: unexpected `oid` when `name` is present | ||
--> $DIR/bad_postgres_type.rs:30:44 | ||
| | ||
30 | #[diesel(postgres_type(name = "foo", oid = 2, array_oid = 3))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a thing for the followup PR: This spans could also be improved using the same strategy as demonstrated for deserialize_as
/embed
I would just accept |
Address review and used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's merge this 🎉
@pksunkara I want to use this opportunity to thank your for your long term effort here. I really appreciate this. ❤️ |
No problem. I just wish I had the time to actually focus on this properly in a straight forward manner instead of doing over a long time. |
#[column_name = "QUERY PLAN"]
supportTypePath
forsql_type
andforeign_derive
?changeset_options
keyword