Skip to content
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

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

Open
A4-Tacks opened this issue Jul 28, 2024 · 6 comments
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@A4-Tacks
Copy link

A4-Tacks commented Jul 28, 2024

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

@A4-Tacks A4-Tacks added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 28, 2024
@tgross35
Copy link
Contributor

tgross35 commented Jul 28, 2024

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).

@A4-Tacks
Copy link
Author

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

@A4-Tacks
Copy link
Author

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

@tgross35
Copy link
Contributor

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

@A4-Tacks
Copy link
Author

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

@chansuke
Copy link
Contributor

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants