Skip to content

Commit 45f2cff

Browse files
committed
---
yaml --- r: 152242 b: refs/heads/try2 c: d130acc h: refs/heads/master v: v3
1 parent 1a285db commit 45f2cff

File tree

9 files changed

+66
-27
lines changed

9 files changed

+66
-27
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 179fc6dbfd97eb59e92df84e80fa9354ce5eeea0
8+
refs/heads/try2: d130acc0d0e83bd0b4b94cda9d39dcbb67312526
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libregex/parse/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ pub fn parse(s: &str) -> Result<Ast, Error> {
201201

202202
impl<'a> Parser<'a> {
203203
fn parse(&mut self) -> Result<Ast, Error> {
204+
if self.chars.len() == 0 {
205+
return Ok(Nothing);
206+
}
204207
loop {
205208
let c = self.cur();
206209
match c {

branches/try2/src/libregex/test/tests.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ fn split() {
2828
assert_eq!(subs, vec!("cauchy", "plato", "tyler", "binx"));
2929
}
3030

31+
#[test]
32+
fn empty_regex_empty_match() {
33+
let re = regex!("");
34+
let ms = re.find_iter("").collect::<Vec<(uint, uint)>>();
35+
assert_eq!(ms, vec![(0, 0)]);
36+
}
37+
38+
#[test]
39+
fn empty_regex_nonempty_match() {
40+
let re = regex!("");
41+
let ms = re.find_iter("abc").collect::<Vec<(uint, uint)>>();
42+
assert_eq!(ms, vec![(0, 0), (1, 1), (2, 2), (3, 3)]);
43+
}
44+
3145
macro_rules! replace(
3246
($name:ident, $which:ident, $re:expr,
3347
$search:expr, $replace:expr, $result:expr) => (

branches/try2/src/librustc/back/archive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl<'a> Archive<'a> {
110110
lto: bool) -> io::IoResult<()> {
111111
let object = format!("{}.o", name);
112112
let bytecode = format!("{}.bc.deflate", name);
113-
let mut ignore = vec!(METADATA_FILENAME, bytecode.as_slice());
113+
let mut ignore = vec!(bytecode.as_slice(), METADATA_FILENAME);
114114
if lto {
115115
ignore.push(object.as_slice());
116116
}

branches/try2/src/librustc/middle/typeck/check/demand.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
use middle::ty;
1313
use middle::typeck::check::FnCtxt;
1414
use middle::typeck::infer;
15+
use middle::typeck::infer::resolve_type;
16+
use middle::typeck::infer::resolve::try_resolve_tvar_shallow;
1517

1618
use std::result::{Err, Ok};
1719
use std::result;
1820
use syntax::ast;
1921
use syntax::codemap::Span;
22+
use util::ppaux::Repr;
2023

2124
// Requires that the two types unify, and prints an error message if they
2225
// don't.
@@ -58,6 +61,13 @@ pub fn eqtype(fcx: &FnCtxt, sp: Span, expected: ty::t, actual: ty::t) {
5861
// Checks that the type `actual` can be coerced to `expected`.
5962
pub fn coerce(fcx: &FnCtxt, sp: Span, expected: ty::t, expr: &ast::Expr) {
6063
let expr_ty = fcx.expr_ty(expr);
64+
debug!("demand::coerce(expected = {}, expr_ty = {})",
65+
expected.repr(fcx.ccx.tcx),
66+
expr_ty.repr(fcx.ccx.tcx));
67+
let expected = if ty::type_needs_infer(expected) {
68+
resolve_type(fcx.infcx(), expected,
69+
try_resolve_tvar_shallow).unwrap_or(expected)
70+
} else { expected };
6171
match fcx.mk_assignty(expr, expr_ty, expected) {
6272
result::Ok(()) => { /* ok */ }
6373
result::Err(ref err) => {

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

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,6 @@ pub struct Inherited<'a> {
168168
upvar_borrow_map: RefCell<ty::UpvarBorrowMap>,
169169
}
170170

171-
#[deriving(Clone)]
172-
pub enum FnKind {
173-
// A do-closure.
174-
DoBlock,
175-
176-
// A normal closure or fn item.
177-
Vanilla
178-
}
179-
180171
#[deriving(Clone)]
181172
pub struct FnStyleState {
182173
pub def: ast::NodeId,
@@ -249,11 +240,6 @@ pub struct FnCtxt<'a> {
249240
// can actually be made to live as long as it needs to live.
250241
region_lb: Cell<ast::NodeId>,
251242

252-
// Says whether we're inside a for loop, in a do block
253-
// or neither. Helps with error messages involving the
254-
// function return type.
255-
fn_kind: FnKind,
256-
257243
inh: &'a Inherited<'a>,
258244

259245
ccx: &'a CrateCtxt<'a>,
@@ -289,7 +275,6 @@ fn blank_fn_ctxt<'a>(ccx: &'a CrateCtxt<'a>,
289275
ret_ty: rty,
290276
ps: RefCell::new(FnStyleState::function(ast::NormalFn, 0)),
291277
region_lb: Cell::new(region_bnd),
292-
fn_kind: Vanilla,
293278
inh: inh,
294279
ccx: ccx
295280
}
@@ -356,7 +341,7 @@ fn check_bare_fn(ccx: &CrateCtxt,
356341
ty::ty_bare_fn(ref fn_ty) => {
357342
let inh = Inherited::new(ccx.tcx, param_env);
358343
let fcx = check_fn(ccx, fn_ty.fn_style, &fn_ty.sig,
359-
decl, id, body, Vanilla, &inh);
344+
decl, id, body, &inh);
360345

361346
vtable::resolve_in_block(&fcx, body);
362347
regionck::regionck_fn(&fcx, body);
@@ -440,7 +425,6 @@ fn check_fn<'a>(ccx: &'a CrateCtxt<'a>,
440425
decl: &ast::FnDecl,
441426
id: ast::NodeId,
442427
body: &ast::Block,
443-
fn_kind: FnKind,
444428
inherited: &'a Inherited<'a>) -> FnCtxt<'a>
445429
{
446430
/*!
@@ -479,7 +463,6 @@ fn check_fn<'a>(ccx: &'a CrateCtxt<'a>,
479463
ret_ty: ret_ty,
480464
ps: RefCell::new(FnStyleState::function(fn_style, id)),
481465
region_lb: Cell::new(body.id),
482-
fn_kind: fn_kind,
483466
inh: inherited,
484467
ccx: ccx
485468
};
@@ -2295,7 +2278,6 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
22952278
store: ty::TraitStore,
22962279
decl: &ast::FnDecl,
22972280
body: ast::P<ast::Block>,
2298-
fn_kind: FnKind,
22992281
expected: Option<ty::t>) {
23002282
let tcx = fcx.ccx.tcx;
23012283

@@ -2373,7 +2355,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
23732355
};
23742356

23752357
check_fn(fcx.ccx, inherited_style, &fty_sig,
2376-
decl, id, body, fn_kind, fcx.inh);
2358+
decl, id, body, fcx.inh);
23772359
}
23782360

23792361

@@ -3044,7 +3026,6 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
30443026
ty::RegionTraitStore(region, ast::MutMutable),
30453027
decl,
30463028
body,
3047-
Vanilla,
30483029
expected);
30493030
}
30503031
ast::ExprProc(decl, body) => {
@@ -3053,7 +3034,6 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
30533034
ty::UniqTraitStore,
30543035
decl,
30553036
body,
3056-
Vanilla,
30573037
expected);
30583038
}
30593039
ast::ExprBlock(b) => {

branches/try2/src/test/compile-fail/issue-7573.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ impl CrateId {
2424
}
2525

2626
pub fn remove_package_from_database() {
27-
let mut lines_to_use: Vec<&CrateId> = Vec::new(); //~ ERROR cannot infer an appropriate lifetime
27+
let mut lines_to_use: Vec<&CrateId> = Vec::new();
2828
let push_id = |installed_id: &CrateId| {
2929
lines_to_use.push(installed_id);
30+
//~^ ERROR cannot infer an appropriate lifetime for automatic coercion due to
31+
// conflicting requirements
3032
};
3133
list_database(push_id);
3234

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
// All 3 expressions should work in that the argument gets
12+
// coerced to a trait object
13+
14+
fn main() {
15+
send::<Box<Foo>>(box Output(0));
16+
Test::<Box<Foo>>::foo(box Output(0));
17+
Test::<Box<Foo>>.send(box Output(0));
18+
}
19+
20+
fn send<T>(_: T) {}
21+
22+
struct Test<T>;
23+
impl<T> Test<T> {
24+
fn foo(_: T) {}
25+
fn send(&self, _: T) {}
26+
}
27+
28+
trait Foo {}
29+
struct Output(int);
30+
impl Foo for Output {}

branches/try2/src/test/run-pass/issue-4446.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ use std::io::println;
1313
pub fn main() {
1414
let (tx, rx) = channel();
1515

16+
tx.send("hello, world");
17+
1618
spawn(proc() {
1719
println(rx.recv());
1820
});
19-
20-
tx.send("hello, world");
2121
}

0 commit comments

Comments
 (0)