Rfcs: The compiler should be warned when some misleading code is being used

Created on 30 Oct 2016  Â·  3Comments  Â·  Source: rust-lang/rfcs

The compiler should be warned when some misleading code is being used
for example:

  • Use && and || at the same time without parentheses. This may cause programmers to misunderstand their priorities.
  • The identifiers are case-sensitive only. Programmers may mix them.
  • Identifiers are defined in capitalized form for keywords. Programmers may mix them.
  • Use return in the last sentence of the function. Just because it is not beautiful.

Most helpful comment

This is the job of clippy.

On Oct 29, 2016, 21:45 -0400, Ryûki [email protected], wrote:

The compiler should be warned when some misleading code is being used
for example:

Use && and || without parentheses. This may cause programmers to misunderstand their priorities.
The identifiers are case-sensitive only. Programmers may mix them.
Identifiers are defined in capitalized form for keywords. Programmers may mix them.
Use return in the last sentence of the function. Just because it is not beautiful.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub (https://github.com/rust-lang/rfcs/issues/1781), or mute the thread (https://github.com/notifications/unsubscribe-auth/AABsilwTTqFasen-eQO3tq1i20ge9G5Xks5q4_bJgaJpZM4KkRA9).

All 3 comments

This is the job of clippy.

On Oct 29, 2016, 21:45 -0400, Ryûki [email protected], wrote:

The compiler should be warned when some misleading code is being used
for example:

Use && and || without parentheses. This may cause programmers to misunderstand their priorities.
The identifiers are case-sensitive only. Programmers may mix them.
Identifiers are defined in capitalized form for keywords. Programmers may mix them.
Use return in the last sentence of the function. Just because it is not beautiful.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub (https://github.com/rust-lang/rfcs/issues/1781), or mute the thread (https://github.com/notifications/unsubscribe-auth/AABsilwTTqFasen-eQO3tq1i20ge9G5Xks5q4_bJgaJpZM4KkRA9).

Use && and || at the same time without parentheses. This may cause programmers to misunderstand their priorities.

Perhaps this can be an enhancement for https://github.com/Manishearth/rust-clippy/wiki#precedence

The identifiers are case-sensitive only. Programmers may mix them.
Identifiers are defined in capitalized form for keywords. Programmers may mix them.

Not sure what you mean by "case-sensitive"/"keywords", but bad_style lints (non_snake_case,non_camel_case_types,non_upper_case_globals) in rustc cover them, don't they?

Use return in the last sentence of the function. Just because it is not beautiful.

https://github.com/Manishearth/rust-clippy/wiki#needless_return

continued in the clippy repo: https://github.com/Manishearth/rust-clippy/issues/1308

this can be closed I think?

Was this page helpful?
0 / 5 - 0 ratings