Skip to content

Commit 98bb653

Browse files
committed
---
yaml --- r: 130455 b: refs/heads/try c: b7d456d h: refs/heads/master i: 130453: accef2e 130451: 864fac9 130447: 6519042 v: v3
1 parent d822e85 commit 98bb653

Some content is hidden

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

45 files changed

+595
-160
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: c964cb229bd342bdeb0b4506c3a6d32b03e575f6
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 67b97ab6d2b7de9b69fd97dc171fcf8feec932ff
5-
refs/heads/try: 3c610af6706a66b185807b8ec721f454e16625de
5+
refs/heads/try: b7d456dfea5487c13ff0389c905693aad85f775f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/doc/complement-lang-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ We want to maintain the option to parametrize at runtime. We may eventually chan
8383

8484
## Why aren't values type-parametric? Why only items?
8585

86-
Doing so would make type inference much more complex, and require the implementation strategy of runtime parametrization.
86+
Doing so would make type inference much more complex, and require the implementation strategy of runtime parameterization.
8787

8888
## Why are enumerations nominal and closed?
8989

branches/try/src/doc/guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1808,7 +1808,7 @@ our code in this file. We'll talk about multiple-file projects later on in the
18081808
guide.
18091809

18101810
Before we move on, let me show you one more Cargo command: `run`. `cargo run`
1811-
is kind of like `cargo build`, but it also then runs the produced exectuable.
1811+
is kind of like `cargo build`, but it also then runs the produced executable.
18121812
Try it out:
18131813

18141814
```{notrust,ignore}

branches/try/src/doc/rust.md

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,7 +1954,7 @@ On `struct`s:
19541954

19551955
- `repr` - specifies the representation to use for this struct. Takes a list
19561956
of options. The currently accepted ones are `C` and `packed`, which may be
1957-
combined. `C` will use a C ABI comptible struct layout, and `packed` will
1957+
combined. `C` will use a C ABI compatible struct layout, and `packed` will
19581958
remove any padding between fields (note that this is very fragile and may
19591959
break platforms which require aligned access).
19601960

@@ -2367,7 +2367,7 @@ One can indicate the stability of an API using the following attributes:
23672367
These levels are directly inspired by
23682368
[Node.js' "stability index"](http://nodejs.org/api/documentation.html).
23692369

2370-
Stability levels are inherited, so an items's stability attribute is the
2370+
Stability levels are inherited, so an item's stability attribute is the
23712371
default stability for everything nested underneath it.
23722372

23732373
There are lints for disallowing items marked with certain levels: `deprecated`,
@@ -2444,7 +2444,7 @@ The currently implemented features of the reference compiler are:
24442444

24452445
* `concat_idents` - Allows use of the `concat_idents` macro, which is in many
24462446
ways insufficient for concatenating identifiers, and may
2447-
be removed entirely for something more wholsome.
2447+
be removed entirely for something more wholesome.
24482448

24492449
* `default_type_params` - Allows use of default type parameters. The future of
24502450
this feature is uncertain.
@@ -3604,7 +3604,7 @@ of the type.[^structtype]
36043604

36053605
New instances of a `struct` can be constructed with a [struct expression](#structure-expressions).
36063606

3607-
The memory layout of a `struct` is undefined by default to allow for compiler optimziations like
3607+
The memory layout of a `struct` is undefined by default to allow for compiler optimizations like
36083608
field reordering, but it can be fixed with the `#[repr(...)]` attribute.
36093609
In either case, fields may be given in any order in a corresponding struct *expression*;
36103610
the resulting `struct` value will always have the same memory layout.
@@ -3668,32 +3668,17 @@ let a: List<int> = Cons(7, box Cons(13, box Nil));
36683668

36693669
All pointers in Rust are explicit first-class values.
36703670
They can be copied, stored into data structures, and returned from functions.
3671-
There are four varieties of pointer in Rust:
3672-
3673-
* Owning pointers (`Box`)
3674-
: These point to owned heap allocations (or "boxes") in the shared, inter-task heap.
3675-
Each owned box has a single owning pointer; pointer and pointee retain a 1:1 relationship at all times.
3676-
Owning pointers are written `Box<content>`,
3677-
for example `Box<int>` means an owning pointer to an owned box containing an integer.
3678-
Copying an owned box is a "deep" operation:
3679-
it involves allocating a new owned box and copying the contents of the old box into the new box.
3680-
Releasing an owning pointer immediately releases its corresponding owned box.
3671+
There are two varieties of pointer in Rust:
36813672

36823673
* References (`&`)
36833674
: These point to memory _owned by some other value_.
3684-
References arise by (automatic) conversion from owning pointers, managed pointers,
3685-
or by applying the borrowing operator `&` to some other value,
3686-
including [lvalues, rvalues or temporaries](#lvalues,-rvalues-and-temporaries).
3687-
A borrow expression is written `&content`.
3688-
3689-
A reference type is written `&'f type` for some lifetime-variable `f`,
3690-
or just `&type` when the lifetime can be elided;
3691-
for example `&int` means a reference to an integer.
3675+
A reference type is written `&type` for some lifetime-variable `f`,
3676+
or just `&'a type` when you need an explicit lifetime.
36923677
Copying a reference is a "shallow" operation:
36933678
it involves only copying the pointer itself.
36943679
Releasing a reference typically has no effect on the value it points to,
3695-
with the exception of temporary values,
3696-
which are released when the last reference to them is released.
3680+
with the exception of temporary values, which are released when the last
3681+
reference to them is released.
36973682

36983683
* Raw pointers (`*`)
36993684
: Raw pointers are pointers without safety or liveness guarantees.
@@ -3706,6 +3691,9 @@ There are four varieties of pointer in Rust:
37063691
they exist to support interoperability with foreign code,
37073692
and writing performance-critical or low-level functions.
37083693

3694+
The standard library contains addtional 'smart pointer' types beyond references
3695+
and raw pointers.
3696+
37093697
### Function types
37103698

37113699
The function type constructor `fn` forms new function types.
@@ -4214,7 +4202,7 @@ be ignored in favor of only building the artifacts specified by command line.
42144202
purpose of this output type is to create a static library containing all of
42154203
the local crate's code along with all upstream dependencies. The static
42164204
library is actually a `*.a` archive on linux and osx and a `*.lib` file on
4217-
windows. This format is recommended for use in situtations such as linking
4205+
windows. This format is recommended for use in situations such as linking
42184206
Rust code into an existing non-Rust application because it will not have
42194207
dynamic dependencies on other Rust code.
42204208

branches/try/src/libnum/complex.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
//! Complex numbers.
1313
1414
use std::fmt;
15-
use std::num::{Zero,One,ToStrRadix};
15+
use std::num::{Zero, One, ToStrRadix};
1616

1717
// FIXME #1284: handle complex NaN & infinity etc. This
1818
// probably doesn't map to C's _Complex correctly.
1919

2020
/// A complex number in Cartesian form.
21-
#[deriving(PartialEq,Clone)]
21+
#[deriving(PartialEq, Clone, Hash)]
2222
pub struct Complex<T> {
2323
/// Real portion of the complex number
2424
pub re: T,
@@ -36,10 +36,8 @@ impl<T: Clone + Num> Complex<T> {
3636
Complex { re: re, im: im }
3737
}
3838

39-
/**
40-
Returns the square of the norm (since `T` doesn't necessarily
41-
have a sqrt function), i.e. `re^2 + im^2`.
42-
*/
39+
/// Returns the square of the norm (since `T` doesn't necessarily
40+
/// have a sqrt function), i.e. `re^2 + im^2`.
4341
#[inline]
4442
pub fn norm_sqr(&self) -> T {
4543
self.re * self.re + self.im * self.im
@@ -193,7 +191,8 @@ mod test {
193191
#![allow(non_uppercase_statics)]
194192

195193
use super::{Complex64, Complex};
196-
use std::num::{Zero,One,Float};
194+
use std::num::{Zero, One, Float};
195+
use std::hash::hash;
197196

198197
pub static _0_0i : Complex64 = Complex { re: 0.0, im: 0.0 };
199198
pub static _1_0i : Complex64 = Complex { re: 1.0, im: 0.0 };
@@ -367,4 +366,14 @@ mod test {
367366
test(-_neg1_1i, "1-1i".to_string());
368367
test(_05_05i, "0.5+0.5i".to_string());
369368
}
369+
370+
#[test]
371+
fn test_hash() {
372+
let a = Complex::new(0i32, 0i32);
373+
let b = Complex::new(1i32, 0i32);
374+
let c = Complex::new(0i32, 1i32);
375+
assert!(hash(&a) != hash(&b));
376+
assert!(hash(&b) != hash(&c));
377+
assert!(hash(&c) != hash(&a));
378+
}
370379
}

branches/try/src/libnum/rational.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use std::num::{Zero, One, ToStrRadix, FromStrRadix};
2121
use bigint::{BigInt, BigUint, Sign, Plus, Minus};
2222

2323
/// Represents the ratio between 2 numbers.
24-
#[deriving(Clone)]
24+
#[deriving(Clone, Hash)]
2525
#[allow(missing_doc)]
2626
pub struct Ratio<T> {
2727
numer: T,
@@ -380,6 +380,7 @@ mod test {
380380
use super::{Ratio, Rational, BigRational};
381381
use std::num::{Zero, One, FromStrRadix, FromPrimitive, ToStrRadix};
382382
use std::from_str::FromStr;
383+
use std::hash::hash;
383384
use std::num;
384385

385386
pub static _0 : Rational = Ratio { numer: 0, denom: 1};
@@ -751,4 +752,10 @@ mod test {
751752
assert!(! _neg1_2.is_positive());
752753
assert!(! _1_2.is_negative());
753754
}
755+
756+
#[test]
757+
fn test_hash() {
758+
assert!(hash(&_0) != hash(&_1));
759+
assert!(hash(&_0) != hash(&_3_2));
760+
}
754761
}

branches/try/src/librustc/diagnostics.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,6 @@ register_diagnostics!(
170170
E0156,
171171
E0157,
172172
E0158,
173-
E0159
173+
E0159,
174+
E0160
174175
)

branches/try/src/librustc/front/test.rs

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ struct TestCtxt<'a> {
5050
path: Vec<ast::Ident>,
5151
ext_cx: ExtCtxt<'a>,
5252
testfns: Vec<Test>,
53-
reexport_mod_ident: ast::Ident,
5453
reexport_test_harness_main: Option<InternedString>,
5554
is_test_crate: bool,
5655
config: ast::CrateConfig,
56+
57+
// top-level re-export submodule, filled out after folding is finished
58+
toplevel_reexport: Option<ast::Ident>,
5759
}
5860

5961
// Traverse the crate, collecting all the test functions, eliding any
@@ -83,7 +85,9 @@ pub fn modify_for_testing(sess: &Session,
8385
struct TestHarnessGenerator<'a> {
8486
cx: TestCtxt<'a>,
8587
tests: Vec<ast::Ident>,
86-
tested_submods: Vec<ast::Ident>,
88+
89+
// submodule name, gensym'd identifier for re-exports
90+
tested_submods: Vec<(ast::Ident, ast::Ident)>,
8791
}
8892

8993
impl<'a> fold::Folder for TestHarnessGenerator<'a> {
@@ -168,10 +172,14 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> {
168172
*i = nomain(*i);
169173
}
170174
if !tests.is_empty() || !tested_submods.is_empty() {
171-
mod_folded.items.push(mk_reexport_mod(&mut self.cx, tests,
172-
tested_submods));
175+
let (it, sym) = mk_reexport_mod(&mut self.cx, tests, tested_submods);
176+
mod_folded.items.push(it);
177+
173178
if !self.cx.path.is_empty() {
174-
self.tested_submods.push(self.cx.path[self.cx.path.len()-1]);
179+
self.tested_submods.push((self.cx.path[self.cx.path.len()-1], sym));
180+
} else {
181+
debug!("pushing nothing, sym: {}", sym);
182+
self.cx.toplevel_reexport = Some(sym);
175183
}
176184
}
177185

@@ -180,16 +188,16 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> {
180188
}
181189

182190
fn mk_reexport_mod(cx: &mut TestCtxt, tests: Vec<ast::Ident>,
183-
tested_submods: Vec<ast::Ident>) -> Gc<ast::Item> {
191+
tested_submods: Vec<(ast::Ident, ast::Ident)>) -> (Gc<ast::Item>, ast::Ident) {
184192
let mut view_items = Vec::new();
185193
let super_ = token::str_to_ident("super");
186194

187195
view_items.extend(tests.move_iter().map(|r| {
188196
cx.ext_cx.view_use_simple(DUMMY_SP, ast::Public,
189197
cx.ext_cx.path(DUMMY_SP, vec![super_, r]))
190198
}));
191-
view_items.extend(tested_submods.move_iter().map(|r| {
192-
let path = cx.ext_cx.path(DUMMY_SP, vec![super_, r, cx.reexport_mod_ident]);
199+
view_items.extend(tested_submods.move_iter().map(|(r, sym)| {
200+
let path = cx.ext_cx.path(DUMMY_SP, vec![super_, r, sym]);
193201
cx.ext_cx.view_use_simple_(DUMMY_SP, ast::Public, r, path)
194202
}));
195203

@@ -198,14 +206,18 @@ fn mk_reexport_mod(cx: &mut TestCtxt, tests: Vec<ast::Ident>,
198206
view_items: view_items,
199207
items: Vec::new(),
200208
};
201-
box(GC) ast::Item {
202-
ident: cx.reexport_mod_ident.clone(),
209+
210+
let sym = token::gensym_ident("__test_reexports");
211+
let it = box(GC) ast::Item {
212+
ident: sym.clone(),
203213
attrs: Vec::new(),
204214
id: ast::DUMMY_NODE_ID,
205215
node: ast::ItemMod(reexport_mod),
206216
vis: ast::Public,
207217
span: DUMMY_SP,
208-
}
218+
};
219+
220+
(it, sym)
209221
}
210222

211223
fn generate_test_harness(sess: &Session,
@@ -220,10 +232,10 @@ fn generate_test_harness(sess: &Session,
220232
}),
221233
path: Vec::new(),
222234
testfns: Vec::new(),
223-
reexport_mod_ident: token::gensym_ident("__test_reexports"),
224235
reexport_test_harness_main: reexport_test_harness_main,
225236
is_test_crate: is_test_crate(&krate),
226237
config: krate.config.clone(),
238+
toplevel_reexport: None,
227239
};
228240

229241
cx.ext_cx.bt_push(ExpnInfo {
@@ -530,7 +542,14 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> Gc<ast::Expr> {
530542
field("should_fail", fail_expr)]);
531543

532544

533-
let mut visible_path = vec![cx.reexport_mod_ident.clone()];
545+
let mut visible_path = match cx.toplevel_reexport {
546+
Some(id) => vec![id],
547+
None => {
548+
cx.sess.bug(
549+
"expected to find top-level re-export name, but found None"
550+
);
551+
}
552+
};
534553
visible_path.extend(path.move_iter());
535554

536555
let fn_expr = ecx.expr_path(ecx.path_global(span, visible_path));

branches/try/src/librustc/middle/astencode.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,9 +1073,18 @@ impl<'a> rbml_writer_helpers for Encoder<'a> {
10731073
this.emit_enum_variant_arg(0, |this| Ok(this.emit_unsize_kind(ecx, uk)))
10741074
})
10751075
}
1076-
&ty::AutoUnsafe(m) => {
1077-
this.emit_enum_variant("AutoUnsafe", 3, 1, |this| {
1078-
this.emit_enum_variant_arg(0, |this| m.encode(this))
1076+
&ty::AutoUnsafe(m, None) => {
1077+
this.emit_enum_variant("AutoUnsafe", 3, 2, |this| {
1078+
this.emit_enum_variant_arg(0, |this| m.encode(this));
1079+
this.emit_enum_variant_arg(1,
1080+
|this| this.emit_option(|this| this.emit_option_none()))
1081+
})
1082+
}
1083+
&ty::AutoUnsafe(m, Some(box ref a)) => {
1084+
this.emit_enum_variant("AutoUnsafe", 3, 2, |this| {
1085+
this.emit_enum_variant_arg(0, |this| m.encode(this));
1086+
this.emit_enum_variant_arg(1, |this| this.emit_option(
1087+
|this| this.emit_option_some(|this| Ok(this.emit_autoref(ecx, a)))))
10791088
})
10801089
}
10811090
}
@@ -1635,8 +1644,16 @@ impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> {
16351644
3 => {
16361645
let m: ast::Mutability =
16371646
this.read_enum_variant_arg(0, |this| Decodable::decode(this)).unwrap();
1647+
let a: Option<Box<ty::AutoRef>> =
1648+
this.read_enum_variant_arg(1, |this| this.read_option(|this, b| {
1649+
if b {
1650+
Ok(Some(box this.read_autoref(xcx)))
1651+
} else {
1652+
Ok(None)
1653+
}
1654+
})).unwrap();
16381655

1639-
ty::AutoUnsafe(m)
1656+
ty::AutoUnsafe(m, a)
16401657
}
16411658
_ => fail!("bad enum variant for ty::AutoRef")
16421659
})

branches/try/src/librustc/middle/expr_use_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ impl<'d,'t,TYPER:mc::Typer> ExprUseVisitor<'d,'t,TYPER> {
762762
ty::BorrowKind::from_mutbl(m),
763763
AutoRef);
764764
}
765-
ty::AutoUnsizeUniq(_) | ty::AutoUnsize(_) | ty::AutoUnsafe(_) => {}
765+
ty::AutoUnsizeUniq(_) | ty::AutoUnsize(_) | ty::AutoUnsafe(..) => {}
766766
}
767767
}
768768

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,9 @@ impl Case {
296296

297297
for (i, &ty) in self.tys.iter().enumerate() {
298298
match ty::get(ty).sty {
299-
// &T/&mut T could either be a thin or fat pointer depending on T
300-
ty::ty_rptr(_, ty::mt { ty, .. }) => match ty::get(ty).sty {
299+
// &T/&mut T/*T could either be a thin or fat pointer depending on T
300+
ty::ty_rptr(_, ty::mt { ty, .. })
301+
| ty::ty_ptr(ty::mt { ty, .. }) => match ty::get(ty).sty {
301302
// &[T] and &str are a pointer and length pair
302303
ty::ty_vec(_, None) | ty::ty_str => return Some(FatPointer(i, slice_elt_base)),
303304

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,8 @@ pub fn compare_scalar_types<'a>(
566566

567567
match ty::get(t).sty {
568568
ty::ty_nil => f(nil_type),
569-
ty::ty_bool | ty::ty_ptr(_) |
570-
ty::ty_uint(_) | ty::ty_char => f(unsigned_int),
569+
ty::ty_bool | ty::ty_uint(_) | ty::ty_char => f(unsigned_int),
570+
ty::ty_ptr(mt) if ty::type_is_sized(cx.tcx(), mt.ty) => f(unsigned_int),
571571
ty::ty_int(_) => f(signed_int),
572572
ty::ty_float(_) => f(floating_point),
573573
// Should never get here, because t is scalar.

0 commit comments

Comments
 (0)