Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another rollup to cut down on the PR queue #8448

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b9945f8
Add #[inline] to impl Zero for ()
stepancheg Aug 8, 2013
f9b4228
add intrinsics for checked overflow add/sub/mul
thestinger Aug 7, 2013
a7849c4
make error messages conform to style guide
Aug 9, 2013
b9504d2
syntax: Shrink enum Token and enum nonterminal
Aug 9, 2013
2f3fde6
Implement an `address_insignificant` attribute
alexcrichton Aug 9, 2013
98dc7b1
Try to fix mac valgrind bot by disabling thread-heavy activities.
graydon Aug 9, 2013
b473ce3
rustc: Obey RUST_MIN_STACK env var
brson Aug 10, 2013
7a29aa5
vec: optimize the Add implementation
thestinger Aug 9, 2013
466a5b5
str: optimize `with_capacity`
thestinger Aug 10, 2013
61ae049
move `strdup_uniq` lang item to std::str
thestinger Aug 10, 2013
94b0b0e
Forbid pub/priv where it has no effect
alexcrichton Aug 9, 2013
5e0529b
Merge branch 'zero-unit-inline' of https://github.com/stepancheg/rust…
erickt Aug 10, 2013
62f8d5d
Merge branch 'checked' of https://github.com/thestinger/rust into rollup
erickt Aug 10, 2013
3c4a28a
Merge branch 'vector-add' of https://github.com/thestinger/rust into …
erickt Aug 10, 2013
4314860
Merge branch 'expect_found' of https://github.com/kud1ing/rust into r…
erickt Aug 11, 2013
b4b53de
Merge branch 'shrink-token' of https://github.com/blake2-ppc/rust int…
erickt Aug 10, 2013
82bbce9
Merge branch 'unnamed-addr' of https://github.com/alexcrichton/rust i…
erickt Aug 10, 2013
25886e5
Merge branch 'less-priv-again' of https://github.com/alexcrichton/rus…
erickt Aug 10, 2013
1b84e34
Merge branch 'mac-valgrind-thread-fixes' of https://github.com/graydo…
erickt Aug 10, 2013
3efd3a0
Merge branch 'rustc-stack' of https://github.com/brson/rust into rollup
erickt Aug 10, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/libextra/crypto/sha1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl Sha1 {
}

impl Digest for Sha1 {
pub fn reset(&mut self) {
fn reset(&mut self) {
self.length_bits = 0;
self.h[0] = 0x67452301u32;
self.h[1] = 0xEFCDAB89u32;
Expand All @@ -169,9 +169,9 @@ impl Digest for Sha1 {
self.buffer.reset();
self.computed = false;
}
pub fn input(&mut self, msg: &[u8]) { add_input(self, msg); }
pub fn result(&mut self, out: &mut [u8]) { return mk_result(self, out); }
pub fn output_bits(&self) -> uint { 160 }
fn input(&mut self, msg: &[u8]) { add_input(self, msg); }
fn result(&mut self, out: &mut [u8]) { return mk_result(self, out); }
fn output_bits(&self) -> uint { 160 }
}

#[cfg(test)]
Expand Down
4 changes: 2 additions & 2 deletions src/libextra/ebml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ pub mod reader {
self.pos = r_doc.end;
let str = r_doc.as_str_slice();
if lbl != str {
fail!("Expected label %s but found %s", lbl, str);
fail!("Expected label %s, found %s", lbl, str);
}
}
}
Expand All @@ -326,7 +326,7 @@ pub mod reader {
r_doc.start,
r_doc.end);
if r_tag != (exp_tag as uint) {
fail!("expected EBML doc with tag %? but found tag %?", exp_tag, r_tag);
fail!("expected EBML doc with tag %?, found tag %?", exp_tag, r_tag);
}
if r_doc.end > self.parent.end {
fail!("invalid EBML, child extends to 0x%x, parent to 0x%x",
Expand Down
8 changes: 4 additions & 4 deletions src/libextra/enum_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ pub struct EnumSet<E> {
/// An iterface for casting C-like enum to uint and back.
pub trait CLike {
/// Converts C-like enum to uint.
pub fn to_uint(&self) -> uint;
fn to_uint(&self) -> uint;
/// Converts uint to C-like enum.
pub fn from_uint(uint) -> Self;
fn from_uint(uint) -> Self;
}

fn bit<E:CLike>(e: E) -> uint {
Expand Down Expand Up @@ -142,11 +142,11 @@ mod test {
}

impl CLike for Foo {
pub fn to_uint(&self) -> uint {
fn to_uint(&self) -> uint {
*self as uint
}

pub fn from_uint(v: uint) -> Foo {
fn from_uint(v: uint) -> Foo {
unsafe { cast::transmute(v) }
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/num/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ impl ToStrRadix for BigUint {
impl FromStrRadix for BigUint {
/// Creates and initializes an BigUint.

pub fn from_str_radix(s: &str, radix: uint)
fn from_str_radix(s: &str, radix: uint)
-> Option<BigUint> {
BigUint::parse_bytes(s.as_bytes(), radix)
}
Expand Down
8 changes: 4 additions & 4 deletions src/libextra/terminfo/parser/compiled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub fn parse(file: @Reader, longnames: bool) -> Result<~TermInfo, ~str> {
// Check magic number
let magic = file.read_le_u16();
if (magic != 0x011A) {
return Err(fmt!("invalid magic number: expected %x but found %x", 0x011A, magic as uint));
return Err(fmt!("invalid magic number: expected %x, found %x", 0x011A, magic as uint));
}

let names_bytes = file.read_le_i16() as int;
Expand All @@ -196,19 +196,19 @@ pub fn parse(file: @Reader, longnames: bool) -> Result<~TermInfo, ~str> {
debug!("string_table_bytes = %?", string_table_bytes);

if (bools_bytes as uint) > boolnames.len() {
error!("expected bools_bytes to be less than %? but found %?", boolnames.len(),
error!("expected bools_bytes to be less than %?, found %?", boolnames.len(),
bools_bytes);
return Err(~"incompatible file: more booleans than expected");
}

if (numbers_count as uint) > numnames.len() {
error!("expected numbers_count to be less than %? but found %?", numnames.len(),
error!("expected numbers_count to be less than %?, found %?", numnames.len(),
numbers_count);
return Err(~"incompatible file: more numbers than expected");
}

if (string_offsets_count as uint) > stringnames.len() {
error!("expected string_offsets_count to be less than %? but found %?", stringnames.len(),
error!("expected string_offsets_count to be less than %?, found %?", stringnames.len(),
string_offsets_count);
return Err(~"incompatible file: more string offsets than expected");
}
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub struct Metric {
pub struct MetricMap(TreeMap<~str,Metric>);

impl Clone for MetricMap {
pub fn clone(&self) -> MetricMap {
fn clone(&self) -> MetricMap {
MetricMap((**self).clone())
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/treemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ impl<K: TotalOrd, V, T: Iterator<(K, V)>> Extendable<(K, V), T> for TreeMap<K, V
}

impl<T: TotalOrd, Iter: Iterator<T>> FromIterator<T, Iter> for TreeSet<T> {
pub fn from_iterator(iter: &mut Iter) -> TreeSet<T> {
fn from_iterator(iter: &mut Iter) -> TreeSet<T> {
let mut set = TreeSet::new();
set.extend(iter);
set
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ pub fn to_str(url: &Url) -> ~str {
}

impl ToStr for Url {
pub fn to_str(&self) -> ~str {
fn to_str(&self) -> ~str {
to_str(self)
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/librustc/lib/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2082,6 +2082,9 @@ pub mod llvm {
Elements: ValueRef,
RunTimeLang: c_uint)
-> ValueRef;

#[fast_ffi]
pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
}
}

Expand All @@ -2101,6 +2104,12 @@ pub fn SetLinkage(Global: ValueRef, Link: Linkage) {
}
}

pub fn SetUnnamedAddr(Global: ValueRef, Unnamed: bool) {
unsafe {
llvm::LLVMSetUnnamedAddr(Global, Unnamed as Bool);
}
}

pub fn ConstICmp(Pred: IntPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef {
unsafe {
llvm::LLVMConstICmp(Pred as c_ushort, V1, V2)
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/metadata/tydecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,12 +542,12 @@ pub fn parse_def_id(buf: &[u8]) -> ast::def_id {

let crate_num = match uint::parse_bytes(crate_part, 10u) {
Some(cn) => cn as int,
None => fail!("internal error: parse_def_id: crate number expected, but found %?",
None => fail!("internal error: parse_def_id: crate number expected, found %?",
crate_part)
};
let def_num = match uint::parse_bytes(def_part, 10u) {
Some(dn) => dn as int,
None => fail!("internal error: parse_def_id: id expected, but found %?",
None => fail!("internal error: parse_def_id: id expected, found %?",
def_part)
};
ast::def_id { crate: crate_num, node: def_num }
Expand Down
79 changes: 79 additions & 0 deletions src/librustc/middle/privacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
// Do not check privacy inside items with the resolve_unexported
// attribute. This is used for the test runner.
if !attr::contains_name(item.attrs, "!resolve_unexported") {
check_sane_privacy(tcx, item);
oldvisit::visit_item(item, (method_map, visitor));
}
},
Expand Down Expand Up @@ -540,3 +541,81 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
});
oldvisit::visit_crate(crate, (method_map, visitor));
}

/// Validates all of the visibility qualifers placed on the item given. This
/// ensures that there are no extraneous qualifiers that don't actually do
/// anything. In theory these qualifiers wouldn't parse, but that may happen
/// later on down the road...
fn check_sane_privacy(tcx: ty::ctxt, item: @ast::item) {
match item.node {
// implementations of traits don't need visibility qualifiers because
// that's controlled by having the trait in scope.
ast::item_impl(_, Some(*), _, ref methods) => {
for m in methods.iter() {
match m.vis {
ast::private | ast::public => {
tcx.sess.span_err(m.span, "unnecessary visibility")
}
ast::inherited => {}
}
}
}

ast::item_enum(ref def, _) => {
for v in def.variants.iter() {
match v.node.vis {
ast::public => {
if item.vis == ast::public {
tcx.sess.span_err(v.span, "unnecessary `pub` \
visibility");
}
}
ast::private => {
if item.vis != ast::public {
tcx.sess.span_err(v.span, "unnecessary `priv` \
visibility");
}
}
ast::inherited => {}
}
}
}

ast::item_struct(ref def, _) => {
for f in def.fields.iter() {
match f.node.kind {
ast::named_field(_, ast::public) => {
tcx.sess.span_err(f.span, "unnecessary `pub` \
visibility");
}
ast::named_field(_, ast::private) => {
// Fields should really be private by default...
}
ast::named_field(*) | ast::unnamed_field => {}
}
}
}

ast::item_trait(_, _, ref methods) => {
for m in methods.iter() {
match *m {
ast::provided(ref m) => {
match m.vis {
ast::private | ast::public => {
tcx.sess.span_err(m.span, "unnecessary \
visibility");
}
ast::inherited => {}
}
}
// this is warned about in the parser
ast::required(*) => {}
}
}
}

ast::item_impl(*) | ast::item_static(*) | ast::item_foreign_mod(*) |
ast::item_fn(*) | ast::item_mod(*) | ast::item_ty(*) |
ast::item_mac(*) => {}
}
}
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ fn assert_is_binding_or_wild(bcx: @mut Block, p: @ast::pat) {
if !pat_is_binding_or_wild(bcx.tcx().def_map, p) {
bcx.sess().span_bug(
p.span,
fmt!("Expected an identifier pattern but found p: %s",
fmt!("Expected an identifier pattern, found p: %s",
p.repr(bcx.tcx())));
}
}
Expand Down
90 changes: 76 additions & 14 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl<'self> StatRecorder<'self> {

#[unsafe_destructor]
impl<'self> Drop for StatRecorder<'self> {
pub fn drop(&self) {
fn drop(&self) {
if self.ccx.sess.trans_stats() {
let end = time::precise_time_ns();
let elapsed = ((end - self.start) / 1_000_000) as uint;
Expand Down Expand Up @@ -2180,19 +2180,18 @@ pub fn trans_item(ccx: @mut CrateContext, item: &ast::item) {
}
ast::item_static(_, m, expr) => {
consts::trans_const(ccx, m, item.id);
// 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
for attr in item.attrs.iter() {
if "static_assert" == attr.name() {
if m == ast::m_mutbl {
ccx.sess.span_fatal(expr.span,
"cannot have static_assert on a mutable static");
}
let v = ccx.const_values.get_copy(&item.id);
unsafe {
if !(llvm::LLVMConstIntGetZExtValue(v) as bool) {
ccx.sess.span_fatal(expr.span, "static assertion failed");
}
// 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 m == ast::m_mutbl {
ccx.sess.span_fatal(expr.span,
"cannot have static_assert on a mutable \
static");
}
let v = ccx.const_values.get_copy(&item.id);
unsafe {
if !(llvm::LLVMConstIntGetZExtValue(v) as bool) {
ccx.sess.span_fatal(expr.span, "static assertion failed");
}
}
}
Expand Down Expand Up @@ -2452,6 +2451,15 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef {
llvm::LLVMAddGlobal(ccx.llmod, llty, buf)
};

// Apply the `unnamed_addr` attribute if
// requested
if attr::contains_name(i.attrs,
"address_insignificant"){
lib::llvm::SetUnnamedAddr(g, true);
lib::llvm::SetLinkage(g,
lib::llvm::InternalLinkage);
}

ccx.item_symbols.insert(i.id, sym);
g
}
Expand Down Expand Up @@ -2740,6 +2748,60 @@ pub fn declare_intrinsics(llmod: ModuleRef) -> HashMap<&'static str, ValueRef> {
ifn!("llvm.bswap.i32",[Type::i32()], Type::i32());
ifn!("llvm.bswap.i64",[Type::i64()], Type::i64());

ifn!("llvm.sadd.with.overflow.i8",
[Type::i8(), Type::i8()], Type::struct_([Type::i8(), Type::i1()], false));
ifn!("llvm.sadd.with.overflow.i16",
[Type::i16(), Type::i16()], Type::struct_([Type::i16(), Type::i1()], false));
ifn!("llvm.sadd.with.overflow.i32",
[Type::i32(), Type::i32()], Type::struct_([Type::i32(), Type::i1()], false));
ifn!("llvm.sadd.with.overflow.i64",
[Type::i64(), Type::i64()], Type::struct_([Type::i64(), Type::i1()], false));

ifn!("llvm.uadd.with.overflow.i8",
[Type::i8(), Type::i8()], Type::struct_([Type::i8(), Type::i1()], false));
ifn!("llvm.uadd.with.overflow.i16",
[Type::i16(), Type::i16()], Type::struct_([Type::i16(), Type::i1()], false));
ifn!("llvm.uadd.with.overflow.i32",
[Type::i32(), Type::i32()], Type::struct_([Type::i32(), Type::i1()], false));
ifn!("llvm.uadd.with.overflow.i64",
[Type::i64(), Type::i64()], Type::struct_([Type::i64(), Type::i1()], false));

ifn!("llvm.ssub.with.overflow.i8",
[Type::i8(), Type::i8()], Type::struct_([Type::i8(), Type::i1()], false));
ifn!("llvm.ssub.with.overflow.i16",
[Type::i16(), Type::i16()], Type::struct_([Type::i16(), Type::i1()], false));
ifn!("llvm.ssub.with.overflow.i32",
[Type::i32(), Type::i32()], Type::struct_([Type::i32(), Type::i1()], false));
ifn!("llvm.ssub.with.overflow.i64",
[Type::i64(), Type::i64()], Type::struct_([Type::i64(), Type::i1()], false));

ifn!("llvm.usub.with.overflow.i8",
[Type::i8(), Type::i8()], Type::struct_([Type::i8(), Type::i1()], false));
ifn!("llvm.usub.with.overflow.i16",
[Type::i16(), Type::i16()], Type::struct_([Type::i16(), Type::i1()], false));
ifn!("llvm.usub.with.overflow.i32",
[Type::i32(), Type::i32()], Type::struct_([Type::i32(), Type::i1()], false));
ifn!("llvm.usub.with.overflow.i64",
[Type::i64(), Type::i64()], Type::struct_([Type::i64(), Type::i1()], false));

ifn!("llvm.smul.with.overflow.i8",
[Type::i8(), Type::i8()], Type::struct_([Type::i8(), Type::i1()], false));
ifn!("llvm.smul.with.overflow.i16",
[Type::i16(), Type::i16()], Type::struct_([Type::i16(), Type::i1()], false));
ifn!("llvm.smul.with.overflow.i32",
[Type::i32(), Type::i32()], Type::struct_([Type::i32(), Type::i1()], false));
ifn!("llvm.smul.with.overflow.i64",
[Type::i64(), Type::i64()], Type::struct_([Type::i64(), Type::i1()], false));

ifn!("llvm.umul.with.overflow.i8",
[Type::i8(), Type::i8()], Type::struct_([Type::i8(), Type::i1()], false));
ifn!("llvm.umul.with.overflow.i16",
[Type::i16(), Type::i16()], Type::struct_([Type::i16(), Type::i1()], false));
ifn!("llvm.umul.with.overflow.i32",
[Type::i32(), Type::i32()], Type::struct_([Type::i32(), Type::i1()], false));
ifn!("llvm.umul.with.overflow.i64",
[Type::i64(), Type::i64()], Type::struct_([Type::i64(), Type::i1()], false));

return intrinsics;
}

Expand Down
Loading