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

Wut #1

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 25 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

14 changes: 11 additions & 3 deletions src/libextra/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#[allow(missing_doc)];

use std::cmp;
use std::hash::Hash;
use std::io;
use std::mem;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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) => ({
Expand Down Expand Up @@ -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 = &[
Expand Down
11 changes: 11 additions & 0 deletions src/librustc/middle/typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
12 changes: 12 additions & 0 deletions src/libstd/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions src/libstd/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
24 changes: 24 additions & 0 deletions src/test/compile-fail/issue-10877.rs
Original file line number Diff line number Diff line change
@@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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() {}