Skip to content

Commit b292942

Browse files
committed
---
yaml --- r: 66309 b: refs/heads/master c: 108739f h: refs/heads/master i: 66307: aa1aae4 v: v3
1 parent a42e978 commit b292942

File tree

4 files changed

+36
-24
lines changed

4 files changed

+36
-24
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 7b968783d79301af2305c0b1052092f9d31fd622
2+
refs/heads/master: 108739f533efd1a4faca62db1afb611f22c5f5f2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/src/libextra/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ type MonitorMsg = (TestDesc, TestResult);
423423
424424
fn run_tests(opts: &TestOpts,
425425
tests: ~[TestDescAndFn],
426-
callback: @fn(e: TestEvent)) {
426+
callback: &fn(e: TestEvent)) {
427427
428428
let filtered_tests = filter_tests(opts, tests);
429429
let filtered_descs = filtered_tests.map(|t| copy t.desc);

trunk/src/librustc/middle/kind.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,9 @@ pub fn check_expr(e: @expr, (cx, v): (Context, visit::vt<Context>)) {
293293
expr_cast(source, _) => {
294294
check_cast_for_escaping_regions(cx, source, e);
295295
match ty::get(ty::expr_ty(cx.tcx, e)).sty {
296-
ty::ty_trait(_, _, store, _, bounds) => {
296+
ty::ty_trait(_, _, _, _, bounds) => {
297297
let source_ty = ty::expr_ty(cx.tcx, source);
298-
check_trait_cast_bounds(cx, e.span, source_ty, bounds, store)
298+
check_trait_cast_bounds(cx, e.span, source_ty, bounds)
299299
}
300300
_ => { }
301301
}
@@ -391,19 +391,14 @@ pub fn check_freevar_bounds(cx: Context, sp: span, ty: ty::t,
391391
}
392392

393393
pub fn check_trait_cast_bounds(cx: Context, sp: span, ty: ty::t,
394-
bounds: ty::BuiltinBounds, store: ty::TraitStore) {
394+
bounds: ty::BuiltinBounds) {
395395
do check_builtin_bounds(cx, ty, bounds) |missing| {
396396
cx.tcx.sess.span_err(sp,
397397
fmt!("cannot pack type `%s`, which does not fulfill \
398398
`%s`, as a trait bounded by %s",
399399
ty_to_str(cx.tcx, ty), missing.user_string(cx.tcx),
400400
bounds.user_string(cx.tcx)));
401401
}
402-
// FIXME(#3569): Remove this check when the corresponding restriction
403-
// is made with type contents.
404-
if store == ty::UniqTraitStore && !ty::type_is_owned(cx.tcx, ty) {
405-
cx.tcx.sess.span_err(sp, "uniquely-owned trait objects must be sendable");
406-
}
407402
}
408403

409404
fn is_nullary_variant(cx: Context, ex: @expr) -> bool {

trunk/src/librustc/middle/ty.rs

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2063,20 +2063,8 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
20632063
TC_MANAGED + statically_sized(nonowned(tc_mt(cx, mt, cache)))
20642064
}
20652065

2066-
ty_trait(_, _, UniqTraitStore, _, _bounds) => {
2067-
// FIXME(#3569): Make this conditional on the trait's bounds.
2068-
TC_NONCOPY_TRAIT + TC_OWNED_POINTER
2069-
}
2070-
2071-
ty_trait(_, _, BoxTraitStore, mutbl, _bounds) => {
2072-
match mutbl {
2073-
ast::m_mutbl => TC_MANAGED + TC_MUTABLE,
2074-
_ => TC_MANAGED
2075-
}
2076-
}
2077-
2078-
ty_trait(_, _, RegionTraitStore(r), mutbl, _bounds) => {
2079-
borrowed_contents(r, mutbl)
2066+
ty_trait(_, _, store, mutbl, bounds) => {
2067+
trait_contents(store, mutbl, bounds)
20802068
}
20812069

20822070
ty_rptr(r, mt) => {
@@ -2278,6 +2266,35 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
22782266
st + rt + ot
22792267
}
22802268

2269+
fn trait_contents(store: TraitStore, mutbl: ast::mutability,
2270+
bounds: BuiltinBounds) -> TypeContents {
2271+
let st = match store {
2272+
UniqTraitStore => TC_OWNED_POINTER,
2273+
BoxTraitStore => TC_MANAGED,
2274+
RegionTraitStore(r) => borrowed_contents(r, mutbl),
2275+
};
2276+
let mt = match mutbl { ast::m_mutbl => TC_MUTABLE, _ => TC_NONE };
2277+
// We get additional "special type contents" for each bound that *isn't*
2278+
// on the trait. So iterate over the inverse of the bounds that are set.
2279+
// This is like with typarams below, but less "pessimistic" and also
2280+
// dependent on the trait store.
2281+
let mut bt = TC_NONE;
2282+
for (AllBuiltinBounds() - bounds).each |bound| {
2283+
bt = bt + match bound {
2284+
BoundCopy if store == UniqTraitStore
2285+
=> TC_NONCOPY_TRAIT,
2286+
BoundCopy => TC_NONE, // @Trait/&Trait are copyable either way
2287+
BoundStatic if bounds.contains_elem(BoundOwned)
2288+
=> TC_NONE, // Owned bound implies static bound.
2289+
BoundStatic => TC_BORROWED_POINTER, // Useful for "@Trait:'static"
2290+
BoundOwned => TC_NON_OWNED,
2291+
BoundConst => TC_MUTABLE,
2292+
BoundSized => TC_NONE, // don't care if interior is sized
2293+
};
2294+
}
2295+
st + mt + bt
2296+
}
2297+
22812298
fn type_param_def_to_contents(cx: ctxt,
22822299
type_param_def: &TypeParameterDef) -> TypeContents
22832300
{

0 commit comments

Comments
 (0)