Skip to content

something to keep code from being unrefactored for long periods of time #2281

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

Open
SoniEx2 opened this issue Jan 7, 2018 · 11 comments
Open
Labels
T-lang Relevant to the language team, which will review and decide on the RFC. T-libs-api Relevant to the library API team, which will review and decide on the RFC.

Comments

@SoniEx2
Copy link

SoniEx2 commented Jan 7, 2018

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.)

@Centril Centril added T-lang Relevant to the language team, which will review and decide on the RFC. T-libs-api Relevant to the library API team, which will review and decide on the RFC. labels Jan 7, 2018
@Centril
Copy link
Contributor

Centril commented Jan 7, 2018

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.

@SoniEx2
Copy link
Author

SoniEx2 commented Jan 7, 2018

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

@Centril
Copy link
Contributor

Centril commented Jan 7, 2018

In that case I think it would be quite useful.

@SoniEx2 SoniEx2 changed the title #[error_if(cond)] or something to keep code from being unrefactored for long periods of time something to keep code from being unrefactored for long periods of time Jan 7, 2018
@eaglgenes101
Copy link

eaglgenes101 commented Jan 8, 2018

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

@Centril
Copy link
Contributor

Centril commented Jan 8, 2018

@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.

@untitaker
Copy link
Contributor

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.

@Centril
Copy link
Contributor

Centril commented Jan 11, 2018

@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 :/

@SoniEx2
Copy link
Author

SoniEx2 commented Jan 11, 2018

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

@Ixrec
Copy link
Contributor

Ixrec commented Jan 15, 2018

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.

@Centril
Copy link
Contributor

Centril commented Jan 15, 2018

@Ixrec You can simply annotate your FIXME like so:

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

@SoniEx2
Copy link
Author

SoniEx2 commented Jan 15, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-lang Relevant to the language team, which will review and decide on the RFC. T-libs-api Relevant to the library API team, which will review and decide on the RFC.
Projects
None yet
Development

No branches or pull requests

5 participants