Skip to content

The suggestion to remove generic parameters proposed by help did not remove comma #128302

Open

Description

@A4-Tacks

Code

type Result<T> = std::result::Result<T, ()>;

fn foo() -> Result<'static, ()> { Ok(()) }

fn main() { }

Current output

error[E0107]: type alias takes 0 lifetime arguments but 1 lifetime argument was supplied
 --> src/main.rs:3:13
  |
3 | fn foo() -> Result<'static, ()> { Ok(()) }
  |             ^^^^^^ ------- help: remove this lifetime argument
  |             |
  |             expected 0 lifetime arguments
  |
note: type alias defined here, with 0 lifetime parameters
 --> src/main.rs:1:6
  |
1 | type Result<T> = std::result::Result<T, ()>;
  |      ^^^^^^

For more information about this error, try `rustc --explain E0107`.
error: could not compile `test2` (bin "test2") due to 1 previous error

Desired output

error[E0107]: type alias takes 0 lifetime arguments but 1 lifetime argument was supplied
 --> src/main.rs:3:13
  |
3 | fn foo() -> Result<'static, ()> { Ok(()) }
  |             ^^^^^^ --------- help: remove this lifetime argument
  |             |
  |             expected 0 lifetime arguments
  |
note: type alias defined here, with 0 lifetime parameters
 --> src/main.rs:1:6
  |
1 | type Result<T> = std::result::Result<T, ()>;
  |      ^^^^^^

For more information about this error, try `rustc --explain E0107`.
error: could not compile `test2` (bin "test2") due to 1 previous error

Rationale and extra context

rust-lang/rust-analyzer#17727

Due to not removing the comma, rust-analyzer still has an error after quick fix

Other cases

No response

Rust Version

rustc 1.80.0 (051478957 2024-07-21)
binary: rustc
commit-hash: 051478957371ee0084a7c0913941d2a8c4757bb9
commit-date: 2024-07-21
host: aarch64-unknown-linux-gnu
release: 1.80.0
LLVM version: 18.1.7

Anything else?

No response

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jul 28, 2024
  2. tgross35 commented on Jul 28, 2024

    @tgross35
    Member

    It looks like that may have been fixed by b30fdec, can you check what happens on the latest nightly? (Unfortunately the playground hasn't been updated to something recent enough yet).

  3. A4-Tacks commented on Jul 28, 2024

    @A4-Tacks
    MemberAuthor

    rustc 1.82.0-nightly (7c2012d 2024-07-26)
    The cargo check output doesn't seem to have changed

  4. A4-Tacks commented on Jul 28, 2024

    @A4-Tacks
    MemberAuthor

    It looks like that may have been fixed by b30fdec, can you check what happens on the latest nightly? (Unfortunately the playground hasn't been updated to something recent enough yet).

    In the example of b30fdec, it seems that the test case does not include a comma that removes the first parameter, but rather the tail parameter

  5. tgross35 commented on Jul 28, 2024

    @tgross35
    Member

    Cc @estebank since you did #127374, might be a quick fixup

  6. A4-Tacks commented on Jul 28, 2024

    @A4-Tacks
    MemberAuthor

    This doesn't seem to remove the comma on the left either

    type Result<T> = std::result::Result<T, ()>;
    
    fn foo() -> Result<(), 'static> { Ok(()) }
    
    fn main() { }

    output:

    error[E0107]: type alias takes 0 lifetime arguments but 1 lifetime argument was supplied
     --> src/main.rs:3:13
      |
    3 | fn foo() -> Result<(), 'static> { Ok(()) }
      |             ^^^^^^     ------- help: remove the lifetime argument
      |             |
      |             expected 0 lifetime arguments
      |
    note: type alias defined here, with 0 lifetime parameters
     --> src/main.rs:1:6
      |
    1 | type Result<T> = std::result::Result<T, ()>;
      |      ^^^^^^
    
    For more information about this error, try `rustc --explain E0107`.
    error: could not compile `test2` (bin "test2") due to 1 previous error
  7. chansuke commented on Aug 12, 2024

    @chansuke
    Contributor

    @rustbot claim

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

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and 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