Skip to content

Commit b17fe42

Browse files
committed
---
yaml --- r: 83101 b: refs/heads/auto c: 818ebf2 h: refs/heads/master i: 83099: 8b62582 v: v3
1 parent 496a290 commit b17fe42

Some content is hidden

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

50 files changed

+447
-450
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: a7e8957c591651b6568d1b495d29ee85d11c0975
16+
refs/heads/auto: 818ebf2ed6c6f61d0a2ec86cb104c4467b28d75e
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: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,18 +415,21 @@ 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 a way to tell the compiler which convention to use:
418+
conventions. Rust provides the `abi` attribute as a way to hint to the compiler which calling
419+
convention to use:
419420

420421
~~~~
421422
#[cfg(target_os = "win32")]
423+
#[abi = "stdcall"]
422424
#[link_name = "kernel32"]
423-
extern "stdcall" {
425+
extern {
424426
fn SetEnvironmentVariableA(n: *u8, v: *u8) -> int;
425427
}
426428
~~~~
427429

428-
This applies to the entire `extern` block, and must be either `"cdecl"` or
429-
`"stdcall"`. The compiler may eventually support other calling conventions.
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.
430433

431434
# Interoperability with foreign code
432435

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 metadata, which includes
2814+
For example, Rust uniquely identifies crates by their link metadate, 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-export common definitions from `std`.
2919+
The role of the `prelude` module is to re-exports 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: 12 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,6 @@ 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-
7760
// A function that runs a test. If the function returns successfully,
7861
// the test succeeds; if the function fails then the test fails. We
7962
// may need to come up with a more clever definition of test in order
@@ -87,19 +70,6 @@ pub enum TestFn {
8770
DynBenchFn(~fn(&mut BenchHarness))
8871
}
8972

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-
10373
// Structure passed to BenchFns
10474
pub struct BenchHarness {
10575
iterations: u64,
@@ -346,8 +316,7 @@ struct ConsoleTestState {
346316
ignored: uint,
347317
measured: uint,
348318
metrics: MetricMap,
349-
failures: ~[TestDesc],
350-
max_name_len: uint, // number of columns to fill when aligning names
319+
failures: ~[TestDesc]
351320
}
352321

353322
impl ConsoleTestState {
@@ -379,8 +348,7 @@ impl ConsoleTestState {
379348
ignored: 0u,
380349
measured: 0u,
381350
metrics: MetricMap::new(),
382-
failures: ~[],
383-
max_name_len: 0u,
351+
failures: ~[]
384352
}
385353
}
386354

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

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));
414+
pub fn write_test_start(&self, test: &TestDesc) {
415+
self.out.write_str(format!("test {} ... ", test.name.to_str()));
449416
}
450417

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

593560
pub fn fmt_bench_samples(bs: &BenchSamples) -> ~str {
594561
if bs.mb_s != 0 {
595-
format!("{:>9} ns/iter (+/- {}) = {} MB/s",
562+
format!("{} ns/iter (+/- {}) = {} MB/s",
596563
bs.ns_iter_summ.median as uint,
597564
(bs.ns_iter_summ.max - bs.ns_iter_summ.min) as uint,
598565
bs.mb_s)
599566
} else {
600-
format!("{:>9} ns/iter (+/- {})",
567+
format!("{} ns/iter (+/- {})",
601568
bs.ns_iter_summ.median as uint,
602569
(bs.ns_iter_summ.max - bs.ns_iter_summ.min) as uint)
603570
}
@@ -610,7 +577,7 @@ pub fn run_tests_console(opts: &TestOpts,
610577
debug2!("callback(event={:?})", event);
611578
match (*event).clone() {
612579
TeFiltered(ref filtered_tests) => st.write_run_start(filtered_tests.len()),
613-
TeWait(ref test, padding) => st.write_test_start(test, padding),
580+
TeWait(ref test) => st.write_test_start(test),
614581
TeResult(test, result) => {
615582
st.write_log(&test, &result);
616583
st.write_result(&result);
@@ -640,20 +607,6 @@ pub fn run_tests_console(opts: &TestOpts,
640607
}
641608
}
642609
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-
}
657610
run_tests(opts, tests, |x| callback(&x, st));
658611
match opts.save_metrics {
659612
None => (),
@@ -693,8 +646,7 @@ fn should_sort_failures_before_printing_them() {
693646
ignored: 0u,
694647
measured: 0u,
695648
metrics: MetricMap::new(),
696-
failures: ~[test_b, test_a],
697-
max_name_len: 0u,
649+
failures: ~[test_b, test_a]
698650
};
699651

700652
st.write_failures();
@@ -710,7 +662,7 @@ fn use_color() -> bool { return get_concurrency() == 1; }
710662
#[deriving(Clone)]
711663
enum TestEvent {
712664
TeFiltered(~[TestDesc]),
713-
TeWait(TestDesc, NamePadding),
665+
TeWait(TestDesc),
714666
TeResult(TestDesc, TestResult),
715667
}
716668

@@ -752,15 +704,15 @@ fn run_tests(opts: &TestOpts,
752704
// We are doing one test at a time so we can print the name
753705
// of the test before we run it. Useful for debugging tests
754706
// that hang forever.
755-
callback(TeWait(test.desc.clone(), test.testfn.padding()));
707+
callback(TeWait(test.desc.clone()));
756708
}
757709
run_test(!opts.run_tests, test, ch.clone());
758710
pending += 1;
759711
}
760712

761713
let (desc, result) = p.recv();
762714
if concurrency != 1 {
763-
callback(TeWait(desc.clone(), PadNone));
715+
callback(TeWait(desc.clone()));
764716
}
765717
callback(TeResult(desc, result));
766718
pending -= 1;
@@ -769,7 +721,7 @@ fn run_tests(opts: &TestOpts,
769721
// All benchmarks run at the end, in serial.
770722
// (this includes metric fns)
771723
for b in filtered_benchs_and_metrics.move_iter() {
772-
callback(TeWait(b.desc.clone(), b.testfn.padding()));
724+
callback(TeWait(b.desc.clone()));
773725
run_test(!opts.run_benchmarks, b, ch.clone());
774726
let (test, result) = p.recv();
775727
callback(TeResult(test, result));

branches/auto/src/libextra/time.rs

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

22+
#[abi = "cdecl"]
2223
extern {
2324
pub fn get_time(sec: &mut i64, nsec: &mut i32);
2425
pub fn precise_time_ns(ns: &mut u64);

branches/auto/src/libextra/unicode.rs

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

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

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

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

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

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -505,27 +505,26 @@ pub fn trans_const(ccx: &mut CrateContext, r: &Repr, discr: Disr,
505505
}
506506
Univariant(ref st, _dro) => {
507507
assert_eq!(discr, 0);
508-
let contents = build_const_struct(ccx, st, vals);
509-
C_struct(contents, st.packed)
508+
C_struct(build_const_struct(ccx, st, vals))
510509
}
511510
General(ref cases) => {
512511
let case = &cases[discr];
513512
let max_sz = cases.iter().map(|x| x.size).max().unwrap();
514513
let discr_ty = C_disr(ccx, discr);
515514
let contents = build_const_struct(ccx, case,
516515
~[discr_ty] + vals);
517-
C_struct(contents + &[padding(max_sz - case.size)], false)
516+
C_struct(contents + &[padding(max_sz - case.size)])
518517
}
519518
NullablePointer{ nonnull: ref nonnull, nndiscr, ptrfield, _ } => {
520519
if discr == nndiscr {
521-
C_struct(build_const_struct(ccx, nonnull, vals), false)
520+
C_struct(build_const_struct(ccx, nonnull, vals))
522521
} else {
523522
assert_eq!(vals.len(), 0);
524523
let vals = do nonnull.fields.iter().enumerate().map |(i, &ty)| {
525524
let llty = type_of::sizing_type_of(ccx, ty);
526525
if i == ptrfield { C_null(llty) } else { C_undef(llty) }
527526
}.collect::<~[ValueRef]>();
528-
C_struct(build_const_struct(ccx, nonnull, vals), false)
527+
C_struct(build_const_struct(ccx, nonnull, vals))
529528
}
530529
}
531530
}
@@ -560,7 +559,7 @@ fn build_const_struct(ccx: &mut CrateContext, st: &Struct, vals: &[ValueRef])
560559
offset = target_offset;
561560
}
562561
let val = if is_undef(vals[i]) {
563-
let wrapped = C_struct([vals[i]], false);
562+
let wrapped = C_struct([vals[i]]);
564563
assert!(!is_undef(wrapped));
565564
wrapped
566565
} 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-
], false);
2939+
]);
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-
], false),
3015+
]),
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-
], false)
3021-
], false));
3020+
])
3021+
]));
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], false);
3055+
let llconst = C_struct([llmeta]);
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: 12 additions & 4 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-
C_struct([], false)
851+
return C_struct([]);
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)], false)
916+
C_struct([cs, C_uint(cx, len)])
917917
}
918918
}
919919

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

930-
pub fn C_struct(elts: &[ValueRef], packed: bool) -> ValueRef {
930+
pub fn C_struct(elts: &[ValueRef]) -> ValueRef {
931931
unsafe {
932932
do elts.as_imm_buf |ptr, len| {
933-
llvm::LLVMConstStructInContext(base::task_llcx(), ptr, len as c_uint, packed as Bool)
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)
934942
}
935943
}
936944
}

0 commit comments

Comments
 (0)