derive-where icon indicating copy to clipboard operation
derive-where copied to clipboard

Possible future improvements

Open daxpedda opened this issue 3 years ago • 6 comments

These are code improvements or features that could be added in the future if demand is there:

  • [ ] Revive rust-lang/rust#51561, which would get rid of the nightly crate feature and remove parts of the safe crate feature implementation.
  • [x] Improve safe PartialOrd and Ord codegen, done in #38.
  • [ ] Implement #[derive_where(Clone; T = u8)], which will generate impl Clone for Test<u8>.
  • [ ] Crate feature to disable warnings, currently errors that don't prevent derive-where from functioning correctly but point to invalid use-cases (use std derive) instead or bad code quality (empty bracers). Currently Rust doesn't have a compile_warn.
  • [ ] Remove quote and build any Rust code purely with syn structures instead.
  • [ ] Improve generated code, mainly remove match and access fields directly when not dealing with an enum. This is mainly modeled after std's derive, which was probably done to make it easy to implement as it makes code generation between enums and structs very similar, but after many refactors, there is no real advantage anymore.
  • [ ] Use once-cell or something similar to cache patterns and Idents, some implementation don't need them, but we don't want to generate them ad-hoc as they do some allocations. The main concern here is adding another dependency.
  • [ ] Use arrayvec or something similar to store traits, reducing overall allocations. We know what the maximum amount of possible traits are, no need to do any allocations. To reduce dependencies we could make our own.
  • [ ] Use smallvec or something similar to store fields and such, we don't expect structs to have an unlimited amount of fields. Again, another dependency.

daxpedda avatar Dec 07 '21 19:12 daxpedda

One thing I would like to do at some point, maybe as a feature would be some way to get rid of the #[derive(DeriveWhere)] even without rust-lang/rust#65823.

Maybe that would be doable as a normal macro even, that just generates the more verbose syntax.

ModProg avatar Dec 08 '21 14:12 ModProg

  • [ ] We use both attr.rs and test/mod.rs I'd lean toward making them all mod.rs.

ModProg avatar Dec 24 '22 14:12 ModProg

We could use this lint: https://rust-lang.github.io/rust-clippy/master/index.html#self_named_module_files

daxpedda avatar Dec 24 '22 17:12 daxpedda

https://github.com/rust-lang/rust/pull/106418 is in it's FCP with a disposition to merge! Still have to figure out what to do about the MSRV then.

daxpedda avatar Aug 24 '23 11:08 daxpedda

Oh, that would be big. We could have a feature that enables the current unsafe work around and therefor keeps the msrv down?

ModProg avatar Aug 24 '23 11:08 ModProg

I would probably do it the other way around, add a crate feature that enables the new behavior but raises the MSRV. Alternatively we could use rustversion.

In any case, we could remove the nightly feature with that.

daxpedda avatar Aug 24 '23 11:08 daxpedda