Skip to content

Commit c23fa9d

Browse files
committed
---
yaml --- r: 63667 b: refs/heads/snap-stage3 c: 032dcc5 h: refs/heads/master i: 63665: 338d6ef 63663: eb6a56d v: v3
1 parent d442713 commit c23fa9d

File tree

23 files changed

+169
-66
lines changed

23 files changed

+169
-66
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: 663f29818310c7aad3b1501fe8eac6ca2379e037
4+
refs/heads/snap-stage3: 032dcc57e8876e960837c3a050be2c7570e7eafd
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/Makefile.in

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,29 +239,29 @@ $(foreach target,$(CFG_TARGET_TRIPLES),\
239239
# Standard library variables
240240
######################################################################
241241

242-
STDLIB_CRATE := $(S)src/libstd/core.rc
242+
STDLIB_CRATE := $(S)src/libstd/std.rs
243243
STDLIB_INPUTS := $(wildcard $(addprefix $(S)src/libstd/, \
244-
core.rc *.rs */*.rs */*/*rs */*/*/*rs))
244+
*.rs */*.rs */*/*rs */*/*/*rs))
245245

246246
######################################################################
247247
# Extra library variables
248248
######################################################################
249249

250-
EXTRALIB_CRATE := $(S)src/libextra/std.rc
250+
EXTRALIB_CRATE := $(S)src/libextra/extra.rs
251251
EXTRALIB_INPUTS := $(wildcard $(addprefix $(S)src/libextra/, \
252-
std.rc *.rs */*.rs))
252+
*.rs */*.rs))
253253

254254
######################################################################
255255
# rustc crate variables
256256
######################################################################
257257

258-
COMPILER_CRATE := $(S)src/librustc/rustc.rc
258+
COMPILER_CRATE := $(S)src/librustc/rustc.rs
259259
COMPILER_INPUTS := $(wildcard $(addprefix $(S)src/librustc/, \
260-
rustc.rc *.rs */*.rs */*/*.rs */*/*/*.rs))
260+
*.rs */*.rs */*/*.rs */*/*/*.rs))
261261

262-
LIBSYNTAX_CRATE := $(S)src/libsyntax/syntax.rc
262+
LIBSYNTAX_CRATE := $(S)src/libsyntax/syntax.rs
263263
LIBSYNTAX_INPUTS := $(wildcard $(addprefix $(S)src/libsyntax/, \
264-
syntax.rc *.rs */*.rs */*/*.rs))
264+
*.rs */*.rs */*/*.rs))
265265

266266
DRIVER_CRATE := $(S)src/driver/driver.rs
267267

branches/snap-stage3/mk/tools.mk

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@
1212
# and host architectures
1313

1414
# The test runner that runs the cfail/rfail/rpass and bxench tests
15-
COMPILETEST_CRATE := $(S)src/compiletest/compiletest.rc
16-
COMPILETEST_INPUTS := $(wildcard $(S)src/compiletest/*rs)
15+
COMPILETEST_CRATE := $(S)src/compiletest/compiletest.rs
16+
COMPILETEST_INPUTS := $(wildcard $(S)src/compiletest/*.rs)
1717

1818
# Rustpkg, the package manager and build system
19-
RUSTPKG_LIB := $(S)src/librustpkg/rustpkg.rc
20-
RUSTPKG_INPUTS := $(wildcard $(S)src/librustpkg/*rs)
19+
RUSTPKG_LIB := $(S)src/librustpkg/rustpkg.rs
20+
RUSTPKG_INPUTS := $(wildcard $(S)src/librustpkg/*.rs)
2121

2222
# Rustdoc, the documentation tool
23-
RUSTDOC_LIB := $(S)src/librustdoc/rustdoc.rc
23+
RUSTDOC_LIB := $(S)src/librustdoc/rustdoc.rs
2424
RUSTDOC_INPUTS := $(wildcard $(S)src/librustdoc/*.rs)
2525

2626
# Rusti, the JIT REPL
27-
RUSTI_LIB := $(S)src/librusti/rusti.rc
27+
RUSTI_LIB := $(S)src/librusti/rusti.rs
2828
RUSTI_INPUTS := $(wildcard $(S)src/librusti/*.rs)
2929

3030
# Rust, the convenience tool
31-
RUST_LIB := $(S)src/librust/rust.rc
31+
RUST_LIB := $(S)src/librust/rust.rs
3232
RUST_INPUTS := $(wildcard $(S)src/librust/*.rs)
3333

3434
# FIXME: These are only built for the host arch. Eventually we'll

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/middle/lint.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ pub enum lint {
9696

9797
missing_doc,
9898
unreachable_code,
99+
100+
warnings,
99101
}
100102

101103
pub fn level_to_str(lv: level) -> &'static str {
@@ -280,6 +282,13 @@ static lint_table: &'static [(&'static str, LintSpec)] = &[
280282
desc: "detects unreachable code",
281283
default: warn
282284
}),
285+
286+
("warnings",
287+
LintSpec {
288+
lint: warnings,
289+
desc: "mass-change the level for lints which produce warnings",
290+
default: warn
291+
}),
283292
];
284293

285294
/*
@@ -362,10 +371,11 @@ impl Context {
362371

363372
fn span_lint(&self, lint: lint, span: span, msg: &str) {
364373
let (level, src) = match self.curr.find(&(lint as uint)) {
374+
None => { return }
375+
Some(&(warn, src)) => (self.get_level(warnings), src),
365376
Some(&pair) => pair,
366-
None => { return; }
367377
};
368-
if level == allow { return; }
378+
if level == allow { return }
369379

370380
let mut note = None;
371381
let msg = match src {

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
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3649,21 +3649,21 @@ pub fn def_has_ty_params(def: ast::def) -> bool {
36493649
}
36503650
}
36513651

3652-
pub fn provided_trait_methods(cx: ctxt, id: ast::def_id) -> ~[@Method] {
3652+
pub fn provided_trait_methods(cx: ctxt, id: ast::def_id) -> ~[ast::ident] {
36533653
if is_local(id) {
36543654
match cx.items.find(&id.node) {
36553655
Some(&ast_map::node_item(@ast::item {
36563656
node: item_trait(_, _, ref ms),
36573657
_
36583658
}, _)) =>
36593659
match ast_util::split_trait_methods(*ms) {
3660-
(_, p) => p.map(|m| method(cx, ast_util::local_def(m.id)))
3660+
(_, p) => p.map(|method| method.ident)
36613661
},
36623662
_ => cx.sess.bug(fmt!("provided_trait_methods: %? is not a trait",
36633663
id))
36643664
}
36653665
} else {
3666-
csearch::get_provided_trait_methods(cx, id)
3666+
csearch::get_provided_trait_methods(cx, id).map(|ifo| ifo.ty.ident)
36673667
}
36683668
}
36693669

0 commit comments

Comments
 (0)