auto merge of #14321 : alexcrichton/rust/ices, r=pcwalton

Also adding tests for fixed ICEs
This commit is contained in:
bors 2014-05-21 23:31:27 -07:00
commit 22e2204c3d
18 changed files with 291 additions and 18 deletions

View File

@ -247,6 +247,7 @@ fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@Pat]) -> useful {
_ => *r.get(0)
}
}
None if v.len() == 0 => return not_useful,
None => v[0]
};
let left_ty = if real_pat.id == 0 { ty::mk_nil() }
@ -341,8 +342,10 @@ fn is_useful_specialized(cx: &MatchCheckCtxt,
let ms = m.iter().filter_map(|r| {
specialize(cx, r.as_slice(), &ctor, arity, lty)
}).collect::<matrix>();
let could_be_useful = is_useful(
cx, &ms, specialize(cx, v, &ctor, arity, lty).unwrap().as_slice());
let could_be_useful = match specialize(cx, v, &ctor, arity, lty) {
Some(v) => is_useful(cx, &ms, v.as_slice()),
None => return not_useful,
};
match could_be_useful {
useful_ => useful(lty, ctor),
u => u,

View File

@ -2040,7 +2040,7 @@ impl<'a> Resolver<'a> {
return;
}
let mut imports = module.imports.borrow_mut();
let imports = module.imports.borrow();
let import_count = imports.len();
while module.resolved_import_count.get() < import_count {
let import_index = module.resolved_import_count.get();

View File

@ -433,9 +433,10 @@ pub fn ast_ty_to_builtin_ty<AC:AstConv,
}
}))
}
this.tcx().sess.span_bug(path.span,
this.tcx().sess.span_err(path.span,
"not enough type parameters \
supplied to `Box<T>`")
supplied to `Box<T>`");
Some(ty::mk_err())
}
_ => None
}

View File

@ -555,17 +555,13 @@ impl<'a> LookupContext<'a> {
param_ty: param_ty) {
debug!("push_inherent_candidates_from_param(param_ty={:?})",
param_ty);
self.push_inherent_candidates_from_bounds(
rcvr_ty,
self.fcx
.inh
.param_env
.type_param_bounds
.get(param_ty.idx)
.trait_bounds
.as_slice(),
restrict_to,
param_numbered(param_ty.idx));
let i = param_ty.idx;
match self.fcx.inh.param_env.type_param_bounds.as_slice().get(i) {
Some(b) => self.push_inherent_candidates_from_bounds(
rcvr_ty, b.trait_bounds.as_slice(), restrict_to,
param_numbered(param_ty.idx)),
None => {}
}
}

View File

@ -2767,7 +2767,8 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
if !checked {
tcx.sess.span_err(expr.span,
"only the managed heap and exchange heap are \
currently supported")
currently supported");
fcx.write_ty(id, ty::mk_err());
}
}

View File

@ -2920,7 +2920,7 @@ impl<'a> Parser<'a> {
_ => {}
}
if !is_ident_or_path(&self.token)
if (!is_ident_or_path(&self.token) && self.token != token::MOD_SEP)
|| self.is_keyword(keywords::True)
|| self.is_keyword(keywords::False) {
// Parse an expression pattern or exp .. exp.

View File

@ -0,0 +1,19 @@
// 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.
fn main() {
let a = Some(box 1);
match a {
Ok(a) => //~ ERROR: mismatched types
println!("{}",a), //~ ERROR: failed to find an implementation of trait
None => fail!()
}
}

View File

@ -0,0 +1,25 @@
// Copyright 2012-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.
enum IntList {
Cons(int, Box<IntList>),
Nil
}
fn tail(source_list: &IntList) -> IntList {
match source_list {
&Cons(val, box ref next_list) => tail(next_list),
&Cons(val, box Nil) => Cons(val, box Nil),
//~^ ERROR: unreachable pattern
_ => fail!()
}
}
fn main() {}

View File

@ -0,0 +1,19 @@
// 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.
fn main() {
let sl = vec![1,2,3];
let v: int = match sl.as_slice() {
[] => 0,
[a,b,c] => 3,
[a, ..rest] => a,
[10,a, ..rest] => 10 //~ ERROR: unreachable pattern
};
}

View File

@ -0,0 +1,23 @@
// 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.
fn match_vecs<'a, T>(l1: &'a [T], l2: &'a [T]) {
match (l1, l2) {
([], []) => println!("both empty"),
([], [hd, ..tl]) | ([hd, ..tl], []) => println!("one empty"),
//~^ ERROR: cannot move out of dereference
//~^^ ERROR: cannot move out of dereference
([hd1, ..tl1], [hd2, ..tl2]) => println!("both nonempty"),
//~^ ERROR: cannot move out of dereference
//~^^ ERROR: cannot move out of dereference
}
}
fn main() {}

View File

@ -0,0 +1,20 @@
// 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.
// error-pattern: missing `Self` type param in the substitution of `fn(Self)`
trait Trait {
fn outer(self) {
fn inner(_: Self) {
}
}
}
fn main() { }

View File

@ -0,0 +1,14 @@
// 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.
fn main() {
box ( () ) 0;
//~^ ERROR: only the managed heap and exchange heap are currently supported
}

View File

@ -0,0 +1,14 @@
// 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.
fn fn1(0: Box) {} //~ ERROR: not enough type parameters supplied to `Box<T>`
fn main() {}

View File

@ -0,0 +1,22 @@
// 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.
enum Whatever {
}
fn foo(x: Whatever) {
match x {
Some(field) => field.access(),
//~^ ERROR: mismatched types: expected `Whatever` but found
//~^^ ERROR: does not implement any method in scope named `access`
}
}
fn main(){}

View File

@ -0,0 +1,17 @@
// 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.
#![feature(globs)]
use self::*; //~ ERROR: unresolved import
fn main() {
}

View File

@ -0,0 +1,13 @@
// 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.
extern "Rust" fn foo() {}
fn main() {}

View File

@ -0,0 +1,35 @@
// 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.
extern crate collections;
extern crate std;
use collections::Bitv;
fn main() {
// Generate sieve of Eratosthenes for n up to 1e6
let n = 1000000u;
let sieve = Bitv::new(n+1, true);
let limit: uint = (n as f32).sqrt() as uint;
for i in range(2, limit+1) {
if sieve[i] {
let mut j = 0;
while i*i + j*i <= n {
sieve[i*i+j*i] = false;
j += 1;
}
}
}
for i in range(2, n+1) {
if sieve[i] {
}
}
}

View File

@ -0,0 +1,51 @@
// Copyright 2012-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.
enum Foo {
Bar(int),
Baz,
}
enum Other {
Other1(Foo),
Other2(Foo, Foo),
}
fn main() {
match Baz {
::Bar(3) => fail!(),
::Bar(_) if false => fail!(),
::Bar(..) if false => fail!(),
::Bar(_n) => fail!(),
::Baz => {}
}
match Bar(3) {
::Bar(3) => {}
::Bar(_) if false => fail!(),
::Bar(..) if false => fail!(),
::Bar(_n) => fail!(),
::Baz => fail!(),
}
match Bar(4) {
::Bar(3) => fail!(),
::Bar(_) if false => fail!(),
::Bar(..) if false => fail!(),
::Bar(n) => assert_eq!(n, 4),
::Baz => fail!(),
}
match Other1(Baz) {
::Other1(::Baz) => {}
::Other1(::Bar(_)) => {}
::Other2(::Baz, ::Bar(_)) => {}
::Other2(::Bar(..), ::Baz) => {}
::Other2(..) => {}
}
}