-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
RFC: #[derive unfinished(..)] and #[unfinished] #2205
Conversation
This looks like an attempt to solve lack of tooling via a language feature. Editors & IDEs should be able to autogenerate a skeleton |
@Xion Discussed in alternatives ;) I think @setharnold puts it well on #rust:
I think this approach is more uniform - and the tooling may not be there for every developer. |
My thoughts:
So... overall I'm lukewarm on this. |
@durka Continuing on from #rust @ IRC:
|
👎 I don't want this RFC. Only because haskell has a feature doesn't mean that Rust has to get it, too. I think extending RLS to auto-output such impls would be the way forward. This is proposing to add a language feature which usually has a high barrier of entry.
I don't think that terseness during prototyping should ever be an issue. You should be seeing that there is something yet to implement! When I do development, I only do a quick glance when putting a working implementation into git, I could easily miss any Furthermore I wonder about the usefulness of turning off warnings about presence of |
|
I think there might be a small amount of confusion about warnings. The RFC specifies a warning if you write Where I want a warning, and potentially one that cannot be turned off (at least when uploading to crates.io) is if you use |
@scottmcm Thanks <3. I think I agree too... So, the RFC should be split in two, one for |
Some random comments from me, of which some are I think mirroring est31's position.
I'm a little skeptical that Rust even has -- or indeed, can have, given the lack of HKT -- a sufficient number of useful derivable traits that'd warrant such an addition. There are crates like
On the other hand, I'd love standalone deriving. It'd allow me, as a crate user, to locally correct some of the mistakes of crate authors without going through burdensome cycle of forking, altering crate code, changing my
In most cases, I'd consider this is a useful hint that the module should be split into multiple files. Introducing the stubs early can be even thought as beneficial in this regard, as it highlights the issue earlier and allows to resolve it more easily, before the actual trait impl might have become more tightly coupled with the rest of the module (which makes the refactoring harder). |
This is not just useful for prototyping, it's also useful for testing: often for component-level testing I use a dummy implementation of a trait in place of the real dependencies. The dummy implementation often only needs to implement one or two methods from the trait for any given set of tests. To do this at the moment I end up giving all of my trait methods default implementations that panic. This is great for the tests, but it means that I don't get any errors if I add a new method and forget to implement it for one of the real implementations of the trait. |
So; I think this RFC is a bit too ambitious for the |
Rendered.
Allows the user to derive any trait for any type with
#[derive_unfinished(Trait1, Trait2, ...)]
by:unimplemented
in any method,ConstDefault
for associated constants where implemented,This desugars to a new
#[unfinished] impl Trait for Type { .. }
construct where the user may leave out any method they wish to not give an implementation for currently, as well as specify any associated type which does not have a default in the trait or any associated constant for which the type is notConstDefault
.The
#[unfinished]
construct in turn desugars into a full implementation of the trait for the type which usesunimplemented
for methods and uses defaults where possible.