Skip to content

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

@rossmacarthur

Description

@rossmacarthur
Contributor

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

Activity

rossmacarthur

rossmacarthur commented on Dec 20, 2020

@rossmacarthur
ContributorAuthor

@rustbot modify labels: +A-diagnostics +D-confusing +D-papercut +C-enhancement -C-bug

added
A-diagnosticsArea: Messages for errors, warnings, and lints
C-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.
and removed
C-bugCategory: This is a bug.
on Dec 20, 2020
added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Dec 31, 2020
TaKO8Ki

TaKO8Ki commented on Dec 11, 2021

@TaKO8Ki
Member

#90856 has already solved this problem.

paulyoung

paulyoung commented on Dec 5, 2022

@paulyoung

I'm using Rust 1.63.0 (rustc 1.63.0 (4b91a6ea7 2022-08-08)) and just ran into this.

Here's a minimal example:

use std::collections::BTreeSet;

pub type Foo = BTreeSet<String, String>;
error[E0658]: use of unstable library feature 'allocator_api'
  --> crates/<my_crate>/src/main.rs:3:33
  |
3 | pub type Foo = BTreeSet<String, String>;
  |                                 ^^^^^^
  |
   = note: see issue #32838 <https://github.com/rust-lang/rust/issues/32838> for more information

For more information about this error, try `rustc --explain E0658`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @paulyoung@rossmacarthur@JohnTitor@TaKO8Ki@rustbot

        Issue actions

          'allocator_api' error has a higher priority than 'unexpected type argument' · Issue #80237 · rust-lang/rust