Skip to content

Commit a8ec41b

Browse files
committed
---
yaml --- r: 130187 b: refs/heads/master c: d3e7922 h: refs/heads/master i: 130185: ca28d3b 130183: a666d96 v: v3
1 parent 6e69e00 commit a8ec41b

File tree

36 files changed

+550
-499
lines changed

36 files changed

+550
-499
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: b7bfe04b2d003d08f6ac450f41d7f221cb87f129
2+
refs/heads/master: d3e7922ddd5f2abfa4d5139e8bca5fab3e796f33
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 67b97ab6d2b7de9b69fd97dc171fcf8feec932ff
55
refs/heads/try: 28d5878c1f0465c11c8e7a3085008b0c592d48d0

trunk/src/driver/driver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
// except according to those terms.
1010

1111
#[cfg(rustdoc)]
12-
extern crate this = "rustdoc";
12+
extern crate "rustdoc" as this;
1313

1414
#[cfg(rustc)]
15-
extern crate this = "rustc";
15+
extern crate "rustc" as this;
1616

1717
fn main() { this::main() }

trunk/src/libcore/fmt/mod.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -461,19 +461,28 @@ impl<'a> Formatter<'a> {
461461
use char::Char;
462462
let align = match self.align {
463463
rt::AlignUnknown => default,
464-
rt::AlignLeft | rt::AlignRight => self.align
464+
_ => self.align
465465
};
466-
if align == rt::AlignLeft {
467-
try!(f(self));
468-
}
466+
467+
let (pre_pad, post_pad) = match align {
468+
rt::AlignLeft => (0u, padding),
469+
rt::AlignRight | rt::AlignUnknown => (padding, 0u),
470+
rt::AlignCenter => (padding / 2, (padding + 1) / 2),
471+
};
472+
469473
let mut fill = [0u8, ..4];
470474
let len = self.fill.encode_utf8(fill).unwrap_or(0);
471-
for _ in range(0, padding) {
475+
476+
for _ in range(0, pre_pad) {
472477
try!(self.buf.write(fill.slice_to(len)));
473478
}
474-
if align == rt::AlignRight {
475-
try!(f(self));
479+
480+
try!(f(self));
481+
482+
for _ in range(0, post_pad) {
483+
try!(self.buf.write(fill.slice_to(len)));
476484
}
485+
477486
Ok(())
478487
}
479488

trunk/src/libcore/fmt/rt.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ pub enum Alignment {
4343
AlignLeft,
4444
/// Indication that contents should be right-aligned.
4545
AlignRight,
46+
/// Indication that contents should be center-aligned.
47+
AlignCenter,
4648
/// No alignment was requested.
4749
AlignUnknown,
4850
}

trunk/src/libfmt_macros/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ pub enum Alignment {
8181
AlignLeft,
8282
/// The value will be aligned to the right.
8383
AlignRight,
84+
/// The value will be aligned in the center.
85+
AlignCenter,
8486
/// The value will take on a default alignment.
8587
AlignUnknown,
8688
}
@@ -279,7 +281,7 @@ impl<'a> Parser<'a> {
279281
match self.cur.clone().next() {
280282
Some((_, c)) => {
281283
match self.cur.clone().skip(1).next() {
282-
Some((_, '>')) | Some((_, '<')) => {
284+
Some((_, '>')) | Some((_, '<')) | Some((_, '^')) => {
283285
spec.fill = Some(c);
284286
self.cur.next();
285287
}
@@ -293,6 +295,8 @@ impl<'a> Parser<'a> {
293295
spec.align = AlignLeft;
294296
} else if self.consume('>') {
295297
spec.align = AlignRight;
298+
} else if self.consume('^') {
299+
spec.align = AlignCenter;
296300
}
297301
// Sign flags
298302
if self.consume('+') {

trunk/src/liblibc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4542,7 +4542,7 @@ pub mod funcs {
45424542
pub fn glob(pattern: *const c_char,
45434543
flags: c_int,
45444544
errfunc: ::Nullable<extern "C" fn(epath: *const c_char,
4545-
errno: c_int) -> int>,
4545+
errno: c_int) -> c_int>,
45464546
pglob: *mut glob_t);
45474547
pub fn globfree(pglob: *mut glob_t);
45484548
}

trunk/src/libnative/io/file_unix.rs

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl rtio::RtioFileStream for FileDesc {
154154

155155
fn fstat(&mut self) -> IoResult<rtio::FileStat> {
156156
let mut stat: libc::stat = unsafe { mem::zeroed() };
157-
match retry(|| unsafe { libc::fstat(self.fd(), &mut stat) }) {
157+
match unsafe { libc::fstat(self.fd(), &mut stat) } {
158158
0 => Ok(mkstat(&stat)),
159159
_ => Err(super::last_error()),
160160
}
@@ -346,9 +346,7 @@ pub fn open(path: &CString, fm: rtio::FileMode, fa: rtio::FileAccess)
346346
}
347347

348348
pub fn mkdir(p: &CString, mode: uint) -> IoResult<()> {
349-
super::mkerr_libc(retry(|| unsafe {
350-
libc::mkdir(p.as_ptr(), mode as libc::mode_t)
351-
}))
349+
super::mkerr_libc(unsafe { libc::mkdir(p.as_ptr(), mode as libc::mode_t) })
352350
}
353351

354352
pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
@@ -393,13 +391,11 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
393391
}
394392

395393
pub fn unlink(p: &CString) -> IoResult<()> {
396-
super::mkerr_libc(retry(|| unsafe { libc::unlink(p.as_ptr()) }))
394+
super::mkerr_libc(unsafe { libc::unlink(p.as_ptr()) })
397395
}
398396

399397
pub fn rename(old: &CString, new: &CString) -> IoResult<()> {
400-
super::mkerr_libc(retry(|| unsafe {
401-
libc::rename(old.as_ptr(), new.as_ptr())
402-
}))
398+
super::mkerr_libc(unsafe { libc::rename(old.as_ptr(), new.as_ptr()) })
403399
}
404400

405401
pub fn chmod(p: &CString, mode: uint) -> IoResult<()> {
@@ -409,9 +405,7 @@ pub fn chmod(p: &CString, mode: uint) -> IoResult<()> {
409405
}
410406

411407
pub fn rmdir(p: &CString) -> IoResult<()> {
412-
super::mkerr_libc(retry(|| unsafe {
413-
libc::rmdir(p.as_ptr())
414-
}))
408+
super::mkerr_libc(unsafe { libc::rmdir(p.as_ptr()) })
415409
}
416410

417411
pub fn chown(p: &CString, uid: int, gid: int) -> IoResult<()> {
@@ -428,10 +422,10 @@ pub fn readlink(p: &CString) -> IoResult<CString> {
428422
len = 1024; // FIXME: read PATH_MAX from C ffi?
429423
}
430424
let mut buf: Vec<u8> = Vec::with_capacity(len as uint);
431-
match retry(|| unsafe {
425+
match unsafe {
432426
libc::readlink(p, buf.as_ptr() as *mut libc::c_char,
433427
len as libc::size_t) as libc::c_int
434-
}) {
428+
} {
435429
-1 => Err(super::last_error()),
436430
n => {
437431
assert!(n > 0);
@@ -442,15 +436,11 @@ pub fn readlink(p: &CString) -> IoResult<CString> {
442436
}
443437

444438
pub fn symlink(src: &CString, dst: &CString) -> IoResult<()> {
445-
super::mkerr_libc(retry(|| unsafe {
446-
libc::symlink(src.as_ptr(), dst.as_ptr())
447-
}))
439+
super::mkerr_libc(unsafe { libc::symlink(src.as_ptr(), dst.as_ptr()) })
448440
}
449441

450442
pub fn link(src: &CString, dst: &CString) -> IoResult<()> {
451-
super::mkerr_libc(retry(|| unsafe {
452-
libc::link(src.as_ptr(), dst.as_ptr())
453-
}))
443+
super::mkerr_libc(unsafe { libc::link(src.as_ptr(), dst.as_ptr()) })
454444
}
455445

456446
fn mkstat(stat: &libc::stat) -> rtio::FileStat {
@@ -489,15 +479,15 @@ fn mkstat(stat: &libc::stat) -> rtio::FileStat {
489479

490480
pub fn stat(p: &CString) -> IoResult<rtio::FileStat> {
491481
let mut stat: libc::stat = unsafe { mem::zeroed() };
492-
match retry(|| unsafe { libc::stat(p.as_ptr(), &mut stat) }) {
482+
match unsafe { libc::stat(p.as_ptr(), &mut stat) } {
493483
0 => Ok(mkstat(&stat)),
494484
_ => Err(super::last_error()),
495485
}
496486
}
497487

498488
pub fn lstat(p: &CString) -> IoResult<rtio::FileStat> {
499489
let mut stat: libc::stat = unsafe { mem::zeroed() };
500-
match retry(|| unsafe { libc::lstat(p.as_ptr(), &mut stat) }) {
490+
match unsafe { libc::lstat(p.as_ptr(), &mut stat) } {
501491
0 => Ok(mkstat(&stat)),
502492
_ => Err(super::last_error()),
503493
}
@@ -508,9 +498,7 @@ pub fn utime(p: &CString, atime: u64, mtime: u64) -> IoResult<()> {
508498
actime: (atime / 1000) as libc::time_t,
509499
modtime: (mtime / 1000) as libc::time_t,
510500
};
511-
super::mkerr_libc(retry(|| unsafe {
512-
libc::utime(p.as_ptr(), &buf)
513-
}))
501+
super::mkerr_libc(unsafe { libc::utime(p.as_ptr(), &buf) })
514502
}
515503

516504
#[cfg(test)]

trunk/src/libregex/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@
372372
#![deny(missing_doc)]
373373

374374
#[cfg(test)]
375-
extern crate stdtest = "test";
375+
extern crate "test" as stdtest;
376376
#[cfg(test)]
377377
extern crate rand;
378378

trunk/src/librustc/front/std_inject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct StandardLibraryInjector<'a> {
6262
impl<'a> fold::Folder for StandardLibraryInjector<'a> {
6363
fn fold_crate(&mut self, mut krate: ast::Crate) -> ast::Crate {
6464

65-
// The name to use in `extern crate std = "name";`
65+
// The name to use in `extern crate "name" as std;`
6666
let actual_crate_name = match self.sess.opts.alt_std_name {
6767
Some(ref s) => token::intern_and_get_ident(s.as_slice()),
6868
None => token::intern_and_get_ident("std"),

trunk/src/librustc/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ extern crate flate;
4242
extern crate getopts;
4343
extern crate graphviz;
4444
extern crate libc;
45-
extern crate llvm = "rustc_llvm";
46-
extern crate rustc_back = "rustc_back";
45+
extern crate "rustc_llvm" as llvm;
46+
extern crate "rustc_back" as rustc_back;
4747
extern crate serialize;
4848
extern crate rbml;
4949
extern crate time;

trunk/src/librustc/lint/builtin.rs

Lines changed: 56 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ use syntax::attr;
4545
use syntax::codemap::Span;
4646
use syntax::parse::token;
4747
use syntax::{ast, ast_util, visit};
48+
use syntax::visit::Visitor;
4849

4950
declare_lint!(WHILE_TRUE, Warn,
5051
"suggest using `loop { }` instead of `while true { }`")
@@ -339,6 +340,51 @@ impl LintPass for TypeLimits {
339340
declare_lint!(CTYPES, Warn,
340341
"proper use of libc types in foreign modules")
341342

343+
struct CTypesVisitor<'a> {
344+
cx: &'a Context<'a>
345+
}
346+
347+
impl<'a> CTypesVisitor<'a> {
348+
fn check_def(&mut self, sp: Span, ty_id: ast::NodeId, path_id: ast::NodeId) {
349+
match self.cx.tcx.def_map.borrow().get_copy(&path_id) {
350+
def::DefPrimTy(ast::TyInt(ast::TyI)) => {
351+
self.cx.span_lint(CTYPES, sp,
352+
"found rust type `int` in foreign module, while \
353+
libc::c_int or libc::c_long should be used");
354+
}
355+
def::DefPrimTy(ast::TyUint(ast::TyU)) => {
356+
self.cx.span_lint(CTYPES, sp,
357+
"found rust type `uint` in foreign module, while \
358+
libc::c_uint or libc::c_ulong should be used");
359+
}
360+
def::DefTy(..) => {
361+
let tty = match self.cx.tcx.ast_ty_to_ty_cache.borrow().find(&ty_id) {
362+
Some(&ty::atttce_resolved(t)) => t,
363+
_ => fail!("ast_ty_to_ty_cache was incomplete after typeck!")
364+
};
365+
366+
if !ty::is_ffi_safe(self.cx.tcx, tty) {
367+
self.cx.span_lint(CTYPES, sp,
368+
"found type without foreign-function-safe
369+
representation annotation in foreign module, consider \
370+
adding a #[repr(...)] attribute to the type");
371+
}
372+
}
373+
_ => ()
374+
}
375+
}
376+
}
377+
378+
impl<'a> Visitor<()> for CTypesVisitor<'a> {
379+
fn visit_ty(&mut self, ty: &ast::Ty, _: ()) {
380+
match ty.node {
381+
ast::TyPath(_, _, id) => self.check_def(ty.span, ty.id, id),
382+
_ => (),
383+
}
384+
visit::walk_ty(self, ty, ());
385+
}
386+
}
387+
342388
pub struct CTypes;
343389

344390
impl LintPass for CTypes {
@@ -348,38 +394,8 @@ impl LintPass for CTypes {
348394

349395
fn check_item(&mut self, cx: &Context, it: &ast::Item) {
350396
fn check_ty(cx: &Context, ty: &ast::Ty) {
351-
match ty.node {
352-
ast::TyPath(_, _, id) => {
353-
match cx.tcx.def_map.borrow().get_copy(&id) {
354-
def::DefPrimTy(ast::TyInt(ast::TyI)) => {
355-
cx.span_lint(CTYPES, ty.span,
356-
"found rust type `int` in foreign module, while \
357-
libc::c_int or libc::c_long should be used");
358-
}
359-
def::DefPrimTy(ast::TyUint(ast::TyU)) => {
360-
cx.span_lint(CTYPES, ty.span,
361-
"found rust type `uint` in foreign module, while \
362-
libc::c_uint or libc::c_ulong should be used");
363-
}
364-
def::DefTy(..) => {
365-
let tty = match cx.tcx.ast_ty_to_ty_cache.borrow().find(&ty.id) {
366-
Some(&ty::atttce_resolved(t)) => t,
367-
_ => fail!("ast_ty_to_ty_cache was incomplete after typeck!")
368-
};
369-
370-
if !ty::is_ffi_safe(cx.tcx, tty) {
371-
cx.span_lint(CTYPES, ty.span,
372-
"found type without foreign-function-safe
373-
representation annotation in foreign module, consider \
374-
adding a #[repr(...)] attribute to the type");
375-
}
376-
}
377-
_ => ()
378-
}
379-
}
380-
ast::TyPtr(ref mt) => { check_ty(cx, &*mt.ty) }
381-
_ => {}
382-
}
397+
let mut vis = CTypesVisitor { cx: cx };
398+
vis.visit_ty(ty, ());
383399
}
384400

385401
fn check_foreign_fn(cx: &Context, decl: &ast::FnDecl) {
@@ -390,15 +406,15 @@ impl LintPass for CTypes {
390406
}
391407

392408
match it.node {
393-
ast::ItemForeignMod(ref nmod) if nmod.abi != abi::RustIntrinsic => {
394-
for ni in nmod.items.iter() {
395-
match ni.node {
396-
ast::ForeignItemFn(decl, _) => check_foreign_fn(cx, &*decl),
397-
ast::ForeignItemStatic(t, _) => check_ty(cx, &*t)
409+
ast::ItemForeignMod(ref nmod) if nmod.abi != abi::RustIntrinsic => {
410+
for ni in nmod.items.iter() {
411+
match ni.node {
412+
ast::ForeignItemFn(decl, _) => check_foreign_fn(cx, &*decl),
413+
ast::ForeignItemStatic(t, _) => check_ty(cx, &*t)
414+
}
398415
}
399416
}
400-
}
401-
_ => {/* nothing to do */ }
417+
_ => (),
402418
}
403419
}
404420
}
@@ -493,7 +509,7 @@ struct RawPtrDerivingVisitor<'a> {
493509
cx: &'a Context<'a>
494510
}
495511

496-
impl<'a> visit::Visitor<()> for RawPtrDerivingVisitor<'a> {
512+
impl<'a> Visitor<()> for RawPtrDerivingVisitor<'a> {
497513
fn visit_ty(&mut self, ty: &ast::Ty, _: ()) {
498514
static MSG: &'static str = "use of `#[deriving]` with a raw pointer";
499515
match ty.node {

0 commit comments

Comments
 (0)