Skip to content

Commit c90a5c4

Browse files
committed
---
yaml --- r: 83102 b: refs/heads/auto c: 3d693d7 h: refs/heads/master v: v3
1 parent b17fe42 commit c90a5c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+608
-526
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 818ebf2ed6c6f61d0a2ec86cb104c4467b28d75e
16+
refs/heads/auto: 3d693d74b814eed6140b9ca29ff01eb3411255a2
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/doc/tutorial-ffi.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -415,21 +415,18 @@ fn main() {
415415

416416
Most foreign code exposes a C ABI, and Rust uses the platform's C calling convention by default when
417417
calling foreign functions. Some foreign functions, most notably the Windows API, use other calling
418-
conventions. Rust provides the `abi` attribute as a way to hint to the compiler which calling
419-
convention to use:
418+
conventions. Rust provides a way to tell the compiler which convention to use:
420419

421420
~~~~
422421
#[cfg(target_os = "win32")]
423-
#[abi = "stdcall"]
424422
#[link_name = "kernel32"]
425-
extern {
423+
extern "stdcall" {
426424
fn SetEnvironmentVariableA(n: *u8, v: *u8) -> int;
427425
}
428426
~~~~
429427

430-
The `abi` attribute applies to a foreign module (it cannot be applied to a single function within a
431-
module), and must be either `"cdecl"` or `"stdcall"`. The compiler may eventually support other
432-
calling conventions.
428+
This applies to the entire `extern` block, and must be either `"cdecl"` or
429+
`"stdcall"`. The compiler may eventually support other calling conventions.
433430

434431
# Interoperability with foreign code
435432

branches/auto/doc/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2811,7 +2811,7 @@ For every crate you can define a number of metadata items, such as link name, ve
28112811
You can also toggle settings that have crate-global consequences. Both mechanism
28122812
work by providing attributes in the crate root.
28132813

2814-
For example, Rust uniquely identifies crates by their link metadate, which includes
2814+
For example, Rust uniquely identifies crates by their link metadata, which includes
28152815
the link name and the version. It also hashes the filename and the symbols in a binary
28162816
based on the link metadata, allowing you to use two different versions of the same library in a crate
28172817
without conflict.
@@ -2916,7 +2916,7 @@ As well as this line into every module body:
29162916
use std::prelude::*;
29172917
~~~
29182918

2919-
The role of the `prelude` module is to re-exports common definitions from `std`.
2919+
The role of the `prelude` module is to re-export common definitions from `std`.
29202920

29212921
This allows you to use common types and functions like `Option<T>` or `println`
29222922
without needing to import them. And if you need something from `std` that's not in the prelude,

branches/auto/src/libextra/test.rs

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,23 @@ impl ToStr for TestName {
5757
}
5858
}
5959

60+
#[deriving(Clone)]
61+
enum NamePadding { PadNone, PadOnLeft, PadOnRight }
62+
63+
impl TestDesc {
64+
fn padded_name(&self, column_count: uint, align: NamePadding) -> ~str {
65+
use std::num::Saturating;
66+
let name = self.name.to_str();
67+
let fill = column_count.saturating_sub(name.len());
68+
let pad = " ".repeat(fill);
69+
match align {
70+
PadNone => name,
71+
PadOnLeft => pad.append(name),
72+
PadOnRight => name.append(pad),
73+
}
74+
}
75+
}
76+
6077
// A function that runs a test. If the function returns successfully,
6178
// the test succeeds; if the function fails then the test fails. We
6279
// may need to come up with a more clever definition of test in order
@@ -70,6 +87,19 @@ pub enum TestFn {
7087
DynBenchFn(~fn(&mut BenchHarness))
7188
}
7289

90+
impl TestFn {
91+
fn padding(&self) -> NamePadding {
92+
match self {
93+
&StaticTestFn(*) => PadNone,
94+
&StaticBenchFn(*) => PadOnRight,
95+
&StaticMetricFn(*) => PadOnRight,
96+
&DynTestFn(*) => PadNone,
97+
&DynMetricFn(*) => PadOnRight,
98+
&DynBenchFn(*) => PadOnRight,
99+
}
100+
}
101+
}
102+
73103
// Structure passed to BenchFns
74104
pub struct BenchHarness {
75105
iterations: u64,
@@ -316,7 +346,8 @@ struct ConsoleTestState {
316346
ignored: uint,
317347
measured: uint,
318348
metrics: MetricMap,
319-
failures: ~[TestDesc]
349+
failures: ~[TestDesc],
350+
max_name_len: uint, // number of columns to fill when aligning names
320351
}
321352

322353
impl ConsoleTestState {
@@ -348,7 +379,8 @@ impl ConsoleTestState {
348379
ignored: 0u,
349380
measured: 0u,
350381
metrics: MetricMap::new(),
351-
failures: ~[]
382+
failures: ~[],
383+
max_name_len: 0u,
352384
}
353385
}
354386

@@ -411,8 +443,9 @@ impl ConsoleTestState {
411443
self.out.write_line(format!("\nrunning {} {}", len, noun));
412444
}
413445

414-
pub fn write_test_start(&self, test: &TestDesc) {
415-
self.out.write_str(format!("test {} ... ", test.name.to_str()));
446+
pub fn write_test_start(&self, test: &TestDesc, align: NamePadding) {
447+
let name = test.padded_name(self.max_name_len, align);
448+
self.out.write_str(format!("test {} ... ", name));
416449
}
417450

418451
pub fn write_result(&self, result: &TestResult) {
@@ -559,12 +592,12 @@ pub fn fmt_metrics(mm: &MetricMap) -> ~str {
559592

560593
pub fn fmt_bench_samples(bs: &BenchSamples) -> ~str {
561594
if bs.mb_s != 0 {
562-
format!("{} ns/iter (+/- {}) = {} MB/s",
595+
format!("{:>9} ns/iter (+/- {}) = {} MB/s",
563596
bs.ns_iter_summ.median as uint,
564597
(bs.ns_iter_summ.max - bs.ns_iter_summ.min) as uint,
565598
bs.mb_s)
566599
} else {
567-
format!("{} ns/iter (+/- {})",
600+
format!("{:>9} ns/iter (+/- {})",
568601
bs.ns_iter_summ.median as uint,
569602
(bs.ns_iter_summ.max - bs.ns_iter_summ.min) as uint)
570603
}
@@ -577,7 +610,7 @@ pub fn run_tests_console(opts: &TestOpts,
577610
debug2!("callback(event={:?})", event);
578611
match (*event).clone() {
579612
TeFiltered(ref filtered_tests) => st.write_run_start(filtered_tests.len()),
580-
TeWait(ref test) => st.write_test_start(test),
613+
TeWait(ref test, padding) => st.write_test_start(test, padding),
581614
TeResult(test, result) => {
582615
st.write_log(&test, &result);
583616
st.write_result(&result);
@@ -607,6 +640,20 @@ pub fn run_tests_console(opts: &TestOpts,
607640
}
608641
}
609642
let st = @mut ConsoleTestState::new(opts);
643+
fn len_if_padded(t: &TestDescAndFn) -> uint {
644+
match t.testfn.padding() {
645+
PadNone => 0u,
646+
PadOnLeft | PadOnRight => t.desc.name.to_str().len(),
647+
}
648+
}
649+
match tests.iter().max_by(|t|len_if_padded(*t)) {
650+
Some(t) => {
651+
let n = t.desc.name.to_str();
652+
debug2!("Setting max_name_len from: {}", n);
653+
st.max_name_len = n.len();
654+
},
655+
None => {}
656+
}
610657
run_tests(opts, tests, |x| callback(&x, st));
611658
match opts.save_metrics {
612659
None => (),
@@ -646,7 +693,8 @@ fn should_sort_failures_before_printing_them() {
646693
ignored: 0u,
647694
measured: 0u,
648695
metrics: MetricMap::new(),
649-
failures: ~[test_b, test_a]
696+
failures: ~[test_b, test_a],
697+
max_name_len: 0u,
650698
};
651699

652700
st.write_failures();
@@ -662,7 +710,7 @@ fn use_color() -> bool { return get_concurrency() == 1; }
662710
#[deriving(Clone)]
663711
enum TestEvent {
664712
TeFiltered(~[TestDesc]),
665-
TeWait(TestDesc),
713+
TeWait(TestDesc, NamePadding),
666714
TeResult(TestDesc, TestResult),
667715
}
668716

@@ -704,15 +752,15 @@ fn run_tests(opts: &TestOpts,
704752
// We are doing one test at a time so we can print the name
705753
// of the test before we run it. Useful for debugging tests
706754
// that hang forever.
707-
callback(TeWait(test.desc.clone()));
755+
callback(TeWait(test.desc.clone(), test.testfn.padding()));
708756
}
709757
run_test(!opts.run_tests, test, ch.clone());
710758
pending += 1;
711759
}
712760

713761
let (desc, result) = p.recv();
714762
if concurrency != 1 {
715-
callback(TeWait(desc.clone()));
763+
callback(TeWait(desc.clone(), PadNone));
716764
}
717765
callback(TeResult(desc, result));
718766
pending -= 1;
@@ -721,7 +769,7 @@ fn run_tests(opts: &TestOpts,
721769
// All benchmarks run at the end, in serial.
722770
// (this includes metric fns)
723771
for b in filtered_benchs_and_metrics.move_iter() {
724-
callback(TeWait(b.desc.clone()));
772+
callback(TeWait(b.desc.clone(), b.testfn.padding()));
725773
run_test(!opts.run_benchmarks, b, ch.clone());
726774
let (test, result) = p.recv();
727775
callback(TeResult(test, result));

branches/auto/src/libextra/time.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ static NSEC_PER_SEC: i32 = 1_000_000_000_i32;
1919
pub mod rustrt {
2020
use super::Tm;
2121

22-
#[abi = "cdecl"]
2322
extern {
2423
pub fn get_time(sec: &mut i64, nsec: &mut i32);
2524
pub fn precise_time_ns(ns: &mut u64);

branches/auto/src/libextra/unicode.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ pub mod icu {
162162

163163
// #[link_name = "icuuc"]
164164
#[link_args = "-licuuc"]
165-
#[abi = "cdecl"]
166165
extern {
167166
pub fn u_hasBinaryProperty(c: UChar32, which: UProperty) -> UBool;
168167
pub fn u_isdigit(c: UChar32) -> UBool;

branches/auto/src/librustc/driver/driver.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ pub fn phase_2_configure_and_expand(sess: Session,
199199

200200
pub struct CrateAnalysis {
201201
exp_map2: middle::resolve::ExportMap2,
202+
exported_items: middle::privacy::ExportedItems,
202203
ty_cx: ty::ctxt,
203204
maps: astencode::Maps,
204205
reachable: @mut HashSet<ast::NodeId>
@@ -310,6 +311,7 @@ pub fn phase_3_run_analysis_passes(sess: Session,
310311
CrateAnalysis {
311312
exp_map2: exp_map2,
312313
ty_cx: ty_cx,
314+
exported_items: exported_items,
313315
maps: astencode::Maps {
314316
root_map: root_map,
315317
method_map: method_map,

branches/auto/src/librustc/lib/llvm.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ pub mod llvm {
300300

301301
#[link_args = "-Lrustllvm -lrustllvm"]
302302
#[link_name = "rustllvm"]
303-
#[abi = "cdecl"]
304303
extern {
305304
/* Create and destroy contexts. */
306305
pub fn LLVMContextCreate() -> ContextRef;

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -505,26 +505,27 @@ pub fn trans_const(ccx: &mut CrateContext, r: &Repr, discr: Disr,
505505
}
506506
Univariant(ref st, _dro) => {
507507
assert_eq!(discr, 0);
508-
C_struct(build_const_struct(ccx, st, vals))
508+
let contents = build_const_struct(ccx, st, vals);
509+
C_struct(contents, st.packed)
509510
}
510511
General(ref cases) => {
511512
let case = &cases[discr];
512513
let max_sz = cases.iter().map(|x| x.size).max().unwrap();
513514
let discr_ty = C_disr(ccx, discr);
514515
let contents = build_const_struct(ccx, case,
515516
~[discr_ty] + vals);
516-
C_struct(contents + &[padding(max_sz - case.size)])
517+
C_struct(contents + &[padding(max_sz - case.size)], false)
517518
}
518519
NullablePointer{ nonnull: ref nonnull, nndiscr, ptrfield, _ } => {
519520
if discr == nndiscr {
520-
C_struct(build_const_struct(ccx, nonnull, vals))
521+
C_struct(build_const_struct(ccx, nonnull, vals), false)
521522
} else {
522523
assert_eq!(vals.len(), 0);
523524
let vals = do nonnull.fields.iter().enumerate().map |(i, &ty)| {
524525
let llty = type_of::sizing_type_of(ccx, ty);
525526
if i == ptrfield { C_null(llty) } else { C_undef(llty) }
526527
}.collect::<~[ValueRef]>();
527-
C_struct(build_const_struct(ccx, nonnull, vals))
528+
C_struct(build_const_struct(ccx, nonnull, vals), false)
528529
}
529530
}
530531
}
@@ -559,7 +560,7 @@ fn build_const_struct(ccx: &mut CrateContext, st: &Struct, vals: &[ValueRef])
559560
offset = target_offset;
560561
}
561562
let val = if is_undef(vals[i]) {
562-
let wrapped = C_struct([vals[i]]);
563+
let wrapped = C_struct([vals[i]], false);
563564
assert!(!is_undef(wrapped));
564565
wrapped
565566
} else {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2936,7 +2936,7 @@ pub fn create_module_map(ccx: &mut CrateContext) -> (ValueRef, uint, uint) {
29362936
let elt = C_struct([
29372937
C_estr_slice(ccx, *key),
29382938
v_ptr
2939-
]);
2939+
], false);
29402940
elts.push(elt);
29412941
}
29422942
unsafe {
@@ -3012,13 +3012,13 @@ pub fn fill_crate_map(ccx: &mut CrateContext, map: ValueRef) {
30123012
p2i(ccx, mod_map),
30133013
// byte size of the module map array, an entry consists of two integers
30143014
C_int(ccx, ((mod_count * mod_struct_size) as int))
3015-
]),
3015+
], false),
30163016
C_struct([
30173017
p2i(ccx, vec_elements),
30183018
// byte size of the subcrates array, an entry consists of an integer
30193019
C_int(ccx, (subcrates.len() * llsize_of_alloc(ccx, ccx.int_type)) as int)
3020-
])
3021-
]));
3020+
], false)
3021+
], false));
30223022
}
30233023
}
30243024

@@ -3052,7 +3052,7 @@ pub fn write_metadata(cx: &CrateContext, crate: &ast::Crate) {
30523052

30533053
let encode_parms = crate_ctxt_to_encode_parms(cx, encode_inlined_item);
30543054
let llmeta = C_bytes(encoder::encode_metadata(encode_parms, crate));
3055-
let llconst = C_struct([llmeta]);
3055+
let llconst = C_struct([llmeta], false);
30563056
let mut llglobal = do "rust_metadata".with_c_str |buf| {
30573057
unsafe {
30583058
llvm::LLVMAddGlobal(cx.llmod, val_ty(llconst).to_ref(), buf)

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ pub fn C_floating(s: &str, t: Type) -> ValueRef {
848848
}
849849

850850
pub fn C_nil() -> ValueRef {
851-
return C_struct([]);
851+
C_struct([], false)
852852
}
853853

854854
pub fn C_bool(val: bool) -> ValueRef {
@@ -913,7 +913,7 @@ pub fn C_estr_slice(cx: &mut CrateContext, s: @str) -> ValueRef {
913913
unsafe {
914914
let len = s.len();
915915
let cs = llvm::LLVMConstPointerCast(C_cstr(cx, s), Type::i8p().to_ref());
916-
C_struct([cs, C_uint(cx, len)])
916+
C_struct([cs, C_uint(cx, len)], false)
917917
}
918918
}
919919

@@ -927,18 +927,10 @@ pub fn C_zero_byte_arr(size: uint) -> ValueRef {
927927
}
928928
}
929929

930-
pub fn C_struct(elts: &[ValueRef]) -> ValueRef {
930+
pub fn C_struct(elts: &[ValueRef], packed: bool) -> ValueRef {
931931
unsafe {
932932
do elts.as_imm_buf |ptr, len| {
933-
llvm::LLVMConstStructInContext(base::task_llcx(), ptr, len as c_uint, False)
934-
}
935-
}
936-
}
937-
938-
pub fn C_packed_struct(elts: &[ValueRef]) -> ValueRef {
939-
unsafe {
940-
do elts.as_imm_buf |ptr, len| {
941-
llvm::LLVMConstStructInContext(base::task_llcx(), ptr, len as c_uint, True)
933+
llvm::LLVMConstStructInContext(base::task_llcx(), ptr, len as c_uint, packed as Bool)
942934
}
943935
}
944936
}

0 commit comments

Comments
 (0)