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

"newbie mode" that contains helpful hints that don't work as lints #1737

Open
Manishearth opened this Issue May 8, 2017 · 6 comments

Comments

Projects
None yet
5 participants
@Manishearth
Collaborator

Manishearth commented May 8, 2017

It would be interesting to have a "newbie mode" (basically another lint group) that points out various features in your code, not necessarily suggesting fixes or anything.

For example impl Trait for OtherTrait can explain the difference between impl<T: OtherTrait> Trait for T and itself" or fn foo(mut x: Bar) can tell you that mut x does not mutate the outer variable when Bar is copy. Stuff like this, that doesn't work well as a lint (because there are plenty of good reasons to do it), but do merit a "watch out this may not do what you think" for newbies.

Thoughts? Ideas for similar newbie hint-lints?

@oli-obk

This comment has been minimized.

Show comment
Hide comment
@oli-obk

oli-obk May 9, 2017

Collaborator

My main concern is discoverability of such a group. Newcomers have enough on their plate starting out with Rust. I can tell my students to enable it, but how will someone who finds Rust on their own know about such lints? We can't "detect" newcomers, because we can't differentiate them from someone who just created a small crate to test something.

Once clippy is stable, we could consider this by asking the rustc devs to

  1. put #[warn(clippy_for_new_rustaceans)] into the cargo new --bin template conditionally on some hidden config file which stores the date of the first rustc usage of the user and the number of crates created. Then the template could revert to its normal version after the count reaches 5 or the age reaches a month.
  2. or just add several suggestions in the book about adding this flag
Collaborator

oli-obk commented May 9, 2017

My main concern is discoverability of such a group. Newcomers have enough on their plate starting out with Rust. I can tell my students to enable it, but how will someone who finds Rust on their own know about such lints? We can't "detect" newcomers, because we can't differentiate them from someone who just created a small crate to test something.

Once clippy is stable, we could consider this by asking the rustc devs to

  1. put #[warn(clippy_for_new_rustaceans)] into the cargo new --bin template conditionally on some hidden config file which stores the date of the first rustc usage of the user and the number of crates created. Then the template could revert to its normal version after the count reaches 5 or the age reaches a month.
  2. or just add several suggestions in the book about adding this flag
@Manishearth

This comment has been minimized.

Show comment
Hide comment
@Manishearth

Manishearth May 9, 2017

Collaborator

I do intend to insert clippy into the docs along with rustfmt once it is stable.

Collaborator

Manishearth commented May 9, 2017

I do intend to insert clippy into the docs along with rustfmt once it is stable.

@CBenoit

This comment has been minimized.

Show comment
Hide comment
@CBenoit

CBenoit May 17, 2017

Contributor

I absolutely love the idea.

Contributor

CBenoit commented May 17, 2017

I absolutely love the idea.

@oli-obk

This comment has been minimized.

Show comment
Hide comment
@oli-obk

oli-obk May 18, 2017

Collaborator

We should discuss this with the rustc team, because this would also be a good idea for error messages. Some errors are obvious mistakes made by new rustaceans, but after a while it will be a more complex issue

Collaborator

oli-obk commented May 18, 2017

We should discuss this with the rustc team, because this would also be a good idea for error messages. Some errors are obvious mistakes made by new rustaceans, but after a while it will be a more complex issue

@golddranks

This comment has been minimized.

Show comment
Hide comment
@golddranks

golddranks May 19, 2017

Of course, rustup could also ask about the default when installing the toolchain.

golddranks commented May 19, 2017

Of course, rustup could also ask about the default when installing the toolchain.

@joshlf

This comment has been minimized.

Show comment
Hide comment
@joshlf

joshlf May 19, 2017

Maybe make it default to assuming you're a newbie, but also make it easy to turn off? That way newbies are covered, and non-newbies should find it easy to disable.

joshlf commented May 19, 2017

Maybe make it default to assuming you're a newbie, but also make it easy to turn off? That way newbies are covered, and non-newbies should find it easy to disable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment