Skip to content

Commit ab6e340

Browse files
Evgeny SologubovEvgeny Sologubov
authored andcommitted
---
yaml --- r: 81693 b: refs/heads/master c: fadc6cc h: refs/heads/master i: 81691: ad7e073 v: v3
1 parent 9e4e122 commit ab6e340

File tree

11 files changed

+81
-189
lines changed

11 files changed

+81
-189
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 755f6229da1d436f4cb23fffea644ba13291b434
2+
refs/heads/master: fadc6cc4b006d0eb6250afb899f10f8b67ad546d
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6c08cc2db4f98e9f07ae7d50338396c4123c2f0a
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729

trunk/RELEASES.txt

Lines changed: 0 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,148 +1,3 @@
1-
Version 0.8 (October 2013)
2-
--------------------------
3-
4-
* ~2100 changes, numerous bugfixes
5-
6-
* Language
7-
* The `for` loop syntax has changed to work with the `Iterator` trait.
8-
* At long last, unwinding works on Windows.
9-
* Default methods definitely mostly work.
10-
* Many trait inheritance bugs fixed.
11-
* Owned and borrowed trait objects work more reliably.
12-
* `copy` is no longer a keyword. It has been replaced by the `Clone` trait.
13-
* rustc no longer emits code for the `debug!` macro unless it is passed
14-
`--cfg debug`
15-
* mod.rs is now "blessed". When loading `mod foo;`, rustc will now look
16-
for foo.rs, then foo/mod.rs, and will generate an error when both are
17-
present.
18-
* Strings no longer contain trailing nulls. The new `std::c_str` module
19-
provides new mechanisms for converting to C strings.
20-
* The type of foreign functions is now `extern "C" fn` instead of `*u8'.
21-
* The FFI has been overhauled such that foreign functions are called directly,
22-
instead of through a stack-switching wrapper.
23-
* Calling a foreign function must be done through a Rust function with the
24-
`#[fixed_stack_segment]` attribute.
25-
* The `externfn!` macro can be used to declare both a foreign function and
26-
a `#[fixed_stack_segment]` wrapper at once.
27-
* `pub` and `priv` modifiers on `extern` blocks are no longer parsed.
28-
* `unsafe` is no longer allowed on extern fns - they are all unsafe.
29-
* `priv` is disallowed everywhere except for struct fields and enum variants.
30-
* `&T` (besides `&'static T`) is no longer allowed in `@T`.
31-
* `ref` bindings in irrefutable patterns work correctly now.
32-
* `char` is now prevented from containing invalid code points.
33-
* Casting to `bool` is no longer allowed.
34-
* `yield` is a reserved keyword.
35-
* `typeof` is a reserved keyword.
36-
* Crates may be imported by URL with `extern mod foo = "url";`.
37-
* Explicit enum discriminants may be given as uints as in `enum E { V = 0u }`
38-
* Static vectors can be initialized with repeating elements,
39-
e.g. `static foo: [u8, .. 100]: [0, .. 100];`.
40-
* Static structs can be initialized with functional record update,
41-
e.g. `static foo: Foo = Foo { a: 5, .. bar };`.
42-
* `cfg!` can be used to conditionally execute code based on the crate
43-
configuration, similarly to `#[cfg(...)]`.
44-
* The `unnecessary_qualification` lint detects unneeded module
45-
prefixes (default: allow).
46-
* Arithmetic operations have been implemented on the SIMD types in
47-
`std::unstable::simd`.
48-
* Exchange allocation headers were removed, reducing memory usage.
49-
* `format!` implements a completely new, extensible, and higher-performance
50-
string formatting system. It will replace `fmt!`.
51-
* `print!` and `println!` write formatted strings (using the `format!`
52-
extension) to stdout.
53-
* `write!` and `writeln!` write formatted strings (using the `format!`
54-
extension) to the new Writers in `std::rt::io`.
55-
* The library section in which a function or static is placed may
56-
be specified with `#[link_section = "..."]`.
57-
* The `proto!` syntax extension for defining bounded message protocols
58-
was removed.
59-
* `macro_rules!` is hygenic for `let` declarations.
60-
* The `#[export_name]` attribute specifies the name of a symbol.
61-
* `unreachable!` can be used to indicate unreachable code, and fails
62-
if executed.
63-
64-
* Libraries
65-
* std: Transitioned to the new runtime, written in Rust.
66-
* std: Added an experimental I/O library, `rt::io`, based on the new
67-
runtime.
68-
* std: A new generic `range` function was added to the prelude, replacing
69-
`uint::range` and friends.
70-
* std: `range_rev` no longer exists. Since range is an iterator it can be
71-
reversed with `range(lo, hi).invert()`.
72-
* std: The `chain` method on option renamed to `and_then`; `unwrap_or_default`
73-
renamed to `unwrap_or`.
74-
* std: The `iterator` module was renamed to `iter`.
75-
* std: Integral types now support the `checked_add`, `checked_sub`, and
76-
`checked_mul` operations for detecting overflow.
77-
* std: Many methods in `str`, `vec`, `option, `result` were renamed for
78-
consistency.
79-
* std: Methods are standardizing on conventions for casting methods:
80-
`to_foo` for copying, `into_foo` for moving, `as_foo` for temporary
81-
and cheap casts.
82-
* std: The `CString` type in `c_str` provides new ways to convert to and
83-
from C strings.
84-
* std: `DoubleEndedIterator` can yield elements in two directions.
85-
* std: The `mut_split` method on vectors partitions an `&mut [T]` into
86-
two splices.
87-
* std: `str::from_bytes` renamed to `str::from_utf8`.
88-
* std: `pop_opt` and `shift_opt` methods added to vectors.
89-
* std: The task-local data interface no longer uses @, and keys are
90-
no longer function pointers.
91-
* std: The `swap_unwrap` method of `Option` renamed to `take_unwrap`.
92-
* std: Added `SharedPort` to `comm`.
93-
* std: `Eq` has a default method for `ne`; only `eq` is required
94-
in implementations.
95-
* std: `Ord` has default methods for `le`, `gt` and `le`; only `lt`
96-
is required in implementations.
97-
* std: `is_utf8` performance is improved, impacting many string functions.
98-
* std: `os::MemoryMap` provides cross-platform mmap.
99-
* std: `ptr::offset` is now unsafe, but also more optimized. Offsets that
100-
are not 'in-bounds' are considered undefined.
101-
* std: Many freestanding functions in `vec` removed in favor of methods.
102-
* std: Many freestanding functions on scalar types removed in favor of
103-
methods.
104-
* std: Many options to task builders were removed since they don't make
105-
sense in the new scheduler design.
106-
* std: More containers implement `FromIterator` so can be created by the
107-
`collect` method.
108-
* std: More complete atomic types in `unstable::atomics`.
109-
* std: `comm::PortSet` removed.
110-
* std: Mutating methods in the `Set` and `Map` traits have been moved into
111-
the `MutableSet` and `MutableMap` traits. `Container::is_empty`,
112-
`Map::contains_key`, `MutableMap::insert`, and `MutableMap::remove` have
113-
default implementations.
114-
* extra: `dlist`, the doubly-linked list was modernized.
115-
* extra: Added a `hex` module with `ToHex` and `FromHex` traits.
116-
* extra: Added `glob` module, replacing `std::os::glob`.
117-
* extra: `rope` was removed.
118-
* extra: `deque` was renamed to `ringbuf`. `RingBuf` implements `Deque`.
119-
* extra: `net`, and `timer` were removed. The experimental replacements
120-
are `std::rt::io::net` and `std::rt::io::timer`.
121-
* extra: Iterators implemented for `SmallIntMap`.
122-
* extra: Iterators implemented for `Bitv` and `BitvSet`.
123-
* extra: `SmallIntSet` removed. Use `BitvSet`.
124-
* extra: Performance of JSON parsing greatly improved.
125-
* extra: `semver` updated to SemVer 2.0.0.
126-
* extra: `term` handles more terminals correctly.
127-
* extra: `dbg` module removed.
128-
129-
* Other
130-
* rustc's debug info generation (`-Z debug-info`) is greatly improved.
131-
* rustc accepts `--target-cpu` to compile to a specific CPU architecture,
132-
similarly to gcc's `--march` flag.
133-
* rustpkg has received many improvements.
134-
* rustpkg supports git tags as package IDs.
135-
* rustpkg builds into target-specific directories so it can be used for
136-
cross-compiling.
137-
* The number of concurrent test tasks is controlled by the environment
138-
variable RUST_TEST_TASKS.
139-
* The test harness can now report metrics for benchmarks.
140-
* All tools have man pages.
141-
* Programs compiled with `--test` now support the `-h` and `--help` flags.
142-
* The runtime uses jemalloc for allocations.
143-
* Segmented stacks are temporarily disabled as part of the transition to
144-
the new runtime. Stack overflows are possible!
145-
1461
Version 0.7 (July 2013)
1472
-----------------------
1483

trunk/src/librustc/middle/trans/expr.rs

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,36 @@ pub fn trans_to_datum(bcx: @mut Block, expr: @ast::Expr) -> DatumBlock {
313313
let target_obj_ty = expr_ty_adjusted(bcx, expr);
314314
debug!("auto_borrow_obj(target=%s)",
315315
target_obj_ty.repr(tcx));
316+
317+
// Extract source store information
318+
let (source_store, source_mutbl) = match ty::get(source_datum.ty).sty {
319+
ty::ty_trait(_, _, s, m, _) => (s, m),
320+
_ => {
321+
bcx.sess().span_bug(
322+
expr.span,
323+
fmt!("auto_borrow_trait_obj expected a trait, found %s",
324+
source_datum.ty.repr(bcx.tcx())));
325+
}
326+
};
327+
328+
// check if any borrowing is really needed or we could reuse the source_datum instead
329+
match ty::get(target_obj_ty).sty {
330+
ty::ty_trait(_, _, ty::RegionTraitStore(target_scope), target_mutbl, _) => {
331+
if target_mutbl == ast::MutImmutable && target_mutbl == source_mutbl {
332+
match source_store {
333+
ty::RegionTraitStore(source_scope) => {
334+
if tcx.region_maps.is_subregion_of(target_scope, source_scope) {
335+
return DatumBlock { bcx: bcx, datum: source_datum };
336+
}
337+
},
338+
_ => {}
339+
340+
};
341+
}
342+
},
343+
_ => {}
344+
}
345+
316346
let scratch = scratch_datum(bcx, target_obj_ty,
317347
"__auto_borrow_obj", false);
318348

@@ -331,15 +361,6 @@ pub fn trans_to_datum(bcx: @mut Block, expr: @ast::Expr) -> DatumBlock {
331361
// ~T, or &T, depending on source_obj_ty.
332362
let source_data_ptr = GEPi(bcx, source_llval, [0u, abi::trt_field_box]);
333363
let source_data = Load(bcx, source_data_ptr); // always a ptr
334-
let (source_store, source_mutbl) = match ty::get(source_datum.ty).sty {
335-
ty::ty_trait(_, _, s, m, _) => (s, m),
336-
_ => {
337-
bcx.sess().span_bug(
338-
expr.span,
339-
fmt!("auto_borrow_trait_obj expected a trait, found %s",
340-
source_datum.ty.repr(bcx.tcx())));
341-
}
342-
};
343364
let target_data = match source_store {
344365
ty::BoxTraitStore(*) => {
345366
// For deref of @T or @mut T, create a dummy datum and

trunk/src/librustc/middle/trans/meth.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,13 +434,22 @@ pub fn trans_trait_callee(bcx: @mut Block,
434434
let _icx = push_ctxt("impl::trans_trait_callee");
435435
let mut bcx = bcx;
436436

437+
// make a local copy for trait if needed
437438
let self_ty = expr_ty_adjusted(bcx, self_expr);
438-
let self_scratch = scratch_datum(bcx, self_ty, "__trait_callee", false);
439-
bcx = expr::trans_into(bcx, self_expr, expr::SaveIn(self_scratch.val));
439+
let self_scratch = match ty::get(self_ty).sty {
440+
ty::ty_trait(_, _, ty::RegionTraitStore(*), _, _) => {
441+
unpack_datum!(bcx, expr::trans_to_datum(bcx, self_expr))
442+
}
443+
_ => {
444+
let d = scratch_datum(bcx, self_ty, "__trait_callee", false);
445+
bcx = expr::trans_into(bcx, self_expr, expr::SaveIn(d.val));
446+
// Arrange a temporary cleanup for the object in case something
447+
// should go wrong before the method is actually *invoked*.
448+
d.add_clean(bcx);
449+
d
450+
}
451+
};
440452

441-
// Arrange a temporary cleanup for the object in case something
442-
// should go wrong before the method is actually *invoked*.
443-
self_scratch.add_clean(bcx);
444453

445454
let callee_ty = node_id_type(bcx, callee_id);
446455
trans_trait_callee_from_llval(bcx,

trunk/src/librustc/middle/trans/type_.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -278,23 +278,12 @@ impl Type {
278278

279279
pub fn opaque_trait(ctx: &CrateContext, store: ty::TraitStore) -> Type {
280280
let tydesc_ptr = ctx.tydesc_type.ptr_to();
281-
match store {
282-
ty::BoxTraitStore => {
283-
Type::struct_(
284-
[ tydesc_ptr, Type::opaque_box(ctx).ptr_to() ],
285-
false)
286-
}
287-
ty::UniqTraitStore => {
288-
Type::struct_(
289-
[ tydesc_ptr, Type::unique(ctx, &Type::i8()).ptr_to()],
290-
false)
291-
}
292-
ty::RegionTraitStore(*) => {
293-
Type::struct_(
294-
[ tydesc_ptr, Type::i8().ptr_to() ],
295-
false)
296-
}
297-
}
281+
let box_ty = match store {
282+
ty::BoxTraitStore => Type::opaque_box(ctx),
283+
ty::UniqTraitStore => Type::unique(ctx, &Type::i8()),
284+
ty::RegionTraitStore(*) => Type::i8()
285+
};
286+
Type::struct_([tydesc_ptr, box_ty.ptr_to()], false)
298287
}
299288

300289
pub fn kind(&self) -> TypeKind {

trunk/src/libstd/option.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,14 +467,23 @@ impl<T: Default> Option<T> {
467467
None => Default::default()
468468
}
469469
}
470+
471+
/// Returns self or `Some`-wrapped default value
472+
#[inline]
473+
pub fn or_default(self) -> Option<T> {
474+
match self {
475+
None => Some(Default::default()),
476+
x => x,
477+
}
478+
}
470479
}
471480

472481
impl<T> Default for Option<T> {
473482
#[inline]
474483
fn default() -> Option<T> { None }
475484
}
476485

477-
impl<T: Zero> Option<T> {
486+
impl<T:Zero> Option<T> {
478487
/// Returns the contained value or zero (for this type)
479488
#[inline]
480489
pub fn unwrap_or_zero(self) -> T {
@@ -483,6 +492,15 @@ impl<T: Zero> Option<T> {
483492
None => Zero::zero()
484493
}
485494
}
495+
496+
/// Returns self or `Some`-wrapped zero value
497+
#[inline]
498+
pub fn or_zero(self) -> Option<T> {
499+
match self {
500+
None => Some(Zero::zero()),
501+
x => x
502+
}
503+
}
486504
}
487505

488506
/// An iterator that yields either one or zero elements

trunk/src/libsyntax/ext/deriving/default.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ fn default_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Exp
4747
cx.ident_of("Default"),
4848
cx.ident_of("default")
4949
];
50-
let default_call = cx.expr_call_global(span, default_ident.clone(), ~[]);
50+
let default_call = || {
51+
cx.expr_call_global(span, default_ident.clone(), ~[])
52+
};
5153

5254
return match *substr.fields {
5355
StaticStruct(_, ref summary) => {
@@ -56,13 +58,13 @@ fn default_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Exp
5658
if count == 0 {
5759
cx.expr_ident(span, substr.type_ident)
5860
} else {
59-
let exprs = vec::from_elem(count, default_call);
61+
let exprs = vec::from_fn(count, |_| default_call());
6062
cx.expr_call_ident(span, substr.type_ident, exprs)
6163
}
6264
}
6365
Right(ref fields) => {
6466
let default_fields = do fields.map |ident| {
65-
cx.field_imm(span, *ident, default_call)
67+
cx.field_imm(span, *ident, default_call())
6668
};
6769
cx.expr_struct_ident(span, substr.type_ident, default_fields)
6870
}

trunk/src/libsyntax/ext/deriving/zero.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ fn zero_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
6262
cx.ident_of("Zero"),
6363
cx.ident_of("zero")
6464
];
65-
let zero_call = cx.expr_call_global(span, zero_ident.clone(), ~[]);
65+
let zero_call = || {
66+
cx.expr_call_global(span, zero_ident.clone(), ~[])
67+
};
6668

6769
return match *substr.fields {
6870
StaticStruct(_, ref summary) => {
@@ -71,13 +73,13 @@ fn zero_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
7173
if count == 0 {
7274
cx.expr_ident(span, substr.type_ident)
7375
} else {
74-
let exprs = vec::from_elem(count, zero_call);
76+
let exprs = vec::from_fn(count, |_| zero_call());
7577
cx.expr_call_ident(span, substr.type_ident, exprs)
7678
}
7779
}
7880
Right(ref fields) => {
7981
let zero_fields = do fields.map |ident| {
80-
cx.field_imm(span, *ident, zero_call)
82+
cx.field_imm(span, *ident, zero_call())
8183
};
8284
cx.expr_struct_ident(span, substr.type_ident, zero_fields)
8385
}

trunk/src/libsyntax/ext/format.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ impl Context {
7676
self.ecx.span_err(sp, "expected token: `,`");
7777
return (extra, None);
7878
}
79-
if *p.token == token::EOF { break } // accept trailing commas
8079
if named || (token::is_ident(p.token) &&
8180
p.look_ahead(1, |t| *t == token::EQ)) {
8281
named = true;

trunk/src/test/run-pass/core-run-destroy.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ fn test_destroy_actually_kills(force: bool) {
5555

5656
#[cfg(windows)]
5757
fn process_exists(pid: libc::pid_t) -> bool {
58+
#[fixed_stack_segment];
5859

5960
use std::libc::types::os::arch::extra::DWORD;
6061
use std::libc::funcs::extra::kernel32::{CloseHandle, GetExitCodeProcess, OpenProcess};

trunk/src/test/run-pass/ifmt.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,6 @@ pub fn main() {
243243
}
244244

245245
test_format_args();
246-
247-
// test that trailing commas are acceptable
248-
format!("{}", "test",);
249-
format!("{foo}", foo="test",);
250246
}
251247

252248
// Basic test to make sure that we can invoke the `write!` macro with an

0 commit comments

Comments
 (0)