Skip to content

debug ice: E0061 with several fn arguments where 0 are expected #108249

Closed
@matthiaskrgr

Description

Code

This triggers a debug assertion due to bad spans when more than one input is given to a function that expects none.

fn main() {
	Vec::new(0, 1);
}

without debug assertions, this results in

error[E0061]: this function takes 0 arguments but 2 arguments were supplied
   --> extern-prelude.rs:2:2
    |
2   |     Vec::new(0, 1);
    |     ^^^^^^^^ -  - unexpected argument of type `{integer}`
    |              |
    |              unexpected argument of type `{integer}`
    |
note: associated function defined here
   --> /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/mod.rs:424:18
    |
424 |     pub const fn new() -> Self {
    |                  ^^^
help: remove the extra arguments
    |
2   -     Vec::new(0, 1);
2   +     Vec::new();

I think under the hood rustc might try to generate empty spans for within the () where it suggests to remove the fn args..? Just a wild guess though 🤔

Meta

rustc --version --verbose:

eebdfb55fce148676c24555505aebf648123b2de

Error output

error[E0061]: this function takes 0 arguments but 2 arguments were supplied
   --> extern-prelude.rs:2:2
    |
2   |     Vec::new(0, 1);
    |     ^^^^^^^^ -  - unexpected argument of type `{integer}`
    |              |
    |              unexpected argument of type `{integer}`
    |
note: associated function defined here
   --> /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/mod.rs:424:18
    |
424 |     pub const fn new() -> Self {
    |                  ^^^
help: remove the extra arguments
    |
2   -     Vec::new(0, 1);
2   +     Vec::new();
    |

error: aborting due to previous error

For more information about this error, try `rustc --explain E0061`

ice.log

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-debug-assertionsThis issue requires a build of rustc or tooling with debug-assertions in some way

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions