Skip to content

parenthesized_params_in_types_and_modules future-compatibility warnings #42238

Closed

Description

@qnighy

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 = self.foo() 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

Activity

  1. added a commit that references this issue on May 26, 2017
  2. added
    B-unstableBlocker: Implemented in the nightly compiler and unstable.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on May 29, 2017
  3. qnighy commented on Jun 12, 2017

    @qnighy
    ContributorAuthor

    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
    }
  4. added
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    on Jul 22, 2017
  5. tchamelot commented on Jan 3, 2019

    @tchamelot

    I don't know if this should go here, I am new to Rust and I still make mistakes such as confuse ":" and "=" for struct. Today, the compiler brought me here through a link because of this error. Is this the standard behavior for this kind of error.

    error: parenthesized parameters may only be used with a trait --> src/main.rs:100:28 | 100 | let mut ally : Pod::new(); | ^^ | = note: #[deny(parenthesized_params_in_types_and_modules)] on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238>

  6. removed
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    on Jan 13, 2019
  7. added a commit that references this issue on Aug 3, 2019
  8. added a commit that references this issue on Nov 8, 2019
    fcc7964
  9. added a commit that references this issue on Nov 8, 2019
    7ab50e4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-unstableBlocker: Implemented in the nightly compiler and unstable.C-future-incompatibilityCategory: Future-incompatibility lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions