Skip to content

Commit afe20d0

Browse files
author
Do Nhat Minh
committed
---
yaml --- r: 85702 b: refs/heads/dist-snap c: 77df8b8 h: refs/heads/master v: v3
1 parent 1b570ed commit afe20d0

File tree

24 files changed

+112
-1289
lines changed

24 files changed

+112
-1289
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 0983ebe5310d4eb6d289f636f7ed0536c08bbc0e
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 95c542e7fed0b6a76376f7c1146ac34499bbf238
9+
refs/heads/dist-snap: 77df8b809a3927ffcdd2c43d48783c97a25712a8
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librust/rust.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl ValidUsage {
4545

4646
enum Action {
4747
Call(extern "Rust" fn(args: &[~str]) -> ValidUsage),
48-
CallMain(&'static str, extern "Rust" fn()),
48+
CallMain(&'static str, extern "Rust" fn(&[~str])),
4949
}
5050

5151
enum UsageSource<'self> {
@@ -69,7 +69,7 @@ static NUM_OF_COMMANDS: uint = 7;
6969
static COMMANDS: [Command<'static>, .. NUM_OF_COMMANDS] = [
7070
Command{
7171
cmd: "build",
72-
action: CallMain("rustc", rustc::main),
72+
action: CallMain("rustc", rustc::main_args),
7373
usage_line: "compile rust source files",
7474
usage_full: UsgCall(rustc_help),
7575
},
@@ -95,19 +95,19 @@ static COMMANDS: [Command<'static>, .. NUM_OF_COMMANDS] = [
9595
},
9696
Command{
9797
cmd: "doc",
98-
action: CallMain("rustdoc", rustdoc::main),
98+
action: CallMain("rustdoc", rustdoc::main_args),
9999
usage_line: "generate documentation from doc comments",
100100
usage_full: UsgCall(rustdoc::config::usage),
101101
},
102102
Command{
103103
cmd: "pkg",
104-
action: CallMain("rustpkg", rustpkg::main),
104+
action: CallMain("rustpkg", rustpkg::main_args),
105105
usage_line: "download, build, install rust packages",
106106
usage_full: UsgCall(rustpkg::usage::general),
107107
},
108108
Command{
109109
cmd: "sketch",
110-
action: CallMain("rusti", rusti::main),
110+
action: CallMain("rusti", rusti::main_args),
111111
usage_line: "run a rust interpreter",
112112
usage_full: UsgStr("\nUsage:\trusti"),
113113
},
@@ -164,7 +164,7 @@ fn cmd_test(args: &[~str]) -> ValidUsage {
164164
[ref filename] => {
165165
let test_exec = Path(*filename).filestem().unwrap() + "test~";
166166
invoke("rustc", &[~"--test", filename.to_owned(),
167-
~"-o", test_exec.to_owned()], rustc::main);
167+
~"-o", test_exec.to_owned()], rustc::main_args);
168168
let exit_code = run::process_status(~"./" + test_exec, []);
169169
Valid(exit_code)
170170
}
@@ -177,19 +177,18 @@ fn cmd_run(args: &[~str]) -> ValidUsage {
177177
[ref filename, ..prog_args] => {
178178
let exec = Path(*filename).filestem().unwrap() + "~";
179179
invoke("rustc", &[filename.to_owned(), ~"-o", exec.to_owned()],
180-
rustc::main);
180+
rustc::main_args);
181181
let exit_code = run::process_status(~"./"+exec, prog_args);
182182
Valid(exit_code)
183183
}
184184
_ => Invalid
185185
}
186186
}
187187

188-
fn invoke(prog: &str, args: &[~str], f: &fn()) {
188+
fn invoke(prog: &str, args: &[~str], f: &fn(&[~str])) {
189189
let mut osargs = ~[prog.to_owned()];
190190
osargs.push_all_move(args.to_owned());
191-
os::set_args(osargs);
192-
f();
191+
f(osargs);
193192
}
194193

195194
fn do_command(command: &Command, args: &[~str]) -> ValidUsage {

branches/dist-snap/src/librustc/middle/liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ impl Liveness {
16171617

16181618
pub fn should_warn(&self, var: Variable) -> Option<@str> {
16191619
let name = self.ir.variable_name(var);
1620-
if name.len() == 0 || name[0] == ('_' as u8) { None } else { Some(name) }
1620+
if name[0] == ('_' as u8) { None } else { Some(name) }
16211621
}
16221622

16231623
pub fn warn_about_unused_args(&self, decl: &fn_decl, entry_ln: LiveNode) {

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -577,23 +577,20 @@ fn emit_vtable_methods(bcx: @mut Block,
577577

578578
let trait_method_def_ids = ty::trait_method_def_ids(tcx, trt_id);
579579
do trait_method_def_ids.map |method_def_id| {
580-
let ident = ty::method(tcx, *method_def_id).ident;
581-
// The substitutions we have are on the impl, so we grab
582-
// the method type from the impl to substitute into.
583-
let m_id = method_with_name(ccx, impl_id, ident);
584-
let m = ty::method(tcx, m_id);
585-
debug!("(making impl vtable) emitting method %s at subst %s",
586-
m.repr(tcx),
587-
substs.repr(tcx));
580+
let im = ty::method(tcx, *method_def_id);
588581
let fty = ty::subst_tps(tcx,
589582
substs,
590583
None,
591-
ty::mk_bare_fn(tcx, m.fty.clone()));
592-
if m.generics.has_type_params() || ty::type_has_self(fty) {
584+
ty::mk_bare_fn(tcx, im.fty.clone()));
585+
if im.generics.has_type_params() || ty::type_has_self(fty) {
593586
debug!("(making impl vtable) method has self or type params: %s",
594-
tcx.sess.str_of(ident));
587+
tcx.sess.str_of(im.ident));
595588
C_null(Type::nil().ptr_to())
596589
} else {
590+
debug!("(making impl vtable) adding method to vtable: %s",
591+
tcx.sess.str_of(im.ident));
592+
let m_id = method_with_name(ccx, impl_id, im.ident);
593+
597594
trans_fn_ref_with_vtables(bcx, m_id, 0,
598595
substs, Some(vtables)).llfn
599596
}

branches/dist-snap/src/librustc/middle/typeck/check/method.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -938,18 +938,9 @@ impl<'self> LookupContext<'self> {
938938

939939
// static methods should never have gotten this far:
940940
assert!(candidate.method_ty.explicit_self != sty_static);
941-
942-
let transformed_self_ty = match candidate.origin {
943-
method_object(*) => {
944-
// For annoying reasons, we've already handled the
945-
// substitution for object calls.
946-
candidate.method_ty.transformed_self_ty.unwrap()
947-
}
948-
_ => {
949-
ty::subst(tcx, &candidate.rcvr_substs,
950-
candidate.method_ty.transformed_self_ty.unwrap())
951-
}
952-
};
941+
let transformed_self_ty =
942+
ty::subst(tcx, &candidate.rcvr_substs,
943+
candidate.method_ty.transformed_self_ty.unwrap());
953944

954945
// Determine the values for the type parameters of the method.
955946
// If they were not explicitly supplied, just construct fresh

branches/dist-snap/src/librustc/middle/typeck/check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3092,6 +3092,7 @@ pub fn ty_param_bounds_and_ty_for_def(fcx: @mut FnCtxt,
30923092
sp: span,
30933093
defn: ast::def)
30943094
-> ty_param_bounds_and_ty {
3095+
30953096
match defn {
30963097
ast::def_arg(nid, _) | ast::def_local(nid, _) | ast::def_self(nid, _) |
30973098
ast::def_binding(nid, _) => {
@@ -3148,8 +3149,7 @@ pub fn instantiate_path(fcx: @mut FnCtxt,
31483149
let ty_param_count = tpt.generics.type_param_defs.len();
31493150
let ty_substs_len = pth.types.len();
31503151

3151-
debug!("tpt=%s ty_param_count=%? ty_substs_len=%?",
3152-
tpt.repr(fcx.tcx()),
3152+
debug!("ty_param_count=%? ty_substs_len=%?",
31533153
ty_param_count,
31543154
ty_substs_len);
31553155

branches/dist-snap/src/librustc/middle/typeck/collect.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,9 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt,
346346
let substd_type_param_defs = m.generics.type_param_defs.subst(tcx, &substs);
347347
new_type_param_defs.push_all(*substd_type_param_defs);
348348

349-
debug!("static method %s type_param_defs=%s ty=%s, substs=%s",
349+
debug!("static method %s type_param_defs=%s substs=%s",
350350
m.def_id.repr(tcx),
351351
new_type_param_defs.repr(tcx),
352-
ty.repr(tcx),
353352
substs.repr(tcx));
354353

355354
tcx.tcache.insert(m.def_id,
@@ -894,8 +893,8 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::item) {
894893
}
895894
ast::item_trait(ref generics, _, ref trait_methods) => {
896895
let _trait_def = trait_def_of_item(ccx, it);
896+
ensure_trait_methods(ccx, it.id);
897897

898-
// Run convert_methods on the provided methods.
899898
let (_, provided_methods) =
900899
split_trait_methods(*trait_methods);
901900
let untransformed_rcvr_ty = ty::mk_self(tcx, local_def(it.id));
@@ -905,11 +904,6 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::item) {
905904
untransformed_rcvr_ty,
906905
&ty_generics, generics,
907906
it.vis);
908-
909-
// We need to do this *after* converting methods, since
910-
// convert_methods produces a tcache entry that is wrong for
911-
// static trait methods. This is somewhat unfortunate.
912-
ensure_trait_methods(ccx, it.id);
913907
}
914908
ast::item_struct(struct_def, ref generics) => {
915909
ensure_no_ty_param_bounds(ccx, it.span, generics, "structure");

branches/dist-snap/src/librustc/rustc.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,11 @@ pub fn describe_debug_flags() {
191191
}
192192
}
193193

194-
pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
194+
pub fn run_compiler(args: &[~str], demitter: diagnostic::Emitter) {
195195
// Don't display log spew by default. Can override with RUST_LOG.
196196
::std::logging::console_off();
197197

198-
let mut args = (*args).clone();
198+
let mut args = args.to_owned();
199199
let binary = args.shift().to_managed();
200200

201201
if args.is_empty() { usage(binary); return; }
@@ -381,7 +381,12 @@ pub fn monitor(f: ~fn(diagnostic::Emitter)) {
381381

382382
pub fn main() {
383383
let args = os::args();
384+
main_args(args);
385+
}
386+
387+
pub fn main_args(args: &[~str]) {
388+
let owned_args = args.to_owned();
384389
do monitor |demitter| {
385-
run_compiler(&args, demitter);
390+
run_compiler(owned_args, demitter);
386391
}
387392
}

branches/dist-snap/src/librustdoc/rustdoc.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ pub mod prune_private_pass;
5959

6060
pub fn main() {
6161
let args = os::args();
62+
main_args(args);
63+
}
6264

65+
pub fn main_args(args: &[~str]) {
6366
if args.iter().any(|x| "-h" == *x) || args.iter().any(|x| "--help" == *x) {
6467
config::usage();
6568
return;

branches/dist-snap/src/librusti/rusti.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,13 @@ pub fn run_line(repl: &mut Repl, input: @io::Reader, out: @io::Writer, line: ~st
498498
}
499499

500500
pub fn main() {
501+
let args = os::args();
502+
main_args(args);
503+
}
504+
505+
pub fn main_args(args: &[~str]) {
501506
#[fixed_stack_segment]; #[inline(never)];
502507

503-
let args = os::args();
504508
let input = io::stdin();
505509
let out = io::stdout();
506510
let mut repl = Repl {

branches/dist-snap/src/librustpkg/rustpkg.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,11 @@ impl CtxMethods for Ctx {
466466

467467
pub fn main() {
468468
io::println("WARNING: The Rust package manager is experimental and may be unstable");
469-
470469
let args = os::args();
470+
main_args(args);
471+
}
472+
473+
pub fn main_args(args: &[~str]) {
471474
let opts = ~[getopts::optflag("h"), getopts::optflag("help"),
472475
getopts::optflag("j"), getopts::optflag("json"),
473476
getopts::optmulti("c"), getopts::optmulti("cfg")];

branches/dist-snap/src/librustpkg/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,6 @@ fn rustpkg_local_pkg() {
678678
}
679679
680680
#[test]
681-
#[ignore (reason = "test makes bogus assumptions about build directory layout: issue #8690")]
682681
fn package_script_with_default_build() {
683682
let dir = create_local_package(&PkgId::new("fancy-lib"));
684683
debug!("dir = %s", dir.to_str());

branches/dist-snap/src/libstd/os.rs

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ use iterator::range;
3636
use libc;
3737
use libc::{c_char, c_void, c_int, size_t};
3838
use libc::FILE;
39-
use local_data;
4039
use option::{Some, None};
4140
use os;
4241
use prelude::*;
@@ -1188,7 +1187,7 @@ unsafe fn load_argc_and_argv(argc: c_int, argv: **c_char) -> ~[~str] {
11881187
* Returns a list of the command line arguments.
11891188
*/
11901189
#[cfg(target_os = "macos")]
1191-
pub fn real_args() -> ~[~str] {
1190+
fn real_args() -> ~[~str] {
11921191
#[fixed_stack_segment]; #[inline(never)];
11931192

11941193
unsafe {
@@ -1201,7 +1200,7 @@ pub fn real_args() -> ~[~str] {
12011200
#[cfg(target_os = "linux")]
12021201
#[cfg(target_os = "android")]
12031202
#[cfg(target_os = "freebsd")]
1204-
pub fn real_args() -> ~[~str] {
1203+
fn real_args() -> ~[~str] {
12051204
use rt;
12061205

12071206
match rt::args::clone() {
@@ -1211,7 +1210,7 @@ pub fn real_args() -> ~[~str] {
12111210
}
12121211

12131212
#[cfg(windows)]
1214-
pub fn real_args() -> ~[~str] {
1213+
fn real_args() -> ~[~str] {
12151214
#[fixed_stack_segment]; #[inline(never)];
12161215

12171216
let mut nArgs: c_int = 0;
@@ -1261,28 +1260,10 @@ struct OverriddenArgs {
12611260
val: ~[~str]
12621261
}
12631262

1264-
static overridden_arg_key: local_data::Key<@OverriddenArgs> = &local_data::Key;
1265-
12661263
/// Returns the arguments which this program was started with (normally passed
12671264
/// via the command line).
1268-
///
1269-
/// The return value of the function can be changed by invoking the
1270-
/// `os::set_args` function.
12711265
pub fn args() -> ~[~str] {
1272-
match local_data::get(overridden_arg_key, |k| k.map(|&k| *k)) {
1273-
None => real_args(),
1274-
Some(args) => args.val.clone()
1275-
}
1276-
}
1277-
1278-
/// For the current task, overrides the task-local cache of the arguments this
1279-
/// program had when it started. These new arguments are only available to the
1280-
/// current task via the `os::args` method.
1281-
pub fn set_args(new_args: ~[~str]) {
1282-
let overridden_args = @OverriddenArgs {
1283-
val: new_args.clone()
1284-
};
1285-
local_data::set(overridden_arg_key, overridden_args);
1266+
real_args()
12861267
}
12871268

12881269
// FIXME #6100 we should really use an internal implementation of this - using
@@ -1770,7 +1751,7 @@ mod tests {
17701751
use libc;
17711752
use option::Some;
17721753
use option;
1773-
use os::{env, getcwd, getenv, make_absolute, real_args};
1754+
use os::{env, getcwd, getenv, make_absolute, args};
17741755
use os::{remove_file, setenv, unsetenv};
17751756
use os;
17761757
use path::Path;
@@ -1788,7 +1769,7 @@ mod tests {
17881769
17891770
#[test]
17901771
pub fn test_args() {
1791-
let a = real_args();
1772+
let a = args();
17921773
assert!(a.len() >= 1);
17931774
}
17941775

0 commit comments

Comments
 (0)