Skip to content

Commit 6a37e2c

Browse files
committed
---
yaml --- r: 65502 b: refs/heads/master c: f6fa5b9 h: refs/heads/master v: v3
1 parent d2ea33a commit 6a37e2c

File tree

9 files changed

+159
-125
lines changed

9 files changed

+159
-125
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: 18bee38bbea9ffc784a5857b6f819b1b529b22fc
2+
refs/heads/master: f6fa5b91e25fb24397d1e2eaf26e476b4041c65c
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/mk/tests.mk

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,8 @@ CFG_ADB_TEST_DIR=/data/tmp
122122
$(info check: android device test dir $(CFG_ADB_TEST_DIR) ready \
123123
$(shell adb remount 1>/dev/null) \
124124
$(shell adb shell mkdir $(CFG_ADB_TEST_DIR) 1>/dev/null) \
125-
$(shell adb shell rm $(CFG_ADB_TEST_DIR)/*.so 1>/dev/null) \
126-
$(shell adb shell rm $(CFG_ADB_TEST_DIR)/*-arm-linux-androideabi 1>/dev/null) \
127-
$(shell adb shell rm $(CFG_ADB_TEST_DIR)/*-arm-linux-androideabi.* 1>/dev/null) \
128-
$(shell adb push $(S)src/etc/adb_run_wrapper.sh $(CFG_ADB_TEST_DIR) 1>/dev/null) \
129125
$(shell adb push $(CFG_ANDROID_CROSS_PATH)/arm-linux-androideabi/lib/armv7-a/libgnustl_shared.so \
130126
$(CFG_ADB_TEST_DIR) 1>/dev/null) \
131-
$(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(CFG_RUNTIME_arm-linux-androideabi) \
132-
$(CFG_ADB_TEST_DIR)) \
133-
$(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(STDLIB_GLOB_arm-linux-androideabi) \
134-
$(CFG_ADB_TEST_DIR)) \
135-
$(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD_TRIPLE))/$(EXTRALIB_GLOB_arm-linux-androideabi) \
136-
$(CFG_ADB_TEST_DIR)) \
137127
)
138128
else
139129
CFG_ADB_TEST_DIR=

trunk/src/compiletest/runtest.rs

Lines changed: 35 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -753,62 +753,53 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
753753
copy_result.out, copy_result.err));
754754
}
755755

756+
// execute program
756757
logv(config, fmt!("executing (%s) %s", config.target, cmdline));
757758

758-
let mut runargs = ~[];
759+
// adb shell dose not forward stdout and stderr of internal result
760+
// to stdout and stderr separately but to stdout only
761+
let mut newargs_out = ~[];
762+
let mut newargs_err = ~[];
763+
newargs_out.push(~"shell");
764+
newargs_err.push(~"shell");
759765

760-
// run test via adb_run_wrapper
761-
runargs.push(~"shell");
762-
runargs.push(fmt!("%s/adb_run_wrapper.sh", config.adb_test_dir));
763-
runargs.push(fmt!("%s", config.adb_test_dir));
764-
runargs.push(fmt!("%s", prog_short));
766+
let mut newcmd_out = ~"";
767+
let mut newcmd_err = ~"";
765768

766-
for args.args.each |tv| {
767-
runargs.push(tv.to_owned());
768-
}
769-
770-
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~""));
771-
772-
// get exitcode of result
773-
runargs = ~[];
774-
runargs.push(~"shell");
775-
runargs.push(~"cat");
776-
runargs.push(fmt!("%s/%s.exitcode", config.adb_test_dir, prog_short));
769+
newcmd_out.push_str(fmt!("LD_LIBRARY_PATH=%s %s/%s",
770+
config.adb_test_dir, config.adb_test_dir, prog_short));
777771

778-
let procsrv::Result{ out: exitcode_out, err: _, status: _ } =
779-
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")],
780-
Some(~""));
772+
newcmd_err.push_str(fmt!("LD_LIBRARY_PATH=%s %s/%s",
773+
config.adb_test_dir, config.adb_test_dir, prog_short));
781774

782-
let mut exitcode : int = 0;
783-
for str::each_char(exitcode_out) |c| {
784-
if !c.is_digit() { break; }
785-
exitcode = exitcode * 10 + match c {
786-
'0' .. '9' => c as int - ('0' as int),
787-
_ => 101,
788-
}
775+
for args.args.each |tv| {
776+
newcmd_out.push_str(" ");
777+
newcmd_err.push_str(" ");
778+
newcmd_out.push_str(*tv);
779+
newcmd_err.push_str(*tv);
789780
}
790781

791-
// get stdout of result
792-
runargs = ~[];
793-
runargs.push(~"shell");
794-
runargs.push(~"cat");
795-
runargs.push(fmt!("%s/%s.stdout", config.adb_test_dir, prog_short));
782+
newcmd_out.push_str(" 2>/dev/null");
783+
newcmd_err.push_str(" 1>/dev/null");
796784

797-
let procsrv::Result{ out: stdout_out, err: _, status: _ } =
798-
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~""));
785+
newargs_out.push(newcmd_out);
786+
newargs_err.push(newcmd_err);
799787

800-
// get stderr of result
801-
runargs = ~[];
802-
runargs.push(~"shell");
803-
runargs.push(~"cat");
804-
runargs.push(fmt!("%s/%s.stderr", config.adb_test_dir, prog_short));
788+
let procsrv::Result{ out: out_out, err: _out_err, status: out_status } =
789+
procsrv::run("", config.adb_path, newargs_out, ~[(~"",~"")],
790+
Some(~""));
791+
let procsrv::Result{ out: err_out, err: _err_err, status: _err_status } =
792+
procsrv::run("", config.adb_path, newargs_err, ~[(~"",~"")],
793+
Some(~""));
805794

806-
let procsrv::Result{ out: stderr_out, err: _, status: _ } =
807-
procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~""));
795+
dump_output(config, testfile, out_out, err_out);
808796

809-
dump_output(config, testfile, stdout_out, stderr_out);
810-
811-
ProcRes {status: exitcode, stdout: stdout_out, stderr: stderr_out, cmdline: cmdline }
797+
match err_out {
798+
~"" => ProcRes {status: out_status, stdout: out_out,
799+
stderr: err_out, cmdline: cmdline },
800+
_ => ProcRes {status: 101, stdout: out_out,
801+
stderr: err_out, cmdline: cmdline }
802+
}
812803
}
813804

814805
fn _dummy_exec_compiled_test(config: &config, props: &TestProps,

trunk/src/etc/adb_run_wrapper.sh

Lines changed: 0 additions & 35 deletions
This file was deleted.

trunk/src/librustc/metadata/encoder.rs

Lines changed: 70 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -374,50 +374,90 @@ fn encode_path(ecx: @EncodeContext,
374374
fn encode_reexported_static_method(ecx: @EncodeContext,
375375
ebml_w: &mut writer::Encoder,
376376
exp: &middle::resolve::Export2,
377-
m: @ty::Method) {
378-
debug!("(encode static trait method) reexport '%s::%s'",
379-
*exp.name, *ecx.tcx.sess.str_of(m.ident));
377+
method_def_id: def_id,
378+
method_ident: ident) {
379+
debug!("(encode reexported static method) %s::%s",
380+
*exp.name, *ecx.tcx.sess.str_of(method_ident));
380381
ebml_w.start_tag(tag_items_data_item_reexport);
381382
ebml_w.start_tag(tag_items_data_item_reexport_def_id);
382-
ebml_w.wr_str(def_to_str(m.def_id));
383+
ebml_w.wr_str(def_to_str(method_def_id));
383384
ebml_w.end_tag();
384385
ebml_w.start_tag(tag_items_data_item_reexport_name);
385-
ebml_w.wr_str(*exp.name + "::" + *ecx.tcx.sess.str_of(m.ident));
386+
ebml_w.wr_str(*exp.name + "::" + *ecx.tcx.sess.str_of(method_ident));
386387
ebml_w.end_tag();
387388
ebml_w.end_tag();
388389
}
389390

391+
fn encode_reexported_static_base_methods(ecx: @EncodeContext,
392+
ebml_w: &mut writer::Encoder,
393+
exp: &middle::resolve::Export2)
394+
-> bool {
395+
match ecx.tcx.base_impls.find(&exp.def_id) {
396+
Some(implementations) => {
397+
for implementations.each |&base_impl| {
398+
for base_impl.methods.each |&m| {
399+
if m.explicit_self == ast::sty_static {
400+
encode_reexported_static_method(ecx, ebml_w, exp,
401+
m.did, m.ident);
402+
}
403+
}
404+
}
405+
406+
true
407+
}
408+
None => { false }
409+
}
410+
}
411+
412+
fn encode_reexported_static_trait_methods(ecx: @EncodeContext,
413+
ebml_w: &mut writer::Encoder,
414+
exp: &middle::resolve::Export2)
415+
-> bool {
416+
match ecx.tcx.trait_methods_cache.find(&exp.def_id) {
417+
Some(methods) => {
418+
for methods.each |&m| {
419+
if m.explicit_self == ast::sty_static {
420+
encode_reexported_static_method(ecx, ebml_w, exp,
421+
m.def_id, m.ident);
422+
}
423+
}
424+
425+
true
426+
}
427+
None => { false }
428+
}
429+
}
430+
390431
fn encode_reexported_static_methods(ecx: @EncodeContext,
391432
ebml_w: &mut writer::Encoder,
392433
mod_path: &[ast_map::path_elt],
393434
exp: &middle::resolve::Export2) {
394-
match ecx.tcx.trait_methods_cache.find(&exp.def_id) {
395-
Some(methods) => {
396-
match ecx.tcx.items.find(&exp.def_id.node) {
397-
Some(&ast_map::node_item(item, path)) => {
398-
let original_name = ecx.tcx.sess.str_of(item.ident);
399-
400-
//
401-
// We don't need to reexport static methods on traits
402-
// declared in the same module as our `pub use ...` since
403-
// that's done when we encode the trait item.
404-
//
405-
// The only exception is when the reexport *changes* the
406-
// name e.g. `pub use Foo = self::Bar` -- we have
407-
// encoded metadata for static methods relative to Bar,
408-
// but not yet for Foo.
409-
//
410-
if mod_path != *path || *exp.name != *original_name {
411-
for methods.each |&m| {
412-
if m.explicit_self == ast::sty_static {
413-
encode_reexported_static_method(ecx,
414-
ebml_w,
415-
exp, m);
416-
}
417-
}
435+
match ecx.tcx.items.find(&exp.def_id.node) {
436+
Some(&ast_map::node_item(item, path)) => {
437+
let original_name = ecx.tcx.sess.str_of(item.ident);
438+
439+
//
440+
// We don't need to reexport static methods on items
441+
// declared in the same module as our `pub use ...` since
442+
// that's done when we encode the trait item.
443+
//
444+
// The only exception is when the reexport *changes* the
445+
// name e.g. `pub use Foo = self::Bar` -- we have
446+
// encoded metadata for static methods relative to Bar,
447+
// but not yet for Foo.
448+
//
449+
if mod_path != *path || *exp.name != *original_name {
450+
if !encode_reexported_static_base_methods(ecx, ebml_w, exp) {
451+
if encode_reexported_static_trait_methods(ecx, ebml_w, exp) {
452+
debug!(fmt!("(encode reexported static methods) %s \
453+
[trait]",
454+
*original_name));
418455
}
419456
}
420-
_ => {}
457+
else {
458+
debug!(fmt!("(encode reexported static methods) %s [base]",
459+
*original_name));
460+
}
421461
}
422462
}
423463
_ => {}

trunk/src/librustc/middle/ty.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,9 @@ struct ctxt_ {
306306
// Maps a trait onto a mapping from self-ty to impl
307307
trait_impls: @mut HashMap<ast::def_id, @mut HashMap<t, @Impl>>,
308308

309+
// Maps a base type to its impl
310+
base_impls: @mut HashMap<ast::def_id, @mut ~[@Impl]>,
311+
309312
// Set of used unsafe nodes (functions or blocks). Unsafe nodes not
310313
// present in this set can be warned about.
311314
used_unsafe: @mut HashSet<ast::node_id>,
@@ -971,6 +974,7 @@ pub fn mk_ctxt(s: session::Session,
971974
destructor_for_type: @mut HashMap::new(),
972975
destructors: @mut HashSet::new(),
973976
trait_impls: @mut HashMap::new(),
977+
base_impls: @mut HashMap::new(),
974978
used_unsafe: @mut HashSet::new(),
975979
used_mut_nodes: @mut HashSet::new(),
976980
}
@@ -3699,6 +3703,21 @@ pub fn trait_method(cx: ctxt, trait_did: ast::def_id, idx: uint) -> @Method {
36993703
ty::method(cx, method_def_id)
37003704
}
37013705

3706+
3707+
pub fn add_base_impl(cx: ctxt, base_def_id: def_id, implementation: @Impl) {
3708+
let implementations;
3709+
match cx.base_impls.find(&base_def_id) {
3710+
None => {
3711+
implementations = @mut ~[];
3712+
cx.base_impls.insert(base_def_id, implementations);
3713+
}
3714+
Some(&existing) => {
3715+
implementations = existing;
3716+
}
3717+
}
3718+
implementations.push(implementation);
3719+
}
3720+
37023721
pub fn trait_methods(cx: ctxt, trait_did: ast::def_id) -> @~[@Method] {
37033722
match cx.trait_methods_cache.find(&trait_did) {
37043723
Some(&methods) => methods,

trunk/src/librustc/middle/typeck/coherence.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ pub fn get_base_type_def_id(inference_context: @mut InferCtxt,
146146
}
147147
_ => {
148148
fail!("get_base_type() returned a type that wasn't an \
149-
enum, class, or trait");
149+
enum, struct, or trait");
150150
}
151151
}
152152
}
@@ -312,6 +312,7 @@ pub impl CoherenceChecker {
312312
implementation = existing_implementation;
313313
}
314314
}
315+
315316
self.add_inherent_method(base_type_def_id,
316317
implementation);
317318
}
@@ -432,6 +433,8 @@ pub impl CoherenceChecker {
432433
}
433434

434435
implementation_list.push(implementation);
436+
437+
ty::add_base_impl(self.crate_context.tcx, base_def_id, implementation);
435438
}
436439

437440
fn add_trait_method(&self, trait_id: def_id, implementation: @Impl) {

trunk/src/test/auxiliary/mod_trait_with_static_methods_lib.rs renamed to trunk/src/test/auxiliary/reexported_static_methods.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
pub use sub_foo::Foo;
1212
pub use Baz = self::Bar;
13+
pub use sub_foo::Boz;
14+
pub use sub_foo::Bort;
1315

1416
pub trait Bar {
1517
pub fn bar() -> Self;
@@ -28,4 +30,24 @@ pub mod sub_foo {
2830
pub fn foo() -> int { 42 }
2931
}
3032

33+
pub struct Boz {
34+
unused_str: ~str
35+
}
36+
37+
pub impl Boz {
38+
pub fn boz(i: int) -> bool {
39+
i > 0
40+
}
41+
}
42+
43+
pub enum Bort {
44+
Bort1,
45+
Bort2
46+
}
47+
48+
pub impl Bort {
49+
pub fn bort() -> ~str {
50+
~"bort()"
51+
}
52+
}
3153
}

0 commit comments

Comments
 (0)