Rfcs: something to keep code from being unrefactored for long periods of time

Created on 7 Jan 2018  路  11Comments  路  Source: rust-lang/rfcs

I'd like a way for rust to tell the stupid programmer (me) about when their stupid code (my code) can be made less stupid.

More specifically, I'd like something along the lines of:

#[error_if(is_stable(try_from))]
// TODO switch to TryFrom/TryInto once those are stable. (rust-lang/rust#33417)
IrcCommand::Numeric(Numeric(unsafe { from_utf8_unchecked(cmd) }.parse().unwrap(), array_ref![cmd,0,3]))

Currently I have this line somewhere in my codebase, and once TryFrom/TryInto lands, I'll still have that line somewhere in my codebase, because there's no way to make the compiler tell me I can change it. (arrayref crate will probably remain useful until we get const generics.)

T-lang T-libs

Most helpful comment

I haven't seen it personally yet (I'm still in college after all), but I've heard plenty of stories about how kludges and temporary workarounds end up being permanent simply because no one got around with putting a more robust fix in place. We can't fix developer laziness, but perhaps something like this could help people not forget tasks they defer to later, in general.

warning: FIXME not resolved for 2 years

All 11 comments

That would make library stabilization akin to a breaking change.
But if it was #[warn_if(is_stable(try_from))] it would simply be a warning.

That's ok, as long as it lets me know when I can stop being stupid.

In that case I think it would be quite useful.

I haven't seen it personally yet (I'm still in college after all), but I've heard plenty of stories about how kludges and temporary workarounds end up being permanent simply because no one got around with putting a more robust fix in place. We can't fix developer laziness, but perhaps something like this could help people not forget tasks they defer to later, in general.

warning: FIXME not resolved for 2 years

@eaglgenes101 That sounds quite useful as well, especially in clippy, but the feature is somewhat orthogonal to this one. This proposal will emit the warning / error once stabilization happens and not before wherefore it requires a formal-language syntax with executable content as opposed to free form text.

Couldn't this be done in a linter outside of rustc? You would not be able to use the same syntax for your annotations, but surely magic comments would be good enough.

@untitaker I'd prefer that this be inside the compiler since you might not always run the linter especially since clippy does not always work :/

@untitaker that doesn't integrate with the currently running compiler.

How would this tool determine how old a FIXME comment is? That seems like it would require the tool to speak git, mercurial, svn, etc, and I'm not sure we want rustc to be the kind of tool that has to stay in sync with several other arguably unrelated tools.

@Ixrec You can simply annotate your FIXME like so:

// FIXME 2018-01-15 We really need to improve the performance of X algorithm.

Can you move the FIXME stuff to another issue/thread?

Was this page helpful?
0 / 5 - 0 ratings