Skip to content

Commit 422e109

Browse files
committed
---
yaml --- r: 150773 b: refs/heads/try2 c: 5d284a0 h: refs/heads/master i: 150771: 0159f9a v: v3
1 parent a7ce94f commit 422e109

File tree

10 files changed

+66
-31
lines changed

10 files changed

+66
-31
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 44e34c24c4752408038f95225f536d11605c5ba4
8+
refs/heads/try2: 5d284a0daa39f6b87028f97b5bfa2bb92f658f83
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/front/feature_gate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl<'a> Context<'a> {
9696
fn gate_feature(&self, feature: &str, span: Span, explain: &str) {
9797
if !self.has_feature(feature) {
9898
self.sess.span_err(span, explain);
99-
self.sess.span_note(span, format!("add \\#[feature({})] to the \
99+
self.sess.span_note(span, format!("add \\#![feature({})] to the \
100100
crate attributes to enable",
101101
feature));
102102
}

branches/try2/src/librustc/middle/typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3698,7 +3698,7 @@ pub fn instantiate_path(fcx: &FnCtxt,
36983698
&& !fcx.tcx().sess.features.default_type_params.get() {
36993699
fcx.tcx().sess.span_err(pth.span, "default type parameters are \
37003700
experimental and possibly buggy");
3701-
fcx.tcx().sess.span_note(pth.span, "add #[feature(default_type_params)] \
3701+
fcx.tcx().sess.span_note(pth.span, "add #![feature(default_type_params)] \
37023702
to the crate attributes to enable");
37033703
}
37043704

branches/try2/src/librustc/util/ppaux.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,8 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> ~str {
341341
ty_bot => ~"!",
342342
ty_bool => ~"bool",
343343
ty_char => ~"char",
344-
ty_int(ast::TyI) => ~"int",
345-
ty_int(t) => ast_util::int_ty_to_str(t),
346-
ty_uint(ast::TyU) => ~"uint",
347-
ty_uint(t) => ast_util::uint_ty_to_str(t),
344+
ty_int(t) => ast_util::int_ty_to_str(t, None),
345+
ty_uint(t) => ast_util::uint_ty_to_str(t, None),
348346
ty_float(t) => ast_util::float_ty_to_str(t),
349347
ty_box(typ) => ~"@" + ty_to_str(cx, typ),
350348
ty_uniq(typ) => ~"~" + ty_to_str(cx, typ),

branches/try2/src/libstd/num/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ pub fn abs_sub<T: Signed>(x: T, y: T) -> T {
159159
/// - `-1` if the number is negative
160160
#[inline(always)] pub fn signum<T: Signed>(value: T) -> T { value.signum() }
161161

162+
/// A trait for values which cannot be negative
162163
pub trait Unsigned: Num {}
163164

164165
/// A collection of rounding operations.
@@ -205,6 +206,7 @@ pub fn pow<T: One + Mul<T, T>>(mut base: T, mut exp: uint) -> T {
205206
}
206207
}
207208

209+
/// Numbers which have upper and lower bounds
208210
pub trait Bounded {
209211
// FIXME (#5527): These should be associated constants
210212
fn min_value() -> Self;
@@ -1046,10 +1048,12 @@ impl_num_cast!(int, to_int)
10461048
impl_num_cast!(f32, to_f32)
10471049
impl_num_cast!(f64, to_f64)
10481050

1051+
/// A generic trait for converting a value to a string with a radix (base)
10491052
pub trait ToStrRadix {
10501053
fn to_str_radix(&self, radix: uint) -> ~str;
10511054
}
10521055

1056+
/// A generic trait for converting a string with a radix (base) to a value
10531057
pub trait FromStrRadix {
10541058
fn from_str_radix(str: &str, radix: uint) -> Option<Self>;
10551059
}

branches/try2/src/libsyntax/ast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ pub enum IntTy {
707707

708708
impl fmt::Show for IntTy {
709709
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
710-
write!(f.buf, "{}", ast_util::int_ty_to_str(*self))
710+
write!(f.buf, "{}", ast_util::int_ty_to_str(*self, None))
711711
}
712712
}
713713

@@ -722,7 +722,7 @@ pub enum UintTy {
722722

723723
impl fmt::Show for UintTy {
724724
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
725-
write!(f.buf, "{}", ast_util::uint_ty_to_str(*self))
725+
write!(f.buf, "{}", ast_util::uint_ty_to_str(*self, None))
726726
}
727727
}
728728

branches/try2/src/libsyntax/ast_util.rs

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,21 @@ pub fn is_path(e: @Expr) -> bool {
132132
return match e.node { ExprPath(_) => true, _ => false };
133133
}
134134

135-
pub fn int_ty_to_str(t: IntTy) -> ~str {
136-
match t {
137-
TyI => ~"",
138-
TyI8 => ~"i8",
139-
TyI16 => ~"i16",
140-
TyI32 => ~"i32",
141-
TyI64 => ~"i64"
135+
// Get a string representation of a signed int type, with its value.
136+
// We want to avoid "45int" and "-3int" in favor of "45" and "-3"
137+
pub fn int_ty_to_str(t: IntTy, val: Option<i64>) -> ~str {
138+
let s = match t {
139+
TyI if val.is_some() => "",
140+
TyI => "int",
141+
TyI8 => "i8",
142+
TyI16 => "i16",
143+
TyI32 => "i32",
144+
TyI64 => "i64"
145+
};
146+
147+
match val {
148+
Some(n) => format!("{}{}", n, s),
149+
None => s.to_owned()
142150
}
143151
}
144152

@@ -151,13 +159,21 @@ pub fn int_ty_max(t: IntTy) -> u64 {
151159
}
152160
}
153161

154-
pub fn uint_ty_to_str(t: UintTy) -> ~str {
155-
match t {
156-
TyU => ~"u",
157-
TyU8 => ~"u8",
158-
TyU16 => ~"u16",
159-
TyU32 => ~"u32",
160-
TyU64 => ~"u64"
162+
// Get a string representation of an unsigned int type, with its value.
163+
// We want to avoid "42uint" in favor of "42u"
164+
pub fn uint_ty_to_str(t: UintTy, val: Option<u64>) -> ~str {
165+
let s = match t {
166+
TyU if val.is_some() => "u",
167+
TyU => "uint",
168+
TyU8 => "u8",
169+
TyU16 => "u16",
170+
TyU32 => "u32",
171+
TyU64 => "u64"
172+
};
173+
174+
match val {
175+
Some(n) => format!("{}{}", n, s),
176+
None => s.to_owned()
161177
}
162178
}
163179

branches/try2/src/libsyntax/parse/token.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,8 @@ pub fn to_str(t: &Token) -> ~str {
201201
res.push_char('\'');
202202
res.into_owned()
203203
}
204-
LIT_INT(i, t) => {
205-
i.to_str() + ast_util::int_ty_to_str(t)
206-
}
207-
LIT_UINT(u, t) => {
208-
u.to_str() + ast_util::uint_ty_to_str(t)
209-
}
204+
LIT_INT(i, t) => ast_util::int_ty_to_str(t, Some(i)),
205+
LIT_UINT(u, t) => ast_util::uint_ty_to_str(t, Some(u)),
210206
LIT_INT_UNSUFFIXED(i) => { i.to_str() }
211207
LIT_FLOAT(s, t) => {
212208
let mut body = StrBuf::from_str(get_ident(s).get());

branches/try2/src/libsyntax/print/pprust.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2171,10 +2171,10 @@ impl<'a> State<'a> {
21712171
word(&mut self.s, res.into_owned())
21722172
}
21732173
ast::LitInt(i, t) => {
2174-
word(&mut self.s, format!("{}{}", i, ast_util::int_ty_to_str(t)))
2174+
word(&mut self.s, ast_util::int_ty_to_str(t, Some(i)))
21752175
}
21762176
ast::LitUint(u, t) => {
2177-
word(&mut self.s, format!("{}{}", u, ast_util::uint_ty_to_str(t)))
2177+
word(&mut self.s, ast_util::uint_ty_to_str(t, Some(u)))
21782178
}
21792179
ast::LitIntUnsuffixed(i) => {
21802180
word(&mut self.s, format!("{}", i))
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn foo(_s: i16) { }
12+
13+
fn bar(_s: u32) { }
14+
15+
fn main() {
16+
foo(1*(1 as int));
17+
//~^ ERROR: mismatched types: expected `i16` but found `int` (expected `i16` but found `int`)
18+
19+
bar(1*(1 as uint));
20+
//~^ ERROR: mismatched types: expected `u32` but found `uint` (expected `u32` but found `uint`)
21+
}

0 commit comments

Comments
 (0)