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

Left suffix comma when suggesting remove extra arguments #109425

Closed
chenyukang opened this issue Mar 21, 2023 · 0 comments · Fixed by #109782
Closed

Left suffix comma when suggesting remove extra arguments #109425

chenyukang opened this issue Mar 21, 2023 · 0 comments · Fixed by #109782
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

@chenyukang
Copy link
Member

Code

fn main() {
    {
        let mut mutex: libc() = std::mem::zeroed(
            file.as_raw_fd(),
            0,
            0,
            libc::SYNC_FILE_RANGE_WAIT_BEFORE,
        );
    }
}

Current output

error[E0433]: failed to resolve: use of undeclared crate or module `libc`
 --> ./p/debug.rs:7:13
  |
7 |             libc::SYNC_FILE_RANGE_WAIT_BEFORE,
  |             ^^^^ use of undeclared crate or module `libc`

error[E0412]: cannot find type `libc` in this scope
 --> ./p/debug.rs:3:24
  |
3 |         let mut mutex: libc() = std::mem::zeroed(
  |                        ^^^^ not found in this scope

error[E0423]: expected value, found macro `file`
 --> ./p/debug.rs:4:13
  |
4 |             file.as_raw_fd(),
  |             ^^^^ not a value

error[E0061]: this function takes 0 arguments but 4 arguments were supplied
   --> ./p/debug.rs:3:33
    |
3   |         let mut mutex: libc() = std::mem::zeroed(
    |                                 ^^^^^^^^^^^^^^^^
4   |             file.as_raw_fd(),
    |             ---------------- unexpected argument
5   |             0,
    |             - unexpected argument of type `{integer}`
6   |             0,
    |             - unexpected argument of type `{integer}`
7   |             libc::SYNC_FILE_RANGE_WAIT_BEFORE,
    |             --------------------------------- unexpected argument
    |
note: function defined here
   --> /Users/yukang/rust/library/core/src/mem/mod.rs:643:15
    |
643 | pub unsafe fn zeroed<T>() -> T {
    |               ^^^^^^
help: remove the extra arguments
    |
4   -             file.as_raw_fd(),
4   +             ,
    |

error: aborting due to 4 previous errors

Desired output

error[E0433]: failed to resolve: use of undeclared crate or module `libc`
 --> ./p/debug.rs:7:13
  |
7 |             libc::SYNC_FILE_RANGE_WAIT_BEFORE,
  |             ^^^^ use of undeclared crate or module `libc`

error[E0412]: cannot find type `libc` in this scope
 --> ./p/debug.rs:3:24
  |
3 |         let mut mutex: libc() = std::mem::zeroed(
  |                        ^^^^ not found in this scope

error[E0423]: expected value, found macro `file`
 --> ./p/debug.rs:4:13
  |
4 |             file.as_raw_fd(),
  |             ^^^^ not a value

error[E0061]: this function takes 0 arguments but 4 arguments were supplied
   --> ./p/debug.rs:3:33
    |
3   |         let mut mutex: libc() = std::mem::zeroed(
    |                                 ^^^^^^^^^^^^^^^^
4   |             file.as_raw_fd(),
    |             ---------------- unexpected argument
5   |             0,
    |             - unexpected argument of type `{integer}`
6   |             0,
    |             - unexpected argument of type `{integer}`
7   |             libc::SYNC_FILE_RANGE_WAIT_BEFORE,
    |             --------------------------------- unexpected argument
    |
note: function defined here
   --> /Users/yukang/rust/library/core/src/mem/mod.rs:643:15
    |
643 | pub unsafe fn zeroed<T>() -> T {
    |               ^^^^^^
help: remove the extra arguments
    |
4   -             file.as_raw_fd(),
4   +             
    |

error: aborting due to 4 previous errors

Rationale and extra context

From #109403 (comment)
Maybe a possible way is don't suggestion help when there are multiple arguments need to be removed, because we already have error[E0061] for those details?

Other cases

No response

Anything else?

No response

@chenyukang chenyukang 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 Mar 21, 2023
@WaffleLapkin WaffleLapkin self-assigned this Mar 30, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 6, 2023
…guments, r=oli-obk

Don't leave a comma at the start of argument list when removing arguments

Fixes rust-lang#109425

Quite a dirty hack, but at least it works ig.
@bors bors closed this as completed in b153e2b Apr 6, 2023
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

Successfully merging a pull request may close this issue.

2 participants