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

rustc: make error messages containing generic more self-explanatory. #11513

Merged
merged 1 commit into from
Jan 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -810,23 +810,23 @@ impl Vid for TyVid {
}

impl ToStr for TyVid {
fn to_str(&self) -> ~str { format!("<V{}>", self.to_uint()) }
fn to_str(&self) -> ~str { format!("<generic \\#{}>", self.to_uint()) }
}

impl Vid for IntVid {
fn to_uint(&self) -> uint { let IntVid(v) = *self; v }
}

impl ToStr for IntVid {
fn to_str(&self) -> ~str { format!("<VI{}>", self.to_uint()) }
fn to_str(&self) -> ~str { format!("<generic integer \\#{}>", self.to_uint()) }
}

impl Vid for FloatVid {
fn to_uint(&self) -> uint { let FloatVid(v) = *self; v }
}

impl ToStr for FloatVid {
fn to_str(&self) -> ~str { format!("<VF{}>", self.to_uint()) }
fn to_str(&self) -> ~str { format!("<generic float \\#{}>", self.to_uint()) }
}

impl Vid for RegionVid {
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-3680.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

fn main() {
match None {
Err(_) => () //~ ERROR mismatched types: expected `std::option::Option<<V1>>` but found `std::result::Result<<V2>,<V3>>`
Err(_) => () //~ ERROR mismatched types: expected `std::option::Option<<generic #1>>` but found `std::result::Result<<generic #2>,<generic #3>>`
}
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-4968.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@

static A: (int,int) = (4,2);
fn main() {
match 42 { A => () } //~ ERROR mismatched types: expected `<VI0>` but found `(int,int)` (expected integral variable but found tuple)
match 42 { A => () } //~ ERROR mismatched types: expected `<generic integer #0>` but found `(int,int)` (expected integral variable but found tuple)
}
19 changes: 19 additions & 0 deletions src/test/compile-fail/slightly-nice-generic-literal-messages.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

struct Foo<T,U>(T);

fn main() {
match Foo(1.1) {
1 => {}
//~^ ERROR expected `Foo<<generic float #0>,<generic #2>>` but found `<generic integer #0>`
}

}