From e25d7069b5a6430252e6a411d55debf0a55b955b Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Mon, 13 Jan 2014 22:08:28 +1100 Subject: [PATCH] rustc: make error messages containing generic more self-explanatory. Unsuffixed literals like 1 and 1.1, and free type parameters sometimes have to be printed in error messages, which ended up with , and . This change puts the words "generic" and "integer"/"float" into the message so it's not a completely black box. --- src/librustc/middle/ty.rs | 6 +++--- src/test/compile-fail/issue-3680.rs | 2 +- src/test/compile-fail/issue-4968.rs | 2 +- .../slightly-nice-generic-literal-messages.rs | 19 +++++++++++++++++++ 4 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 src/test/compile-fail/slightly-nice-generic-literal-messages.rs diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index ef31c8c5f3cb6..daa5312229e15 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -810,7 +810,7 @@ impl Vid for TyVid { } impl ToStr for TyVid { - fn to_str(&self) -> ~str { format!("", self.to_uint()) } + fn to_str(&self) -> ~str { format!("", self.to_uint()) } } impl Vid for IntVid { @@ -818,7 +818,7 @@ impl Vid for IntVid { } impl ToStr for IntVid { - fn to_str(&self) -> ~str { format!("", self.to_uint()) } + fn to_str(&self) -> ~str { format!("", self.to_uint()) } } impl Vid for FloatVid { @@ -826,7 +826,7 @@ impl Vid for FloatVid { } impl ToStr for FloatVid { - fn to_str(&self) -> ~str { format!("", self.to_uint()) } + fn to_str(&self) -> ~str { format!("", self.to_uint()) } } impl Vid for RegionVid { diff --git a/src/test/compile-fail/issue-3680.rs b/src/test/compile-fail/issue-3680.rs index b453384c0c890..de2165ff633c1 100644 --- a/src/test/compile-fail/issue-3680.rs +++ b/src/test/compile-fail/issue-3680.rs @@ -10,6 +10,6 @@ fn main() { match None { - Err(_) => () //~ ERROR mismatched types: expected `std::option::Option<>` but found `std::result::Result<,>` + Err(_) => () //~ ERROR mismatched types: expected `std::option::Option<>` but found `std::result::Result<,>` } } diff --git a/src/test/compile-fail/issue-4968.rs b/src/test/compile-fail/issue-4968.rs index 700d8a61c3a39..5739f3dc46b90 100644 --- a/src/test/compile-fail/issue-4968.rs +++ b/src/test/compile-fail/issue-4968.rs @@ -12,5 +12,5 @@ static A: (int,int) = (4,2); fn main() { - match 42 { A => () } //~ ERROR mismatched types: expected `` but found `(int,int)` (expected integral variable but found tuple) + match 42 { A => () } //~ ERROR mismatched types: expected `` but found `(int,int)` (expected integral variable but found tuple) } diff --git a/src/test/compile-fail/slightly-nice-generic-literal-messages.rs b/src/test/compile-fail/slightly-nice-generic-literal-messages.rs new file mode 100644 index 0000000000000..6e5dc7cc102cc --- /dev/null +++ b/src/test/compile-fail/slightly-nice-generic-literal-messages.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo(T); + +fn main() { + match Foo(1.1) { + 1 => {} + //~^ ERROR expected `Foo<,>` but found `` + } + +}