Skip to content

Type errors of the form "expected... but found..." should indicate the source of their expectation #14007

Closed
@zwarich

Description

@zwarich

The program

extern crate collections;
use collections::treemap::TreeMap;

fn main() {
    let mut a = TreeMap::new();
    a.insert(0, 1);
    a.insert(0, "foo");
}

gives the type error

treemap-test.rs:7:17: 7:22 error: mismatched types: expected `<generic integer #1>` but found `&'static str` (expected integral variable but found &-ptr)
treemap-test.rs:7     a.insert(0, "foo");
                                   ^~~~~

This error should indicate the source of the expectation that the type parameter is integral.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-inferenceArea: Type inferenceC-enhancementCategory: An issue proposing an enhancement or a PR with one.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