From 4a22c3368fe4fd570859fbbf03b971f4913a8569 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 28 Feb 2015 22:44:10 +0800 Subject: Fix assuming 32-bit pointers --- src/libcore/fmt/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 117b829fdff..9544fbaa55b 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -700,7 +700,7 @@ impl Display for char { impl Pointer for *const T { fn fmt(&self, f: &mut Formatter) -> Result { f.flags |= 1 << (FlagV1::Alternate as u32); - let ret = LowerHex::fmt(&(*self as u32), f); + let ret = LowerHex::fmt(&(*self as usize), f); f.flags &= !(1 << (FlagV1::Alternate as u32)); ret } -- cgit 1.4.1-3-g733a5 From c22d026326f10f8a4e60d49c6fbf37de3c970a78 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 28 Feb 2015 22:51:29 +0800 Subject: ifmt - Add a basic test for {:p} getting truncated --- src/test/run-pass/ifmt.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index ab83fb90d3f..d54de8824e0 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -137,6 +137,13 @@ pub fn main() { t!(format!("{:+10.3e}", 1.2345e6f64), " +1.234e6"); t!(format!("{:+10.3e}", -1.2345e6f64), " -1.234e6"); + // Test that pointers don't get truncated. + { + let val = usize::MAX; + let exp = format!("{:#x}", val); + t!(format!("{:p}", val as *const isize), exp); + } + // Escaping t!(format!("{{"), "{"); t!(format!("}}"), "}"); -- cgit 1.4.1-3-g733a5 From 28362d542d2561c4cc16cb3229ce3fed7317dbd6 Mon Sep 17 00:00:00 2001 From: Sébastien Marie Date: Mon, 23 Feb 2015 19:58:48 +0100 Subject: openbsd: adjust page guard address some commits in OpenBSD base have corrected a problem of stack position. Now, we can adjust more accurately the page guard in rust. --- src/libstd/sys/unix/thread.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs index f4791d39da1..827e2afdca8 100644 --- a/src/libstd/sys/unix/thread.rs +++ b/src/libstd/sys/unix/thread.rs @@ -164,7 +164,7 @@ pub mod guard { if pthread_main_np() == 1 { // main thread - current_stack.ss_sp as uint - current_stack.ss_size as uint + 3 * PAGE_SIZE as uint + current_stack.ss_sp as uint - current_stack.ss_size as uint + PAGE_SIZE as uint } else { // new thread -- cgit 1.4.1-3-g733a5 From d11b48c85c1cceb559ab8a08815ba3f7b3312c44 Mon Sep 17 00:00:00 2001 From: Björn Steinbrink Date: Sat, 28 Feb 2015 19:22:24 +0100 Subject: Error out when using static_assert on a non-boolean value static_assert is documented as working on static with type `bool`, but we currently accept it on any const static and crash when the const has an non-integral type. This is a breaking-change for anyone who used static_assert on types likes i32, which happened to work but seems like an unintended consequence of the missing error checking. [breaking-change] Fixes #22056 --- src/librustc_trans/trans/base.rs | 5 +++++ src/test/compile-fail/nonbool_static_assert.rs | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/test/compile-fail/nonbool_static_assert.rs (limited to 'src') diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index b18b7b75d32..d1722de90fb 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -2332,6 +2332,11 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) { // Do static_assert checking. It can't really be done much earlier // because we need to get the value of the bool out of LLVM if attr::contains_name(&item.attrs, "static_assert") { + if !ty::type_is_bool(ty::expr_ty(ccx.tcx(), expr)) { + ccx.sess().span_fatal(expr.span, + "can only have static_assert on a static \ + with type `bool`"); + } if m == ast::MutMutable { ccx.sess().span_fatal(expr.span, "cannot have static_assert on a mutable \ diff --git a/src/test/compile-fail/nonbool_static_assert.rs b/src/test/compile-fail/nonbool_static_assert.rs new file mode 100644 index 00000000000..d85f58edc90 --- /dev/null +++ b/src/test/compile-fail/nonbool_static_assert.rs @@ -0,0 +1,16 @@ +// Copyright 2015 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. + +#![allow(dead_code)] + +#[static_assert] +static E: i32 = 1; //~ ERROR can only have static_assert on a static with type `bool` + +fn main() {} -- cgit 1.4.1-3-g733a5 From 000e9768198c8f82f625215be36e25ffce470a6a Mon Sep 17 00:00:00 2001 From: mdinger Date: Sat, 28 Feb 2015 14:05:50 -0500 Subject: Fix incorrectly parsed markdown link --- src/libcollections/str.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index c58cca828d8..86fcac3e4b8 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -1455,9 +1455,9 @@ pub trait StrExt: Index { /// /// `is_cjk` determines behavior for characters in the Ambiguous category: if `is_cjk` is /// `true`, these are 2 columns wide; otherwise, they are 1. In CJK locales, `is_cjk` should be - /// `true`, else it should be `false`. [Unicode Standard Annex - /// #11](http://www.unicode.org/reports/tr11/) recommends that these characters be treated as 1 - /// column (i.e., `is_cjk` = `false`) if the locale is unknown. + /// `true`, else it should be `false`. + /// [Unicode Standard Annex #11](http://www.unicode.org/reports/tr11/) recommends that these + /// characters be treated as 1 column (i.e., `is_cjk = false`) if the locale is unknown. #[unstable(feature = "collections", reason = "this functionality may only be provided by libunicode")] fn width(&self, is_cjk: bool) -> usize { -- cgit 1.4.1-3-g733a5 From 0b5ca7850bd62a2558a4efb7de0c12dfe1f4fb8e Mon Sep 17 00:00:00 2001 From: Björn Steinbrink Date: Sat, 28 Feb 2015 22:40:39 +0100 Subject: Re-enable -Z time-llvm-passes when using a single codegen unit The timing code break when using multiple codegen units, but that shouldn't stop us from using it with a single codegen unit. --- src/librustc_trans/back/write.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index a1fc63778ce..cd14fe529b1 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -851,7 +851,9 @@ pub fn run_passes(sess: &Session, // FIXME: time_llvm_passes support - does this use a global context or // something? - //if sess.time_llvm_passes() { llvm::LLVMRustPrintPassTimings(); } + if sess.opts.cg.codegen_units == 1 && sess.time_llvm_passes() { + unsafe { llvm::LLVMRustPrintPassTimings(); } + } } struct WorkItem { -- cgit 1.4.1-3-g733a5 From 4495bdb52c58e8653861650b5c4b1fd79595c51f Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Sun, 1 Mar 2015 01:45:53 +0530 Subject: Add import of usize (fixup #22901) --- src/test/run-pass/ifmt.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index d54de8824e0..62b8ff528a5 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -17,6 +17,7 @@ #![feature(box_syntax)] use std::fmt; +use std::usize; struct A; struct B; -- cgit 1.4.1-3-g733a5