Skip to content

Commit d66cb58

Browse files
committed
---
yaml --- r: 46567 b: refs/heads/auto c: 99a902c h: refs/heads/master i: 46565: a75c729 46563: 7e16244 46559: 6814c2d v: v3
1 parent 7572e3f commit d66cb58

36 files changed

+758
-267
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: f4327230fa348283f4b9c81aed76cd0759983965
17+
refs/heads/auto: 99a902c81d7bc57fece1b520591f328afe76154a

branches/auto/src/libcore/hash.rs

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -186,42 +186,46 @@ fn SipState(key0: u64, key1: u64) -> SipState {
186186
state
187187
}
188188

189+
// sadly, these macro definitions can't appear later,
190+
// because they're needed in the following defs;
191+
// this design could be improved.
192+
193+
macro_rules! u8to64_le (
194+
($buf:expr, $i:expr) =>
195+
($buf[0+$i] as u64 |
196+
$buf[1+$i] as u64 << 8 |
197+
$buf[2+$i] as u64 << 16 |
198+
$buf[3+$i] as u64 << 24 |
199+
$buf[4+$i] as u64 << 32 |
200+
$buf[5+$i] as u64 << 40 |
201+
$buf[6+$i] as u64 << 48 |
202+
$buf[7+$i] as u64 << 56)
203+
)
204+
205+
macro_rules! rotl (
206+
($x:expr, $b:expr) =>
207+
(($x << $b) | ($x >> (64 - $b)))
208+
)
209+
210+
macro_rules! compress (
211+
($v0:expr, $v1:expr, $v2:expr, $v3:expr) =>
212+
({
213+
$v0 += $v1; $v1 = rotl!($v1, 13); $v1 ^= $v0;
214+
$v0 = rotl!($v0, 32);
215+
$v2 += $v3; $v3 = rotl!($v3, 16); $v3 ^= $v2;
216+
$v0 += $v3; $v3 = rotl!($v3, 21); $v3 ^= $v0;
217+
$v2 += $v1; $v1 = rotl!($v1, 17); $v1 ^= $v2;
218+
$v2 = rotl!($v2, 32);
219+
})
220+
)
221+
189222

190223
impl io::Writer for SipState {
191224

192225
// Methods for io::writer
193226
#[inline(always)]
194227
fn write(&self, msg: &[const u8]) {
195228

196-
macro_rules! u8to64_le (
197-
($buf:expr, $i:expr) =>
198-
($buf[0+$i] as u64 |
199-
$buf[1+$i] as u64 << 8 |
200-
$buf[2+$i] as u64 << 16 |
201-
$buf[3+$i] as u64 << 24 |
202-
$buf[4+$i] as u64 << 32 |
203-
$buf[5+$i] as u64 << 40 |
204-
$buf[6+$i] as u64 << 48 |
205-
$buf[7+$i] as u64 << 56)
206-
);
207-
208-
macro_rules! rotl (
209-
($x:expr, $b:expr) =>
210-
(($x << $b) | ($x >> (64 - $b)))
211-
);
212-
213-
macro_rules! compress (
214-
($v0:expr, $v1:expr, $v2:expr, $v3:expr) =>
215-
({
216-
$v0 += $v1; $v1 = rotl!($v1, 13); $v1 ^= $v0;
217-
$v0 = rotl!($v0, 32);
218-
$v2 += $v3; $v3 = rotl!($v3, 16); $v3 ^= $v2;
219-
$v0 += $v3; $v3 = rotl!($v3, 21); $v3 ^= $v0;
220-
$v2 += $v1; $v1 = rotl!($v1, 17); $v1 ^= $v2;
221-
$v2 = rotl!($v2, 32);
222-
})
223-
);
224-
225229
let length = msg.len();
226230
self.length += length;
227231

branches/auto/src/libcore/rt.rs

Lines changed: 1 addition & 16 deletions
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, c_int};
14+
use libc::{c_char, c_uchar, c_void, size_t, uintptr_t};
1515
use managed::raw::BoxRepr;
1616
use str;
1717
use sys;
@@ -121,21 +121,6 @@ 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-
139124
// Local Variables:
140125
// mode: rust;
141126
// fill-column: 78;

branches/auto/src/libcore/str.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,40 @@ 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+
593627
/**
594628
* Splits a string into a vector of the substrings separated by LF ('\n')
595629
*/

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

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

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: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,16 @@ pub enum LangItem {
7575
ReturnToMutFnLangItem, // 31
7676
CheckNotBorrowedFnLangItem, // 32
7777
StrDupUniqFnLangItem, // 33
78-
79-
StartFnLangItem, // 34
8078
}
8179

8280
pub struct LanguageItems {
83-
items: [ Option<def_id> * 35 ]
81+
items: [ Option<def_id> * 34 ]
8482
}
8583

8684
pub impl LanguageItems {
8785
static pub fn new(&self) -> LanguageItems {
8886
LanguageItems {
89-
items: [ None, ..35 ]
87+
items: [ None, ..34 ]
9088
}
9189
}
9290

@@ -138,8 +136,6 @@ pub impl LanguageItems {
138136
32 => "check_not_borrowed",
139137
33 => "strdup_uniq",
140138

141-
34 => "start",
142-
143139
_ => "???"
144140
}
145141
}
@@ -252,9 +248,6 @@ pub impl LanguageItems {
252248
pub fn strdup_uniq_fn(&const self) -> def_id {
253249
self.items[StrDupUniqFnLangItem as uint].get()
254250
}
255-
pub fn start_fn(&const self) -> def_id {
256-
self.items[StartFnLangItem as uint].get()
257-
}
258251
}
259252

260253
fn LanguageItemCollector(crate: @crate,
@@ -303,7 +296,6 @@ fn LanguageItemCollector(crate: @crate,
303296
item_refs.insert(@~"check_not_borrowed",
304297
CheckNotBorrowedFnLangItem as uint);
305298
item_refs.insert(@~"strdup_uniq", StrDupUniqFnLangItem as uint);
306-
item_refs.insert(@~"start", StartFnLangItem as uint);
307299

308300
LanguageItemCollector {
309301
crate: crate,

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

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4816,6 +4816,42 @@ 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+
48194855
fn name_exists_in_scope_struct(@mut self, name: &str) -> bool {
48204856
let mut i = self.type_ribs.len();
48214857
while i != 0 {
@@ -4882,9 +4918,20 @@ pub impl Resolver {
48824918
wrong_name));
48834919
}
48844920
else {
4885-
self.session.span_err(expr.span,
4886-
fmt!("unresolved name: %s",
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`.",
48874932
wrong_name));
4933+
}
4934+
}
48884935
}
48894936
}
48904937
}

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,6 @@ use syntax::ast_util;
172172
use syntax::codemap::span;
173173
use syntax::print::pprust::pat_to_str;
174174

175-
pub fn macros() {
176-
// FIXME(#3114): Macro import/export.
177-
include!("macros.rs");
178-
}
179-
180175
// An option identifying a literal: either a unit-like struct or an
181176
// expression.
182177
pub enum Lit {

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

Lines changed: 12 additions & 29 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, T_ptr(T_i8())], ccx.int_type);
2270+
let llfty = T_fn(~[ccx.int_type, ccx.int_type], ccx.int_type);
22712271
22722272
// FIXME #4404 android JNI hacks
22732273
let llfn = if *ccx.sess.building_library {
@@ -2285,50 +2285,33 @@ pub fn create_main_wrapper(ccx: @CrateContext,
22852285
llvm::LLVMPositionBuilderAtEnd(bld, llbb);
22862286
}
22872287
let crate_map = ccx.crate_map;
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-
};
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);
23002291
23012292
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-
23072293
if *ccx.sess.building_library {
23082294
~[
2309-
retptr,
2310-
C_null(T_opaque_box_ptr(ccx)),
2311-
opaque_rust_main,
2295+
rust_main,
23122296
llvm::LLVMConstInt(T_i32(), 0u as c_ulonglong, False),
23132297
llvm::LLVMConstInt(T_i32(), 0u as c_ulonglong, False),
2314-
opaque_crate_map
2298+
crate_map
23152299
]
23162300
} else {
23172301
~[
2318-
retptr,
2319-
C_null(T_opaque_box_ptr(ccx)),
2320-
opaque_rust_main,
2302+
rust_main,
23212303
llvm::LLVMGetParam(llfn, 0 as c_uint),
23222304
llvm::LLVMGetParam(llfn, 1 as c_uint),
2323-
opaque_crate_map
2305+
crate_map
23242306
]
23252307
}
23262308
};
23272309
2310+
let result = unsafe {
2311+
llvm::LLVMBuildCall(bld, start, vec::raw::to_ptr(args),
2312+
args.len() as c_uint, noname())
2313+
};
23282314
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());
23322315
llvm::LLVMBuildRet(bld, result);
23332316
}
23342317
}

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ use middle::trans::datum::*;
1818

1919
use core::str;
2020

21-
pub fn macros() {
22-
// FIXME(#3114): Macro import/export.
23-
include!("macros.rs");
24-
}
25-
2621
pub fn trans_block(bcx: block, b: &ast::blk, dest: expr::Dest) -> block {
2722
let _icx = bcx.insn_ctxt("trans_block");
2823
let mut bcx = bcx;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ use syntax::codemap::spanned;
149149
// These are passed around by the code generating functions to track the
150150
// destination of a computation's value.
151151

152-
fn macros() { include!("macros.rs"); } // FIXME(#3114): Macro import/export.
153-
154152
pub enum Dest {
155153
SaveIn(ValueRef),
156154
Ignore,

0 commit comments

Comments
 (0)