Skip to content

Commit 7572e3f

Browse files
committed
---
yaml --- r: 46566 b: refs/heads/auto c: f432723 h: refs/heads/master v: v3
1 parent a75c729 commit 7572e3f

File tree

15 files changed

+70
-111
lines changed

15 files changed

+70
-111
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 28b50a48927db9408060d141b8dcb3a830272365
17+
refs/heads/auto: f4327230fa348283f4b9c81aed76cd0759983965

branches/auto/src/libcore/rt.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! Runtime calls emitted by the compiler.
1212
1313
use cast::transmute;
14-
use libc::{c_char, c_uchar, c_void, size_t, uintptr_t};
14+
use libc::{c_char, c_uchar, c_void, size_t, uintptr_t, c_int};
1515
use managed::raw::BoxRepr;
1616
use str;
1717
use sys;
@@ -121,6 +121,21 @@ pub unsafe fn strdup_uniq(ptr: *c_uchar, len: uint) -> ~str {
121121
str::raw::from_buf_len(ptr, len)
122122
}
123123

124+
#[lang="start"]
125+
pub fn start(main: *u8, argc: int, argv: *c_char,
126+
crate_map: *u8) -> int {
127+
128+
extern {
129+
fn rust_start(main: *c_void, argc: c_int, argv: *c_char,
130+
crate_map: *c_void) -> c_int;
131+
}
132+
133+
unsafe {
134+
return rust_start(main as *c_void, argc as c_int, argv,
135+
crate_map as *c_void) as int;
136+
}
137+
}
138+
124139
// Local Variables:
125140
// mode: rust;
126141
// fill-column: 78;

branches/auto/src/libcore/str.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -590,40 +590,6 @@ pub pure fn split_str_nonempty(s: &a/str, sep: &b/str) -> ~[~str] {
590590
result
591591
}
592592

593-
/// Levenshtein Distance between two strings
594-
pub fn levdistance(s: &str, t: &str) -> uint {
595-
596-
let slen = str::len(s);
597-
let tlen = str::len(t);
598-
599-
if slen == 0 { return tlen; }
600-
if tlen == 0 { return slen; }
601-
602-
let mut dcol = vec::from_fn(tlen + 1, |x| x);
603-
604-
for str::each_chari(s) |i, sc| {
605-
606-
let mut current = i;
607-
dcol[0] = current + 1;
608-
609-
for str::each_chari(t) |j, tc| {
610-
611-
let mut next = dcol[j + 1];
612-
613-
if sc == tc {
614-
dcol[j + 1] = current;
615-
} else {
616-
dcol[j + 1] = ::cmp::min(current, next);
617-
dcol[j + 1] = ::cmp::min(dcol[j + 1], dcol[j]) + 1;
618-
}
619-
620-
current = next;
621-
}
622-
}
623-
624-
return dcol[tlen];
625-
}
626-
627593
/**
628594
* Splits a string into a vector of the substrings separated by LF ('\n')
629595
*/

branches/auto/src/librustc/back/link.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,6 @@ pub fn link_binary(sess: Session,
838838
}
839839
}
840840
841-
// Always want the runtime linked in
842-
cc_args.push(~"-lrustrt");
843-
844841
// On linux librt and libdl are an indirect dependencies via rustrt,
845842
// and binutils 2.22+ won't add them automatically
846843
if sess.targ_cfg.os == session::os_linux {
@@ -880,6 +877,9 @@ pub fn link_binary(sess: Session,
880877
cc_args.push(~"-lmorestack");
881878
}
882879

880+
// Always want the runtime linked in
881+
cc_args.push(~"-lrustrt");
882+
883883
// FIXME (#2397): At some point we want to rpath our guesses as to where
884884
// extern libraries might live, based on the addl_lib_search_paths
885885
cc_args.push_all(rpath::get_rpath_flags(sess, &output));

branches/auto/src/librustc/middle/lang_items.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,18 @@ pub enum LangItem {
7575
ReturnToMutFnLangItem, // 31
7676
CheckNotBorrowedFnLangItem, // 32
7777
StrDupUniqFnLangItem, // 33
78+
79+
StartFnLangItem, // 34
7880
}
7981

8082
pub struct LanguageItems {
81-
items: [ Option<def_id> * 34 ]
83+
items: [ Option<def_id> * 35 ]
8284
}
8385

8486
pub impl LanguageItems {
8587
static pub fn new(&self) -> LanguageItems {
8688
LanguageItems {
87-
items: [ None, ..34 ]
89+
items: [ None, ..35 ]
8890
}
8991
}
9092

@@ -136,6 +138,8 @@ pub impl LanguageItems {
136138
32 => "check_not_borrowed",
137139
33 => "strdup_uniq",
138140

141+
34 => "start",
142+
139143
_ => "???"
140144
}
141145
}
@@ -248,6 +252,9 @@ pub impl LanguageItems {
248252
pub fn strdup_uniq_fn(&const self) -> def_id {
249253
self.items[StrDupUniqFnLangItem as uint].get()
250254
}
255+
pub fn start_fn(&const self) -> def_id {
256+
self.items[StartFnLangItem as uint].get()
257+
}
251258
}
252259

253260
fn LanguageItemCollector(crate: @crate,
@@ -296,6 +303,7 @@ fn LanguageItemCollector(crate: @crate,
296303
item_refs.insert(@~"check_not_borrowed",
297304
CheckNotBorrowedFnLangItem as uint);
298305
item_refs.insert(@~"strdup_uniq", StrDupUniqFnLangItem as uint);
306+
item_refs.insert(@~"start", StartFnLangItem as uint);
299307

300308
LanguageItemCollector {
301309
crate: crate,

branches/auto/src/librustc/middle/resolve.rs

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4816,42 +4816,6 @@ pub impl Resolver {
48164816
}
48174817
}
48184818
4819-
fn find_best_match_for_name(@mut self, name: &str) -> Option<~str> {
4820-
let mut maybes: ~[~str] = ~[];
4821-
let mut values: ~[uint] = ~[];
4822-
4823-
let mut j = self.value_ribs.len();
4824-
while j != 0 {
4825-
j -= 1;
4826-
let rib = self.value_ribs.get_elt(j);
4827-
for rib.bindings.each_entry |e| {
4828-
vec::push(&mut maybes, copy *self.session.str_of(e.key));
4829-
vec::push(&mut values, uint::max_value);
4830-
}
4831-
}
4832-
4833-
let mut smallest = 0;
4834-
for vec::eachi(maybes) |i, &other| {
4835-
4836-
values[i] = str::levdistance(name, other);
4837-
4838-
if values[i] <= values[smallest] {
4839-
smallest = i;
4840-
}
4841-
}
4842-
4843-
if vec::len(values) > 0 &&
4844-
values[smallest] != uint::max_value &&
4845-
values[smallest] < str::len(name) + 2 &&
4846-
maybes[smallest] != name.to_owned() {
4847-
4848-
Some(vec::swap_remove(&mut maybes, smallest))
4849-
4850-
} else {
4851-
None
4852-
}
4853-
}
4854-
48554819
fn name_exists_in_scope_struct(@mut self, name: &str) -> bool {
48564820
let mut i = self.type_ribs.len();
48574821
while i != 0 {
@@ -4918,20 +4882,9 @@ pub impl Resolver {
49184882
wrong_name));
49194883
}
49204884
else {
4921-
match self.find_best_match_for_name(wrong_name) {
4922-
4923-
Some(m) => {
4924-
self.session.span_err(expr.span,
4925-
fmt!("unresolved name: `%s`. \
4926-
Did you mean: `%s`?",
4927-
wrong_name, m));
4928-
}
4929-
None => {
4930-
self.session.span_err(expr.span,
4931-
fmt!("unresolved name: `%s`.",
4885+
self.session.span_err(expr.span,
4886+
fmt!("unresolved name: %s",
49324887
wrong_name));
4933-
}
4934-
}
49354888
}
49364889
}
49374890
}

branches/auto/src/librustc/middle/trans/base.rs

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,7 +2267,7 @@ pub fn create_main_wrapper(ccx: @CrateContext,
22672267
fn main_name() -> ~str { return ~"WinMain@16"; }
22682268
#[cfg(unix)]
22692269
fn main_name() -> ~str { return ~"main"; }
2270-
let llfty = T_fn(~[ccx.int_type, ccx.int_type], ccx.int_type);
2270+
let llfty = T_fn(~[ccx.int_type, T_ptr(T_i8())], ccx.int_type);
22712271
22722272
// FIXME #4404 android JNI hacks
22732273
let llfn = if *ccx.sess.building_library {
@@ -2285,33 +2285,50 @@ pub fn create_main_wrapper(ccx: @CrateContext,
22852285
llvm::LLVMPositionBuilderAtEnd(bld, llbb);
22862286
}
22872287
let crate_map = ccx.crate_map;
2288-
let start_ty = T_fn(~[val_ty(rust_main), ccx.int_type, ccx.int_type,
2289-
val_ty(crate_map)], ccx.int_type);
2290-
let start = decl_cdecl_fn(ccx.llmod, ~"rust_start", start_ty);
2288+
let start_def_id = ccx.tcx.lang_items.start_fn();
2289+
let start_fn = if start_def_id.crate == ast::local_crate {
2290+
ccx.sess.bug(~"start lang item is never in the local crate")
2291+
} else {
2292+
let start_fn_type = csearch::get_type(ccx.tcx,
2293+
start_def_id).ty;
2294+
trans_external_path(ccx, start_def_id, start_fn_type)
2295+
};
2296+
2297+
let retptr = unsafe {
2298+
llvm::LLVMBuildAlloca(bld, ccx.int_type, noname())
2299+
};
22912300
22922301
let args = unsafe {
2302+
let opaque_rust_main = llvm::LLVMBuildPointerCast(
2303+
bld, rust_main, T_ptr(T_i8()), noname());
2304+
let opaque_crate_map = llvm::LLVMBuildPointerCast(
2305+
bld, crate_map, T_ptr(T_i8()), noname());
2306+
22932307
if *ccx.sess.building_library {
22942308
~[
2295-
rust_main,
2309+
retptr,
2310+
C_null(T_opaque_box_ptr(ccx)),
2311+
opaque_rust_main,
22962312
llvm::LLVMConstInt(T_i32(), 0u as c_ulonglong, False),
22972313
llvm::LLVMConstInt(T_i32(), 0u as c_ulonglong, False),
2298-
crate_map
2314+
opaque_crate_map
22992315
]
23002316
} else {
23012317
~[
2302-
rust_main,
2318+
retptr,
2319+
C_null(T_opaque_box_ptr(ccx)),
2320+
opaque_rust_main,
23032321
llvm::LLVMGetParam(llfn, 0 as c_uint),
23042322
llvm::LLVMGetParam(llfn, 1 as c_uint),
2305-
crate_map
2323+
opaque_crate_map
23062324
]
23072325
}
23082326
};
23092327
2310-
let result = unsafe {
2311-
llvm::LLVMBuildCall(bld, start, vec::raw::to_ptr(args),
2312-
args.len() as c_uint, noname())
2313-
};
23142328
unsafe {
2329+
llvm::LLVMBuildCall(bld, start_fn, vec::raw::to_ptr(args),
2330+
args.len() as c_uint, noname());
2331+
let result = llvm::LLVMBuildLoad(bld, retptr, noname());
23152332
llvm::LLVMBuildRet(bld, result);
23162333
}
23172334
}

branches/auto/src/test/compile-fail/alt-join.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ fn my_fail() -> ! { fail!(); }
1616
fn main() {
1717
match true { false => { my_fail(); } true => { } }
1818

19-
log(debug, x); //~ ERROR unresolved name: `x`.
19+
log(debug, x); //~ ERROR unresolved name: x
2020
let x: int;
2121
}

branches/auto/src/test/compile-fail/bad-expr-path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// error-pattern: unresolved name: `m1::a`. Did you mean: `args`?
11+
// error-pattern: unresolved name: m1::a
1212

1313
mod m1 {}
1414

branches/auto/src/test/compile-fail/bad-expr-path2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// error-pattern: unresolved name: `m1::a`. Did you mean: `args`?
11+
// error-pattern: unresolved name: m1::a
1212

1313
mod m1 {
1414
pub mod a {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
// error-pattern: unresolved name: `this_does_nothing_what_the`.
1+
// error-pattern: unresolved name: this_does_nothing_what_the
22
fn main() { debug!("doing"); this_does_nothing_what_the; debug!("boing"); }
33

branches/auto/src/test/compile-fail/issue-1476.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
// except according to those terms.
1010

1111
fn main() {
12-
log(error, x); //~ ERROR unresolved name: `x`.
12+
log(error, x); //~ ERROR unresolved name: x
1313
}

branches/auto/src/test/compile-fail/issue-3021-b.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn siphash(k0 : u64) {
1919
impl siphash {
2020
fn reset(&mut self) {
2121
self.v0 = k0 ^ 0x736f6d6570736575; //~ ERROR attempted dynamic environment-capture
22-
//~^ ERROR unresolved name: `k0`.
22+
//~^ ERROR unresolved name: k0
2323
}
2424
}
2525
}

branches/auto/src/test/compile-fail/issue-3021-d.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ fn siphash(k0 : u64, k1 : u64) -> siphash {
3131
impl siphash for sipstate {
3232
fn reset() {
3333
self.v0 = k0 ^ 0x736f6d6570736575; //~ ERROR attempted dynamic environment-capture
34-
//~^ ERROR unresolved name: `k0`.
34+
//~^ ERROR unresolved name: k0
3535
self.v1 = k1 ^ 0x646f72616e646f6d; //~ ERROR attempted dynamic environment-capture
36-
//~^ ERROR unresolved name: `k1`.
36+
//~^ ERROR unresolved name: k1
3737
}
3838
fn result() -> u64 { return mk_result(self); }
3939
}

branches/auto/src/test/compile-fail/issue-3021.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn siphash(k0 : u64) -> siphash {
2323
impl siphash for sipstate {
2424
fn reset() {
2525
self.v0 = k0 ^ 0x736f6d6570736575; //~ ERROR attempted dynamic environment-capture
26-
//~^ ERROR unresolved name: `k0`.
26+
//~^ ERROR unresolved name: k0
2727
}
2828
}
2929
fail!();

0 commit comments

Comments
 (0)