Skip to content

Commit 3eeaa84

Browse files
committed
auto merge of #14628 : luqmana/rust/fcr, r=nikomatsakis
#14589.
2 parents 507c1a0 + 0a9eafa commit 3eeaa84

File tree

5 files changed

+46
-4
lines changed

5 files changed

+46
-4
lines changed

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
}

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) => {

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

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

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 {}

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)