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

`parenthesized_params_in_types_and_modules` future-compatibility warnings #42238

qnighy opened this Issue May 26, 2017 · 1 comment


None yet
2 participants

qnighy commented May 26, 2017

This is the summary issue for the PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES future-compatibility warning and other related errors. The goal of this page is describe why this change was made and how you can fix code that is affected by it. It also provides a place to ask questions or register a complaint if you feel the change should not be made.

What is the warning for?

The parenthesized_params_in_types_and_modules warning is issued when you use parenthesized generic parameters in modules, primitive types, type parameters, or Self. For structs, enums, enum variants, unions, and type aliases, the syntax has already issued an error. Typical example of this warning is a code like this:

fn something(&self) -> i32 () {
  //                       ^^ parenthesized params

  let x = as usize();
  //                         ^^ parenthesized params

This warning can always be fixed by removing the parentheses.

When will this warning become a hard error?

At the beginning of each 6-week release cycle, the Rust compiler team will review the set of outstanding future compatibility warnings and nominate some of them for Final Comment Period. Toward the end of
the cycle, we will review any comments and make a final determination whether to convert the warning into a hard error or remove it entirely.

Current status

  • #41856 introduces the parenthesized_params_in_types_and_modules lint as warn-by-default
  • #42894 makes the parenthesized_params_in_types_and_modules lint deny-by-default
  • PR ? makes the parenthesized_params_in_types_and_modules lint a hard error

This comment has been minimized.


qnighy commented Jun 12, 2017

I noticed there is a case where () cannot just be removed.

fn main() {
    0 as usize() < 1; // `()` can't just be removed.

The cause is the well-known ambiguity between "less-than" and "open angle bracket". In this case, you can fix the problem like this:

fn main() {
    0 as (usize) < 1; // OK
    (0 as usize) < 1; // OK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment