Skip to content

Wrong underlined argument in tuple returned by function #117846

Closed
@GuillaumeGomez

Description

@GuillaumeGomez

Code

fn get_arguments(data: &[u8]) -> (Vec<String>, &[u8]) {
    (Vec::new(), data)
}

let x = true;
let cmd = &[1, 2, 3, 4];
let (cmd, proc_args) = if x {
    get_arguments(cmd)
} else {
    (Vec::new(), &[])
};

Current output

error[E0277]: the size for values of type `[_]` cannot be known at compilation time
   --> src/unix/apple/macos/process.rs:581:10
    |
581 |     let (cmd, proc_args) = if x {
    |          ^^^ doesn't have a size known at compile-time
    |
    = help: the trait `Sized` is not implemented for `[_]`
    = note: all local variables must have a statically known size
    = help: unsized locals are gated as an unstable feature

Desired output

error[E0277]: the size for values of type `[_]` cannot be known at compilation time
   --> src/unix/apple/macos/process.rs:581:10
    |
581 |     let (cmd, proc_args) = if x {
    |               ^^^^^^^^^ doesn't have a size known at compile-time
    |
    = help: the trait `Sized` is not implemented for `[_]`
    = note: all local variables must have a statically known size
    = help: unsized locals are gated as an unstable feature

Rationale and extra context

It's underlining the wrong argument.

Other cases

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    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