Skip to content

Commit f90462d

Browse files
committed
---
yaml --- r: 63743 b: refs/heads/snap-stage3 c: e8151de h: refs/heads/master i: 63741: 713bc9a 63739: 69c33fb 63735: 3df4832 63727: 174f1d6 63711: 227233e 63679: abb0550 63615: d6ba531 63487: 70fb7a9 v: v3
1 parent b646898 commit f90462d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+258
-412
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 36d7f601d8d419ace8fdf14b2014a9cbf6245896
4+
refs/heads/snap-stage3: e8151de88ff7186d2eaf9b55be087343c148451d
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ endif
139139

140140
# version-string calculation
141141
CFG_GIT_DIR := $(CFG_SRC_DIR).git
142-
CFG_RELEASE = 0.6
142+
CFG_RELEASE = 0.7-pre
143143
CFG_VERSION = $(CFG_RELEASE)
144144

145145
ifneq ($(wildcard $(CFG_GIT)),)

branches/snap-stage3/src/libextra/io_util.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
use core::io::{Reader, BytesReader};
1212
use core::io;
13-
use core::cast;
1413

1514
/// An implementation of the io::Reader interface which reads a buffer of bytes
1615
pub struct BufReader {
@@ -30,13 +29,10 @@ impl BufReader {
3029
}
3130

3231
fn as_bytes_reader<A>(&self, f: &fn(&BytesReader) -> A) -> A {
33-
// XXX FIXME(#5723)
34-
let bytes = ::core::util::id::<&[u8]>(self.buf);
35-
let bytes: &'static [u8] = unsafe { cast::transmute(bytes) };
3632
// Recreating the BytesReader state every call since
3733
// I can't get the borrowing to work correctly
3834
let bytes_reader = BytesReader {
39-
bytes: bytes,
35+
bytes: ::core::util::id::<&[u8]>(self.buf),
4036
pos: @mut *self.pos
4137
};
4238

branches/snap-stage3/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);

branches/snap-stage3/src/librustc/metadata/csearch.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ use syntax::ast;
2424
use syntax::ast_map;
2525
use syntax::diagnostic::expect;
2626

27+
pub struct ProvidedTraitMethodInfo {
28+
ty: ty::Method,
29+
def_id: ast::def_id
30+
}
31+
2732
pub struct StaticMethodInfo {
2833
ident: ast::ident,
2934
def_id: ast::def_id,
@@ -129,7 +134,7 @@ pub fn get_trait_method_def_ids(cstore: @mut cstore::CStore,
129134

130135
pub fn get_provided_trait_methods(tcx: ty::ctxt,
131136
def: ast::def_id)
132-
-> ~[@ty::Method] {
137+
-> ~[ProvidedTraitMethodInfo] {
133138
let cstore = tcx.cstore;
134139
let cdata = cstore::get_crate_data(cstore, def.crate);
135140
decoder::get_provided_trait_methods(cstore.intr, cdata, def.node, tcx)

branches/snap-stage3/src/librustc/metadata/decoder.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use core::prelude::*;
1414

1515
use metadata::cstore::crate_metadata;
1616
use metadata::common::*;
17-
use metadata::csearch::StaticMethodInfo;
17+
use metadata::csearch::{ProvidedTraitMethodInfo, StaticMethodInfo};
1818
use metadata::csearch;
1919
use metadata::cstore;
2020
use metadata::decoder;
@@ -752,7 +752,7 @@ pub fn get_trait_method_def_ids(cdata: cmd,
752752

753753
pub fn get_provided_trait_methods(intr: @ident_interner, cdata: cmd,
754754
id: ast::node_id, tcx: ty::ctxt) ->
755-
~[@ty::Method] {
755+
~[ProvidedTraitMethodInfo] {
756756
let data = cdata.data;
757757
let item = lookup_item(id, data);
758758
let mut result = ~[];
@@ -763,8 +763,13 @@ pub fn get_provided_trait_methods(intr: @ident_interner, cdata: cmd,
763763

764764
if item_method_sort(mth) != 'p' { loop; }
765765

766-
vec::push(&mut result,
767-
@get_method(intr, cdata, did.node, tcx));
766+
let ty_method = get_method(intr, cdata, did.node, tcx);
767+
let provided_trait_method_info = ProvidedTraitMethodInfo {
768+
ty: ty_method,
769+
def_id: did
770+
};
771+
772+
vec::push(&mut result, provided_trait_method_info);
768773
}
769774

770775
return result;

branches/snap-stage3/src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
959959
encode_attributes(ebml_w, item.attrs);
960960
match ty.node {
961961
ast::ty_path(path, bounds, _) if path.idents.len() == 1 => {
962-
assert!(bounds.is_none());
962+
assert!(bounds.is_empty());
963963
encode_impl_type_basename(ecx, ebml_w,
964964
ast_util::path_to_ident(path));
965965
}

branches/snap-stage3/src/librustc/middle/kind.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ fn check_item(item: @item, (cx, visitor): (Context, visit::vt<Context>)) {
128128
// Yes, it's a destructor.
129129
match self_type.node {
130130
ty_path(_, bounds, path_node_id) => {
131-
assert!(bounds.is_none());
131+
assert!(bounds.is_empty());
132132
let struct_def = cx.tcx.def_map.get_copy(
133133
&path_node_id);
134134
let struct_did =
@@ -169,6 +169,10 @@ fn with_appropriate_checker(cx: Context, id: node_id,
169169
let id = ast_util::def_id_of_def(fv.def).node;
170170
let var_t = ty::node_id_to_type(cx.tcx, id);
171171

172+
// FIXME(#3569): Once closure capabilities are restricted based on their
173+
// incoming bounds, make this check conditional based on the bounds.
174+
if !check_owned(cx, var_t, fv.span) { return; }
175+
172176
// check that only immutable variables are implicitly copied in
173177
check_imm_free_var(cx, fv.def, fv.span);
174178

@@ -180,6 +184,10 @@ fn with_appropriate_checker(cx: Context, id: node_id,
180184
let id = ast_util::def_id_of_def(fv.def).node;
181185
let var_t = ty::node_id_to_type(cx.tcx, id);
182186

187+
// FIXME(#3569): Once closure capabilities are restricted based on their
188+
// incoming bounds, make this check conditional based on the bounds.
189+
if !check_durable(cx.tcx, var_t, fv.span) { return; }
190+
183191
// check that only immutable variables are implicitly copied in
184192
check_imm_free_var(cx, fv.def, fv.span);
185193

@@ -285,9 +293,9 @@ pub fn check_expr(e: @expr, (cx, v): (Context, visit::vt<Context>)) {
285293
expr_cast(source, _) => {
286294
check_cast_for_escaping_regions(cx, source, e);
287295
match ty::get(ty::expr_ty(cx.tcx, e)).sty {
288-
ty::ty_trait(_, _, _, _, bounds) => {
296+
ty::ty_trait(_, _, store, _, bounds) => {
289297
let source_ty = ty::expr_ty(cx.tcx, source);
290-
check_trait_cast_bounds(cx, e.span, source_ty, bounds)
298+
check_trait_cast_bounds(cx, e.span, source_ty, bounds, store)
291299
}
292300
_ => { }
293301
}
@@ -383,14 +391,19 @@ pub fn check_freevar_bounds(cx: Context, sp: span, ty: ty::t,
383391
}
384392

385393
pub fn check_trait_cast_bounds(cx: Context, sp: span, ty: ty::t,
386-
bounds: ty::BuiltinBounds) {
394+
bounds: ty::BuiltinBounds, store: ty::TraitStore) {
387395
do check_builtin_bounds(cx, ty, bounds) |missing| {
388396
cx.tcx.sess.span_err(sp,
389397
fmt!("cannot pack type `%s`, which does not fulfill \
390398
`%s`, as a trait bounded by %s",
391399
ty_to_str(cx.tcx, ty), missing.user_string(cx.tcx),
392400
bounds.user_string(cx.tcx)));
393401
}
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+
}
394407
}
395408

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

branches/snap-stage3/src/librustc/middle/resolve.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4195,19 +4195,15 @@ impl Resolver {
41954195
}
41964196
}
41974197

4198-
do bounds.map |bound_vec| {
4199-
for bound_vec.iter().advance |bound| {
4200-
self.resolve_type_parameter_bound(bound, visitor);
4201-
}
4202-
};
4198+
for bounds.iter().advance |bound| {
4199+
self.resolve_type_parameter_bound(bound, visitor);
4200+
}
42034201
}
42044202

42054203
ty_closure(c) => {
4206-
do c.bounds.map |bounds| {
4207-
for bounds.iter().advance |bound| {
4208-
self.resolve_type_parameter_bound(bound, visitor);
4209-
}
4210-
};
4204+
for c.bounds.iter().advance |bound| {
4205+
self.resolve_type_parameter_bound(bound, visitor);
4206+
}
42114207
visit_ty(ty, ((), visitor));
42124208
}
42134209

branches/snap-stage3/src/librustc/middle/trans/base.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,20 +1683,21 @@ pub fn copy_args_to_allocas(fcx: fn_ctxt,
16831683

16841684
match fcx.llself {
16851685
Some(slf) => {
1686-
let self_val = if slf.is_owned
1687-
&& datum::appropriate_mode(slf.t).is_by_value() {
1688-
let tmp = BitCast(bcx, slf.v, type_of(bcx.ccx(), slf.t));
1689-
let alloc = alloc_ty(bcx, slf.t);
1690-
Store(bcx, tmp, alloc);
1691-
alloc
1692-
} else {
1693-
PointerCast(bcx, slf.v, type_of(bcx.ccx(), slf.t).ptr_to())
1694-
};
1695-
1696-
fcx.llself = Some(ValSelfData {v: self_val, ..slf});
1697-
if slf.is_owned {
1698-
add_clean(bcx, self_val, slf.t);
1699-
}
1686+
// We really should do this regardless of whether self is owned, but
1687+
// it doesn't work right with default method impls yet. (FIXME: #2794)
1688+
if slf.is_owned {
1689+
let self_val = if datum::appropriate_mode(slf.t).is_by_value() {
1690+
let tmp = BitCast(bcx, slf.v, type_of(bcx.ccx(), slf.t));
1691+
let alloc = alloc_ty(bcx, slf.t);
1692+
Store(bcx, tmp, alloc);
1693+
alloc
1694+
} else {
1695+
PointerCast(bcx, slf.v, type_of(bcx.ccx(), slf.t).ptr_to())
1696+
};
1697+
1698+
fcx.llself = Some(ValSelfData {v: self_val, ..slf});
1699+
add_clean(bcx, self_val, slf.t);
1700+
}
17001701
}
17011702
_ => {}
17021703
}
@@ -2109,7 +2110,7 @@ pub fn trans_item(ccx: @mut CrateContext, item: &ast::item) {
21092110
}
21102111
ast::item_impl(ref generics, _, _, ref ms) => {
21112112
meth::trans_impl(ccx, /*bad*/copy *path, item.ident, *ms,
2112-
generics, item.id);
2113+
generics, None, item.id);
21132114
}
21142115
ast::item_mod(ref m) => {
21152116
trans_mod(ccx, m);

branches/snap-stage3/src/librustc/middle/trans/expr.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1051,8 +1051,14 @@ pub fn trans_local_var(bcx: block, def: ast::def) -> Datum {
10511051
debug!("def_self() reference, self_info.t=%s",
10521052
self_info.t.repr(bcx.tcx()));
10531053

1054+
// This cast should not be necessary. We should cast self *once*,
1055+
// but right now this conflicts with default methods.
1056+
let real_self_ty = monomorphize_type(bcx, self_info.t);
1057+
let llselfty = type_of::type_of(bcx.ccx(), real_self_ty).ptr_to();
1058+
1059+
let casted_val = PointerCast(bcx, self_info.v, llselfty);
10541060
Datum {
1055-
val: self_info.v,
1061+
val: casted_val,
10561062
ty: self_info.t,
10571063
mode: ByRef(ZeroMem)
10581064
}

branches/snap-stage3/src/librustc/middle/trans/meth.rs

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ pub fn trans_impl(ccx: @mut CrateContext,
4949
name: ast::ident,
5050
methods: &[@ast::method],
5151
generics: &ast::Generics,
52+
self_ty: Option<ty::t>,
5253
id: ast::node_id) {
5354
let _icx = push_ctxt("impl::trans_impl");
5455
let tcx = ccx.tcx;
5556

56-
debug!("trans_impl(path=%s, name=%s, id=%?)",
57-
path.repr(tcx), name.repr(tcx), id);
57+
debug!("trans_impl(path=%s, name=%s, self_ty=%s, id=%?)",
58+
path.repr(tcx), name.repr(tcx), self_ty.repr(tcx), id);
5859

5960
if !generics.ty_params.is_empty() { return; }
6061
let sub_path = vec::append_one(path, path_name(name));
@@ -64,10 +65,24 @@ pub fn trans_impl(ccx: @mut CrateContext,
6465
let path = vec::append_one(/*bad*/copy sub_path,
6566
path_name(method.ident));
6667

68+
let param_substs_opt;
69+
match self_ty {
70+
None => param_substs_opt = None,
71+
Some(self_ty) => {
72+
param_substs_opt = Some(@param_substs {
73+
tys: ~[],
74+
vtables: None,
75+
type_param_defs: @~[],
76+
self_ty: Some(self_ty)
77+
});
78+
}
79+
}
80+
6781
trans_method(ccx,
6882
path,
6983
*method,
70-
None,
84+
param_substs_opt,
85+
self_ty,
7186
llfn,
7287
ast_util::local_def(id));
7388
}
@@ -83,13 +98,17 @@ Translates a (possibly monomorphized) method body.
8398
- `method`: the AST node for the method
8499
- `param_substs`: if this is a generic method, the current values for
85100
type parameters and so forth, else none
101+
- `base_self_ty`: optionally, the explicit self type for this method. This
102+
will be none if this is not a default method and must always be present
103+
if this is a default method.
86104
- `llfn`: the LLVM ValueRef for the method
87105
- `impl_id`: the node ID of the impl this method is inside
88106
*/
89107
pub fn trans_method(ccx: @mut CrateContext,
90108
path: path,
91109
method: &ast::method,
92110
param_substs: Option<@param_substs>,
111+
base_self_ty: Option<ty::t>,
93112
llfn: ValueRef,
94113
impl_id: ast::def_id) {
95114
// figure out how self is being passed
@@ -100,14 +119,18 @@ pub fn trans_method(ccx: @mut CrateContext,
100119
_ => {
101120
// determine the (monomorphized) type that `self` maps to for
102121
// this method
103-
let self_ty = ty::node_id_to_type(ccx.tcx, method.self_id);
122+
let self_ty = match base_self_ty {
123+
None => ty::node_id_to_type(ccx.tcx, method.self_id),
124+
Some(provided_self_ty) => provided_self_ty,
125+
};
104126
let self_ty = match param_substs {
105127
None => self_ty,
106-
Some(@param_substs {tys: ref tys, self_ty: ref self_sub, _}) => {
107-
ty::subst_tps(ccx.tcx, *tys, *self_sub, self_ty)
128+
Some(@param_substs {tys: ref tys, _}) => {
129+
ty::subst_tps(ccx.tcx, *tys, None, self_ty)
108130
}
109131
};
110-
debug!("calling trans_fn with self_ty %s",
132+
debug!("calling trans_fn with base_self_ty %s, self_ty %s",
133+
base_self_ty.repr(ccx.tcx),
111134
self_ty.repr(ccx.tcx));
112135
match method.explicit_self.node {
113136
ast::sty_value => {

branches/snap-stage3/src/librustc/middle/trans/monomorphize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,14 @@ pub fn monomorphic_fn(ccx: @mut CrateContext,
233233
Some(override_impl_did) => impl_did = override_impl_did
234234
}
235235

236-
meth::trans_method(ccx, pt, mth, psubsts, d, impl_did);
236+
meth::trans_method(ccx, pt, mth, psubsts, None, d, impl_did);
237237
d
238238
}
239239
ast_map::node_trait_method(@ast::provided(mth), _, pt) => {
240240
let d = mk_lldecl();
241241
set_inline_hint_if_appr(/*bad*/copy mth.attrs, d);
242242
debug!("monomorphic_fn impl_did_opt is %?", impl_did_opt);
243-
meth::trans_method(ccx, /*bad*/copy *pt, mth, psubsts, d,
243+
meth::trans_method(ccx, /*bad*/copy *pt, mth, psubsts, None, d,
244244
impl_did_opt.get());
245245
d
246246
}

0 commit comments

Comments
 (0)