Skip to content

'allocator_api' error has a higher priority than 'unexpected type argument' #80237

Closed
@rossmacarthur

Description

@rossmacarthur

I tried this code:

fn test() -> Vec<i64, i64> {
    let vals = vec![(1, 2), (3, 4)];
    vals.into_iter().collect()
}

I expected to see this happen:

error[E0107]: wrong number of type arguments: expected 1, found 2
 --> src/main.rs:1:23
  |
1 | fn test() -> Vec<i64, i64> {
  |                       ^^^ unexpected type argument

Instead, this happened:

error[E0658]: use of unstable library feature 'allocator_api'
 --> src/main.rs:1:23
  |
1 | fn test() -> Vec<i64, i64> {
  |                       ^^^
  |
  = note: see issue #32838 <https://github.com/rust-lang/rust/issues/32838> for more information
  = help: add `#![feature(allocator_api)]` to the crate attributes to enable

This was very confusing to me, took me a while to figure out what the real error was.

Meta

rustc --version --verbose:

rustc 1.50.0-nightly (1f5bc176b 2020-12-19)
binary: rustc
commit-hash: 1f5bc176b0e54a8e464704adcd7e571700207fe9
commit-date: 2020-12-19
host: x86_64-apple-darwin
release: 1.50.0-nightly

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.D-confusingDiagnostics: Confusing error or lint that should be reworked.D-papercutDiagnostics: An error or lint that needs small tweaks.T-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