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

File tree

18 files changed

+291
-18
lines changed

18 files changed

+291
-18
lines changed

src/librustc/middle/check_match.rs

Lines changed: 5 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 7 additions & 11 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 19 additions & 0 deletions
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

Lines changed: 25 additions & 0 deletions
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

Lines changed: 19 additions & 0 deletions
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

Lines changed: 23 additions & 0 deletions
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() {}

0 commit comments

Comments
 (0)