Skip to content

Commit

Permalink
auto merge of #11513 : huonw/rust/generic-errs, r=alexcrichton
Browse files Browse the repository at this point in the history
Unsuffixed literals like 1 and 1.1, and free type parameters sometimes
have to be printed in error messages, which ended up with \<V0>, \<VI0>
and \<VF0>. This change puts the words "generic" and "integer"/"float"
into the message so it's not a completely black box.
  • Loading branch information
bors committed Jan 13, 2014
2 parents caf316a + e25d706 commit b97ace2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
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>`
}

}

0 comments on commit b97ace2

Please sign in to comment.