Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zwarich opened this Issue May 7, 2014 · 2 comments

Comments

Projects
None yet
4 participants
@zwarich
Copy link

zwarich commented May 7, 2014

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.

@steveklabnik

This comment has been minimized.

Copy link
Member

steveklabnik commented Feb 2, 2016

Updated code:

use std::collections::BTreeMap;

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

Error

 expected `_`,
    found `&'static str`
(expected integral variable,
    found &-ptr) [E0308]
hello.rs:6     a.insert(0, "foo");
                           ^~~~~

It still does not point to insert(0, 1).

@Havvy

This comment has been minimized.

Copy link
Contributor

Havvy commented Jun 30, 2018

Triage: No change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.