diff --git a/.travis.yml b/.travis.yml index e124ca571def6..c742fc85be171 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,21 +5,28 @@ language: c # Before we start doing anything, install a stock LLVM install: - - sudo apt-get install llvm-3.3 llvm-3.3-dev clang-3.3 lldb-3.3 + - sudo sh -c "echo 'deb http://llvm.org/apt/precise/ llvm-toolchain-precise-3.4 main' >> /etc/apt/sources.list" + - sudo sh -c "echo 'deb http://llvm.org/apt/precise/ llvm-toolchain-precise main' >> /etc/apt/sources.list" + - sudo sh -c "echo 'deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu precise main' >> /etc/apt/sources.list" + - wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add - + - sudo apt-get update -qq + - sudo apt-get install -qq --force-yes -y llvm-$LLVM_VERSION + llvm-${LLVM_VERSION}-dev clang-$LLVM_VERSION lldb-$LLVM_VERSION -# All of the llvm tools are suffixed with "-3.3" which we don't want, so symlink -# them all into a local directory and just use that + +# All of the llvm tools are suffixed with "-$VERS" which we don't want, so +# symlink them all into a local directory and just use that # # FIXME: this shouldn't update the src/llvm sub-repo, that takes about a minute # it's gotta download so much stuff. before_script: - mkdir -p local-llvm/bin - - ln -nsf /usr/bin/llvm-config-3.3 local-llvm/bin/llvm-config - - ln -nsf /usr/bin/llvm-mc-3.3 local-llvm/bin/llvm-mc - - ln -nsf /usr/bin/llvm-as-3.3 local-llvm/bin/llvm-as - - ln -nsf /usr/bin/llvm-dis-3.3 local-llvm/bin/llvm-dis - - ln -nsf /usr/bin/llc-3.3 local-llvm/bin/llc - - ln -nsf /usr/include/llvm-3.3 local-llvm/include + - ln -nsf /usr/bin/llvm-config-$LLVM_VERSION local-llvm/bin/llvm-config + - ln -nsf /usr/bin/llvm-mc-$LLVM_VERSION local-llvm/bin/llvm-mc + - ln -nsf /usr/bin/llvm-as-$LLVM_VERSION local-llvm/bin/llvm-as + - ln -nsf /usr/bin/llvm-dis-$LLVM_VERSION local-llvm/bin/llvm-dis + - ln -nsf /usr/bin/llc-$LLVM_VERSION local-llvm/bin/llc + - ln -nsf /usr/include/llvm-$LLVM_VERSION local-llvm/include - ./configure --disable-optimize-tests --llvm-root=`pwd`/local-llvm --enable-fast-make --enable-clang # Tidy everything up first, then build a few things, and then run a few tests. @@ -29,14 +36,22 @@ before_script: # As a result of https://github.com/travis-ci/travis-ci/issues/1066, we run # everything in one large command instead of multiple commands. script: | + if [[ $TRAVIS_PULL_REQUEST != 'false' ]]; then + if [[ $LLVM_VERSION == '3.3' ]]; then exit 0; fi + fi && make tidy && make -j4 rustc-stage1 && make check-stage1-std check-stage1-rpass check-stage1-cfail check-stage1-rfail env: - - NO_BENCH=1 + global: + - NO_BENCH=1 + matrix: + - LLVM_VERSION=3.3 + - LLVM_VERSION=3.4 # We track this ourselves, and in theory we don't have to update the LLVM repo # (but sadly we do right now anyway). git: submodules: false + diff --git a/src/libextra/stats.rs b/src/libextra/stats.rs index 2450e22fc105d..23e3e104f164f 100644 --- a/src/libextra/stats.rs +++ b/src/libextra/stats.rs @@ -10,7 +10,6 @@ #[allow(missing_doc)]; -use std::cmp; use std::hash::Hash; use std::io; use std::mem; @@ -203,12 +202,12 @@ impl<'a> Stats for &'a [f64] { fn min(self) -> f64 { assert!(self.len() != 0); - self.iter().fold(self[0], |p,q| cmp::min(p, *q)) + self.iter().fold(self[0], |p, q| p.min(*q)) } fn max(self) -> f64 { assert!(self.len() != 0); - self.iter().fold(self[0], |p,q| cmp::max(p, *q)) + self.iter().fold(self[0], |p, q| p.max(*q)) } fn mean(self) -> f64 { @@ -442,6 +441,7 @@ mod tests { use stats::write_boxplot; use std::io; use std::str; + use std::f64; macro_rules! assert_approx_eq( ($a:expr, $b:expr) => ({ @@ -481,6 +481,14 @@ mod tests { assert_eq!(summ.iqr, summ2.iqr); } + #[test] + fn test_min_max_nan() { + let xs = &[1.0, 2.0, f64::NAN, 3.0, 4.0]; + let summary = Summary::new(xs); + assert_eq!(summary.min, 1.0); + assert_eq!(summary.max, 4.0); + } + #[test] fn test_norm2() { let val = &[ diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index f7733335c9177..e40ff6be66707 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -1040,12 +1040,23 @@ pub fn ty_of_foreign_fn_decl(ccx: &CrateCtxt, ast_generics: &ast::Generics, abis: AbiSet) -> ty::ty_param_bounds_and_ty { + + for i in decl.inputs.iter() { + match (*i).pat.node { + ast::PatIdent(_, _, _) => (), + ast::PatWild => (), + _ => ccx.tcx.sess.span_err((*i).pat.span, + "patterns aren't allowed in foreign function declarations") + } + } + let ty_generics = ty_generics(ccx, ast_generics, 0); let rb = BindingRscope::new(def_id.node); let input_tys = decl.inputs .iter() .map(|a| ty_of_arg(ccx, &rb, a, None)) .collect(); + let output_ty = ast_ty_to_ty(ccx, &rb, decl.output); let t_fn = ty::mk_bare_fn( diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index 9ec028b76b956..3ba3a9a134f68 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -866,6 +866,18 @@ mod tests { use num::*; use num; + #[test] + fn test_min_nan() { + assert_eq!(NAN.min(2.0), 2.0); + assert_eq!(2.0f32.min(NAN), 2.0); + } + + #[test] + fn test_max_nan() { + assert_eq!(NAN.max(2.0), 2.0); + assert_eq!(2.0f32.max(NAN), 2.0); + } + #[test] fn test_num() { num::test_num(10f32, 2f32); diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index d173abbcde1b3..b95188b07650d 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -865,6 +865,18 @@ mod tests { use num::*; use num; + #[test] + fn test_min_nan() { + assert_eq!(NAN.min(2.0), 2.0); + assert_eq!(2.0f64.min(NAN), 2.0); + } + + #[test] + fn test_max_nan() { + assert_eq!(NAN.max(2.0), 2.0); + assert_eq!(2.0f64.max(NAN), 2.0); + } + #[test] fn test_num() { num::test_num(10f64, 2f64); diff --git a/src/test/compile-fail/issue-10877.rs b/src/test/compile-fail/issue-10877.rs new file mode 100644 index 0000000000000..fd113908165b1 --- /dev/null +++ b/src/test/compile-fail/issue-10877.rs @@ -0,0 +1,24 @@ +// Copyright 2014 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. + +struct Foo { x: int } +extern { + fn foo(1: ()); + //~^ ERROR: patterns aren't allowed in foreign function declarations + fn bar((): int); + //~^ ERROR: patterns aren't allowed in foreign function declarations + fn baz(Foo { x }: int); + //~^ ERROR: patterns aren't allowed in foreign function declarations + fn qux((x,y): ()); + //~^ ERROR: patterns aren't allowed in foreign function declarations + fn this_is_actually_ok(a: uint); + fn and_so_is_this(_: uint); +} +fn main() {} \ No newline at end of file