Skip to content

Left suffix comma when suggesting remove extra arguments #109425

Closed
@chenyukang

Description

@chenyukang

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

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