Skip to content

Off-by-one in println! diagnostic #44954

Closed
@steveklabnik

Description

@steveklabnik

This program:

fn main() {
    let name = "foo";
    
    println!("{} {}", name);
}

Gives this error:

error: invalid reference to argument `1` (there is 1 argument)

Both things having 1 here is confusing, it'd be nicer if we didn't compare a zero-indexed and a one-indexed number.

Additionally, a note could make this easier to understand overall too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-diagnosticsWorking group: Diagnostics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions