Skip to content

Commit 1132ba9

Browse files
huonwnikomatsakis
authored andcommitted
---
yaml --- r: 171644 b: refs/heads/batch c: d12514b h: refs/heads/master v: v3
1 parent 71a3ee6 commit 1132ba9

File tree

5 files changed

+94
-4
lines changed

5 files changed

+94
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2929
refs/heads/issue-18208-method-dispatch-2: 9e1eae4fb9b6527315b4441cf8a0f5ca911d1671
3030
refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
32-
refs/heads/batch: e95779554e9d6fc111102df7af80b40f8e22cfae
32+
refs/heads/batch: d12514bc589c1955108d517acd6d5952929b1650
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 496dc4eae7de9d14cd49511a9acfbf5f11ae6c3f
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928

branches/batch/src/librustc/middle/ty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2341,12 +2341,12 @@ impl<'tcx> CommonTypes<'tcx> {
23412341
bool: intern_ty(arena, interner, ty_bool),
23422342
char: intern_ty(arena, interner, ty_char),
23432343
err: intern_ty(arena, interner, ty_err),
2344-
int: intern_ty(arena, interner, ty_int(ast::TyIs(_))),
2344+
int: intern_ty(arena, interner, ty_int(ast::TyIs(false))),
23452345
i8: intern_ty(arena, interner, ty_int(ast::TyI8)),
23462346
i16: intern_ty(arena, interner, ty_int(ast::TyI16)),
23472347
i32: intern_ty(arena, interner, ty_int(ast::TyI32)),
23482348
i64: intern_ty(arena, interner, ty_int(ast::TyI64)),
2349-
uint: intern_ty(arena, interner, ty_uint(ast::TyUs(_))),
2349+
uint: intern_ty(arena, interner, ty_uint(ast::TyUs(false))),
23502350
u8: intern_ty(arena, interner, ty_uint(ast::TyU8)),
23512351
u16: intern_ty(arena, interner, ty_uint(ast::TyU16)),
23522352
u32: intern_ty(arena, interner, ty_uint(ast::TyU32)),

branches/batch/src/librustc_trans/trans/type_of.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ pub fn type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
263263
}
264264

265265
match unsized_part_of_type(cx.tcx(), t).sty {
266-
ty::ty_str | ty::ty_vec(..) => Type::uint_from_ty(cx, ast::TyUs(_)),
266+
ty::ty_str | ty::ty_vec(..) => Type::uint_from_ty(cx, ast::TyUs(false)),
267267
ty::ty_trait(_) => Type::vtable_ptr(cx),
268268
_ => panic!("Unexpected type returned from unsized_part_of_type : {}",
269269
t.repr(cx.tcx()))

branches/batch/src/libsyntax/feature_gate.rs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
9393
// OIBIT specific features
9494
("optin_builtin_traits", Active),
9595

96+
// int and uint are now deprecated
97+
("int_uint", Active),
98+
9699
// These are used to test this portion of the compiler, they don't actually
97100
// mean anything
98101
("test_accepted_feature", Accepted),
@@ -157,6 +160,14 @@ impl<'a> Context<'a> {
157160
}
158161
}
159162

163+
fn warn_feature(&self, feature: &str, span: Span, explain: &str) {
164+
if !self.has_feature(feature) {
165+
self.span_handler.span_warn(span, explain);
166+
self.span_handler.span_help(span, &format!("add #![feature({})] to the \
167+
crate attributes to silence this warning",
168+
feature)[]);
169+
}
170+
}
160171
fn has_feature(&self, feature: &str) -> bool {
161172
self.features.iter().any(|&n| n == feature)
162173
}
@@ -334,6 +345,31 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
334345
}
335346

336347
fn visit_ty(&mut self, t: &ast::Ty) {
348+
match t.node {
349+
ast::TyPath(ref p, _) => {
350+
match &*p.segments {
351+
352+
[ast::PathSegment { identifier, .. }] => {
353+
let name = token::get_ident(identifier);
354+
let msg = if name == "int" {
355+
Some("the `int` type is deprecated; \
356+
use `isize` or a fixed-sized integer")
357+
} else if name == "uint" {
358+
Some("the `unt` type is deprecated; \
359+
use `usize` or a fixed-sized integer")
360+
} else {
361+
None
362+
};
363+
364+
if let Some(msg) = msg {
365+
self.context.warn_feature("int_uint", t.span, msg)
366+
}
367+
}
368+
_ => {}
369+
}
370+
}
371+
_ => {}
372+
}
337373
visit::walk_ty(self, t);
338374
}
339375

@@ -345,6 +381,25 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
345381
"box expression syntax is experimental in alpha release; \
346382
you can call `Box::new` instead.");
347383
}
384+
ast::ExprLit(ref lit) => {
385+
match lit.node {
386+
ast::LitInt(_, ty) => {
387+
let msg = if let ast::SignedIntLit(ast::TyIs(true), _) = ty {
388+
Some("the `i` suffix on integers is deprecated; use `is` \
389+
or one of the fixed-sized suffixes")
390+
} else if let ast::UnsignedIntLit(ast::TyUs(true)) = ty {
391+
Some("the `u` suffix on integers is deprecated; use `us` \
392+
or one of the fixed-sized suffixes")
393+
} else {
394+
None
395+
};
396+
if let Some(msg) = msg {
397+
self.context.warn_feature("int_uint", e.span, msg);
398+
}
399+
}
400+
_ => {}
401+
}
402+
}
348403
_ => {}
349404
}
350405
visit::walk_expr(self, e);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2015 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+
#![allow(dead_code)]
12+
13+
mod u {
14+
type X = uint; //~ WARN the `uint` type is deprecated
15+
struct Foo {
16+
x: uint //~ WARN the `uint` type is deprecated
17+
}
18+
fn bar(x: uint) { //~ WARN the `uint` type is deprecated
19+
1u; //~ WARN the `u` suffix on integers is deprecated
20+
}
21+
}
22+
mod i {
23+
type X = int; //~ WARN the `int` type is deprecated
24+
struct Foo {
25+
x: int //~ WARN the `int` type is deprecated
26+
}
27+
fn bar(x: int) { //~ WARN the `int` type is deprecated
28+
1i; //~ WARN the `u` suffix on integers is deprecated
29+
}
30+
}
31+
32+
fn main() {
33+
// make compilation fail, after feature gating
34+
let () = 1u8; //~ ERROR
35+
}

0 commit comments

Comments
 (0)