Skip to content

Commit 22e2204

Browse files
committed
auto merge of #14321 : alexcrichton/rust/ices, r=pcwalton
Also adding tests for fixed ICEs
2 parents f78eb14 + 0d4b840 commit 22e2204

18 files changed

+291
-18
lines changed

src/librustc/middle/check_match.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@Pat]) -> useful {
247247
_ => *r.get(0)
248248
}
249249
}
250+
None if v.len() == 0 => return not_useful,
250251
None => v[0]
251252
};
252253
let left_ty = if real_pat.id == 0 { ty::mk_nil() }
@@ -341,8 +342,10 @@ fn is_useful_specialized(cx: &MatchCheckCtxt,
341342
let ms = m.iter().filter_map(|r| {
342343
specialize(cx, r.as_slice(), &ctor, arity, lty)
343344
}).collect::<matrix>();
344-
let could_be_useful = is_useful(
345-
cx, &ms, specialize(cx, v, &ctor, arity, lty).unwrap().as_slice());
345+
let could_be_useful = match specialize(cx, v, &ctor, arity, lty) {
346+
Some(v) => is_useful(cx, &ms, v.as_slice()),
347+
None => return not_useful,
348+
};
346349
match could_be_useful {
347350
useful_ => useful(lty, ctor),
348351
u => u,

src/librustc/middle/resolve.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2040,7 +2040,7 @@ impl<'a> Resolver<'a> {
20402040
return;
20412041
}
20422042

2043-
let mut imports = module.imports.borrow_mut();
2043+
let imports = module.imports.borrow();
20442044
let import_count = imports.len();
20452045
while module.resolved_import_count.get() < import_count {
20462046
let import_index = module.resolved_import_count.get();

src/librustc/middle/typeck/astconv.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,10 @@ pub fn ast_ty_to_builtin_ty<AC:AstConv,
433433
}
434434
}))
435435
}
436-
this.tcx().sess.span_bug(path.span,
436+
this.tcx().sess.span_err(path.span,
437437
"not enough type parameters \
438-
supplied to `Box<T>`")
438+
supplied to `Box<T>`");
439+
Some(ty::mk_err())
439440
}
440441
_ => None
441442
}

src/librustc/middle/typeck/check/method.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -555,17 +555,13 @@ impl<'a> LookupContext<'a> {
555555
param_ty: param_ty) {
556556
debug!("push_inherent_candidates_from_param(param_ty={:?})",
557557
param_ty);
558-
self.push_inherent_candidates_from_bounds(
559-
rcvr_ty,
560-
self.fcx
561-
.inh
562-
.param_env
563-
.type_param_bounds
564-
.get(param_ty.idx)
565-
.trait_bounds
566-
.as_slice(),
567-
restrict_to,
568-
param_numbered(param_ty.idx));
558+
let i = param_ty.idx;
559+
match self.fcx.inh.param_env.type_param_bounds.as_slice().get(i) {
560+
Some(b) => self.push_inherent_candidates_from_bounds(
561+
rcvr_ty, b.trait_bounds.as_slice(), restrict_to,
562+
param_numbered(param_ty.idx)),
563+
None => {}
564+
}
569565
}
570566

571567

src/librustc/middle/typeck/check/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2767,7 +2767,8 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
27672767
if !checked {
27682768
tcx.sess.span_err(expr.span,
27692769
"only the managed heap and exchange heap are \
2770-
currently supported")
2770+
currently supported");
2771+
fcx.write_ty(id, ty::mk_err());
27712772
}
27722773
}
27732774

src/libsyntax/parse/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2920,7 +2920,7 @@ impl<'a> Parser<'a> {
29202920
_ => {}
29212921
}
29222922

2923-
if !is_ident_or_path(&self.token)
2923+
if (!is_ident_or_path(&self.token) && self.token != token::MOD_SEP)
29242924
|| self.is_keyword(keywords::True)
29252925
|| self.is_keyword(keywords::False) {
29262926
// Parse an expression pattern or exp .. exp.

src/test/compile-fail/issue-11844.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
let a = Some(box 1);
13+
match a {
14+
Ok(a) => //~ ERROR: mismatched types
15+
println!("{}",a), //~ ERROR: failed to find an implementation of trait
16+
None => fail!()
17+
}
18+
}
19+

src/test/compile-fail/issue-12116.rs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
enum IntList {
12+
Cons(int, Box<IntList>),
13+
Nil
14+
}
15+
16+
fn tail(source_list: &IntList) -> IntList {
17+
match source_list {
18+
&Cons(val, box ref next_list) => tail(next_list),
19+
&Cons(val, box Nil) => Cons(val, box Nil),
20+
//~^ ERROR: unreachable pattern
21+
_ => fail!()
22+
}
23+
}
24+
25+
fn main() {}

src/test/compile-fail/issue-12369.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
let sl = vec![1,2,3];
13+
let v: int = match sl.as_slice() {
14+
[] => 0,
15+
[a,b,c] => 3,
16+
[a, ..rest] => a,
17+
[10,a, ..rest] => 10 //~ ERROR: unreachable pattern
18+
};
19+
}

src/test/compile-fail/issue-12567.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn match_vecs<'a, T>(l1: &'a [T], l2: &'a [T]) {
12+
match (l1, l2) {
13+
([], []) => println!("both empty"),
14+
([], [hd, ..tl]) | ([hd, ..tl], []) => println!("one empty"),
15+
//~^ ERROR: cannot move out of dereference
16+
//~^^ ERROR: cannot move out of dereference
17+
([hd1, ..tl1], [hd2, ..tl2]) => println!("both nonempty"),
18+
//~^ ERROR: cannot move out of dereference
19+
//~^^ ERROR: cannot move out of dereference
20+
}
21+
}
22+
23+
fn main() {}

src/test/compile-fail/issue-12796.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// error-pattern: missing `Self` type param in the substitution of `fn(Self)`
12+
13+
trait Trait {
14+
fn outer(self) {
15+
fn inner(_: Self) {
16+
}
17+
}
18+
}
19+
20+
fn main() { }

src/test/compile-fail/issue-14084.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
box ( () ) 0;
13+
//~^ ERROR: only the managed heap and exchange heap are currently supported
14+
}

src/test/compile-fail/issue-14092.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn fn1(0: Box) {} //~ ERROR: not enough type parameters supplied to `Box<T>`
12+
13+
fn main() {}
14+

src/test/compile-fail/issue-7092.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
enum Whatever {
12+
}
13+
14+
fn foo(x: Whatever) {
15+
match x {
16+
Some(field) => field.access(),
17+
//~^ ERROR: mismatched types: expected `Whatever` but found
18+
//~^^ ERROR: does not implement any method in scope named `access`
19+
}
20+
}
21+
22+
fn main(){}

src/test/compile-fail/issue-8208.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(globs)]
12+
13+
use self::*; //~ ERROR: unresolved import
14+
15+
fn main() {
16+
}
17+

src/test/run-pass/issue-10763.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
extern "Rust" fn foo() {}
12+
13+
fn main() {}

src/test/run-pass/issue-11736.rs

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
extern crate collections;
12+
extern crate std;
13+
14+
use collections::Bitv;
15+
16+
fn main() {
17+
// Generate sieve of Eratosthenes for n up to 1e6
18+
let n = 1000000u;
19+
let sieve = Bitv::new(n+1, true);
20+
let limit: uint = (n as f32).sqrt() as uint;
21+
for i in range(2, limit+1) {
22+
if sieve[i] {
23+
let mut j = 0;
24+
while i*i + j*i <= n {
25+
sieve[i*i+j*i] = false;
26+
j += 1;
27+
}
28+
}
29+
}
30+
for i in range(2, n+1) {
31+
if sieve[i] {
32+
}
33+
}
34+
}
35+

src/test/run-pass/issue-6449.rs

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
enum Foo {
12+
Bar(int),
13+
Baz,
14+
}
15+
16+
enum Other {
17+
Other1(Foo),
18+
Other2(Foo, Foo),
19+
}
20+
21+
fn main() {
22+
match Baz {
23+
::Bar(3) => fail!(),
24+
::Bar(_) if false => fail!(),
25+
::Bar(..) if false => fail!(),
26+
::Bar(_n) => fail!(),
27+
::Baz => {}
28+
}
29+
match Bar(3) {
30+
::Bar(3) => {}
31+
::Bar(_) if false => fail!(),
32+
::Bar(..) if false => fail!(),
33+
::Bar(_n) => fail!(),
34+
::Baz => fail!(),
35+
}
36+
match Bar(4) {
37+
::Bar(3) => fail!(),
38+
::Bar(_) if false => fail!(),
39+
::Bar(..) if false => fail!(),
40+
::Bar(n) => assert_eq!(n, 4),
41+
::Baz => fail!(),
42+
}
43+
44+
match Other1(Baz) {
45+
::Other1(::Baz) => {}
46+
::Other1(::Bar(_)) => {}
47+
::Other2(::Baz, ::Bar(_)) => {}
48+
::Other2(::Bar(..), ::Baz) => {}
49+
::Other2(..) => {}
50+
}
51+
}

0 commit comments

Comments
 (0)