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

Fix a number of compiler ICEs #14321

Merged
merged 12 commits into from
May 22, 2014
7 changes: 5 additions & 2 deletions src/librustc/middle/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/middle/typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
18 changes: 7 additions & 11 deletions src/librustc/middle/typeck/check/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {}
}
}


Expand Down
3 changes: 2 additions & 1 deletion src/librustc/middle/typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 19 additions & 0 deletions src/test/compile-fail/issue-11844.rs
Original file line number Diff line number Diff line change
@@ -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!()
}
}

25 changes: 25 additions & 0 deletions src/test/compile-fail/issue-12116.rs
Original file line number Diff line number Diff line change
@@ -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() {}
19 changes: 19 additions & 0 deletions src/test/compile-fail/issue-12369.rs
Original file line number Diff line number Diff line change
@@ -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
};
}
23 changes: 23 additions & 0 deletions src/test/compile-fail/issue-12567.rs
Original file line number Diff line number Diff line change
@@ -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() {}
20 changes: 20 additions & 0 deletions src/test/compile-fail/issue-12796.rs
Original file line number Diff line number Diff line change
@@ -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() { }
14 changes: 14 additions & 0 deletions src/test/compile-fail/issue-14084.rs
Original file line number Diff line number Diff line change
@@ -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
}
14 changes: 14 additions & 0 deletions src/test/compile-fail/issue-14092.rs
Original file line number Diff line number Diff line change
@@ -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() {}

22 changes: 22 additions & 0 deletions src/test/compile-fail/issue-7092.rs
Original file line number Diff line number Diff line change
@@ -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(){}
17 changes: 17 additions & 0 deletions src/test/compile-fail/issue-8208.rs
Original file line number Diff line number Diff line change
@@ -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() {
}

13 changes: 13 additions & 0 deletions src/test/run-pass/issue-10763.rs
Original file line number Diff line number Diff line change
@@ -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() {}
35 changes: 35 additions & 0 deletions src/test/run-pass/issue-11736.rs
Original file line number Diff line number Diff line change
@@ -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] {
}
}
}

51 changes: 51 additions & 0 deletions src/test/run-pass/issue-6449.rs
Original file line number Diff line number Diff line change
@@ -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(..) => {}
}
}