diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 1017f4cfe2f..7b91928ba41 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -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::(); - 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, diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index cd3375799a3..ac37af05359 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -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(); diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index e9a95a4a9eb..cb3e900af7d 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -433,9 +433,10 @@ pub fn ast_ty_to_builtin_ty`") + supplied to `Box`"); + Some(ty::mk_err()) } _ => None } diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 839e3dd080a..9e8edfccd5b 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -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 => {} + } } diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 68f4fd95626..820c5bd859c 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -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()); } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c42febcd607..5829f63b2c5 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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. diff --git a/src/test/compile-fail/issue-11844.rs b/src/test/compile-fail/issue-11844.rs new file mode 100644 index 00000000000..4e11481b5d2 --- /dev/null +++ b/src/test/compile-fail/issue-11844.rs @@ -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 or the MIT license +// , 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!() + } +} + diff --git a/src/test/compile-fail/issue-12116.rs b/src/test/compile-fail/issue-12116.rs new file mode 100644 index 00000000000..a80e405d05c --- /dev/null +++ b/src/test/compile-fail/issue-12116.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum IntList { + Cons(int, Box), + 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() {} diff --git a/src/test/compile-fail/issue-12369.rs b/src/test/compile-fail/issue-12369.rs new file mode 100644 index 00000000000..7d800899e52 --- /dev/null +++ b/src/test/compile-fail/issue-12369.rs @@ -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 or the MIT license +// , 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 + }; +} diff --git a/src/test/compile-fail/issue-12567.rs b/src/test/compile-fail/issue-12567.rs new file mode 100644 index 00000000000..d5a8339ba19 --- /dev/null +++ b/src/test/compile-fail/issue-12567.rs @@ -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 or the MIT license +// , 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() {} diff --git a/src/test/compile-fail/issue-12796.rs b/src/test/compile-fail/issue-12796.rs new file mode 100644 index 00000000000..8b5fb90e2d4 --- /dev/null +++ b/src/test/compile-fail/issue-12796.rs @@ -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 or the MIT license +// , 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() { } diff --git a/src/test/compile-fail/issue-14084.rs b/src/test/compile-fail/issue-14084.rs new file mode 100644 index 00000000000..d247bf0913c --- /dev/null +++ b/src/test/compile-fail/issue-14084.rs @@ -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 or the MIT license +// , 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 +} diff --git a/src/test/compile-fail/issue-14092.rs b/src/test/compile-fail/issue-14092.rs new file mode 100644 index 00000000000..4d663d00fb2 --- /dev/null +++ b/src/test/compile-fail/issue-14092.rs @@ -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 or the MIT license +// , 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` + +fn main() {} + diff --git a/src/test/compile-fail/issue-7092.rs b/src/test/compile-fail/issue-7092.rs new file mode 100644 index 00000000000..bcecab80758 --- /dev/null +++ b/src/test/compile-fail/issue-7092.rs @@ -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 or the MIT license +// , 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(){} diff --git a/src/test/compile-fail/issue-8208.rs b/src/test/compile-fail/issue-8208.rs new file mode 100644 index 00000000000..8d8e87da76e --- /dev/null +++ b/src/test/compile-fail/issue-8208.rs @@ -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 or the MIT license +// , 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() { +} + diff --git a/src/test/run-pass/issue-10763.rs b/src/test/run-pass/issue-10763.rs new file mode 100644 index 00000000000..92ea6026ff6 --- /dev/null +++ b/src/test/run-pass/issue-10763.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern "Rust" fn foo() {} + +fn main() {} diff --git a/src/test/run-pass/issue-11736.rs b/src/test/run-pass/issue-11736.rs new file mode 100644 index 00000000000..4eb9dd1474e --- /dev/null +++ b/src/test/run-pass/issue-11736.rs @@ -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 or the MIT license +// , 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] { + } + } +} + diff --git a/src/test/run-pass/issue-6449.rs b/src/test/run-pass/issue-6449.rs new file mode 100644 index 00000000000..48e2890b259 --- /dev/null +++ b/src/test/run-pass/issue-6449.rs @@ -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 or the MIT license +// , 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(..) => {} + } +}