Skip to content

Commit ef8fcdf

Browse files
Ariel Ben-Yehudaarielb1
authored andcommitted
---
yaml --- r: 233150 b: refs/heads/beta c: 03ee3f5 h: refs/heads/master v: v3
1 parent 93d829b commit ef8fcdf

35 files changed

+130
-307
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 9bba7110639cbd1d51977d97106d377fdfac7cdf
26+
refs/heads/beta: 03ee3f5c204cb9b20c58a5cd2d61dc792727dad7
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 370fe2786109360f7c35b8ba552b83b773dd71d6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/doc/nomicon/exotic-sizes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ support values.
8585
Safe code need not worry about ZSTs, but *unsafe* code must be careful about the
8686
consequence of types with no size. In particular, pointer offsets are no-ops,
8787
and standard allocators (including jemalloc, the one used by default in Rust)
88-
may return `nullptr` when a zero-sized allocation is requested, which is
89-
indistinguishable from out of memory.
88+
generally consider passing in `0` for the size of an allocation as Undefined
89+
Behaviour.
9090

9191

9292

branches/beta/src/doc/nomicon/lifetimes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ likely desugar to the following:
5252
}
5353
```
5454

55-
Wow. That's... awful. Let's all take a moment to thank Rust for making this easier.
55+
Wow. That's... awful. Let's all take a moment to thank Rust for being a
56+
diabetes-inducing torrent of syrupy-goodness.
5657

5758
Actually passing references to outer scopes will cause Rust to infer
5859
a larger lifetime:

branches/beta/src/doc/nomicon/repr-rust.md

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ struct A {
3636
}
3737
```
3838

39-
will be 32-bit aligned on an architecture that aligns these primitives to their
40-
respective sizes. The whole struct will therefore have a size that is a multiple
41-
of 32-bits. It will potentially become:
39+
will be 32-bit aligned assuming these primitives are aligned to their size.
40+
It will therefore have a size that is a multiple of 32-bits. It will potentially
41+
*really* become:
4242

4343
```rust
4444
struct A {
@@ -50,10 +50,10 @@ struct A {
5050
}
5151
```
5252

53-
There is *no indirection* for these types; all data is stored within the struct,
54-
as you would expect in C. However with the exception of arrays (which are
55-
densely packed and in-order), the layout of data is not by default specified in
56-
Rust. Given the two following struct definitions:
53+
There is *no indirection* for these types; all data is stored contiguously as
54+
you would expect in C. However with the exception of arrays (which are densely
55+
packed and in-order), the layout of data is not by default specified in Rust.
56+
Given the two following struct definitions:
5757

5858
```rust
5959
struct A {
@@ -62,17 +62,18 @@ struct A {
6262
}
6363

6464
struct B {
65-
a: i32,
65+
x: i32,
6666
b: u64,
6767
}
6868
```
6969

7070
Rust *does* guarantee that two instances of A have their data laid out in
71-
exactly the same way. However Rust *does not* currently guarantee that an
72-
instance of A has the same field ordering or padding as an instance of B, though
73-
in practice there's no reason why they wouldn't.
71+
exactly the same way. However Rust *does not* guarantee that an instance of A
72+
has the same field ordering or padding as an instance of B (in practice there's
73+
no particular reason why they wouldn't, other than that its not currently
74+
guaranteed).
7475

75-
With A and B as written, this point would seem to be pedantic, but several other
76+
With A and B as written, this is basically nonsensical, but several other
7677
features of Rust make it desirable for the language to play with data layout in
7778
complex ways.
7879

@@ -132,21 +133,18 @@ struct FooRepr {
132133
}
133134
```
134135

135-
And indeed this is approximately how it would be laid out in general (modulo the
136-
size and position of `tag`).
137-
138-
However there are several cases where such a representation is inefficient. The
139-
classic case of this is Rust's "null pointer optimization": an enum consisting
140-
of a single outer unit variant (e.g. `None`) and a (potentially nested) non-
141-
nullable pointer variant (e.g. `&T`) makes the tag unnecessary, because a null
142-
pointer value can safely be interpreted to mean that the unit variant is chosen
143-
instead. The net result is that, for example, `size_of::<Option<&T>>() ==
144-
size_of::<&T>()`.
136+
And indeed this is approximately how it would be laid out in general
137+
(modulo the size and position of `tag`). However there are several cases where
138+
such a representation is inefficient. The classic case of this is Rust's
139+
"null pointer optimization". Given a pointer that is known to not be null
140+
(e.g. `&u32`), an enum can *store* a discriminant bit *inside* the pointer
141+
by using null as a special value. The net result is that
142+
`size_of::<Option<&T>>() == size_of::<&T>()`
145143

146-
There are many types in Rust that are, or contain, non-nullable pointers such as
144+
There are many types in Rust that are, or contain, "not null" pointers such as
147145
`Box<T>`, `Vec<T>`, `String`, `&T`, and `&mut T`. Similarly, one can imagine
148146
nested enums pooling their tags into a single discriminant, as they are by
149-
definition known to have a limited range of valid values. In principle enums could
147+
definition known to have a limited range of valid values. In principle enums can
150148
use fairly elaborate algorithms to cache bits throughout nested types with
151149
special constrained representations. As such it is *especially* desirable that
152150
we leave enum layout unspecified today.

branches/beta/src/doc/trpl/advanced-linking.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ Static linking refers to the process of creating output that contain all
3838
required libraries and so don't need libraries installed on every system where
3939
you want to use your compiled project. Pure-Rust dependencies are statically
4040
linked by default so you can use created binaries and libraries without
41-
installing Rust everywhere. By contrast, native libraries
42-
(e.g. `libc` and `libm`) are usually dynamically linked, but it is possible to
41+
installing the Rust everywhere. By contrast, native libraries
42+
(e.g. `libc` and `libm`) usually dynamically linked, but it is possible to
4343
change this and statically link them as well.
4444

45-
Linking is a very platform-dependent topic, and static linking may not even be
46-
possible on some platforms! This section assumes some basic familiarity with
45+
Linking is a very platform dependent topic — on some platforms, static linking
46+
may not be possible at all! This section assumes some basic familiarity with
4747
linking on your platform of choice.
4848

4949
## Linux
@@ -71,7 +71,8 @@ Dynamic linking on Linux can be undesirable if you wish to use new library
7171
features on old systems or target systems which do not have the required
7272
dependencies for your program to run.
7373

74-
Static linking is supported via an alternative `libc`, `musl`. You can compile
74+
Static linking is supported via an alternative `libc`, `musl` - this must be
75+
enabled at Rust compile-time with some prerequisites available. You can compile
7576
your own version of Rust with `musl` enabled and install it into a custom
7677
directory with the instructions below:
7778

@@ -122,7 +123,7 @@ $ du -h musldist/bin/rustc
122123
```
123124

124125
You now have a build of a `musl`-enabled Rust! Because we've installed it to a
125-
custom prefix we need to make sure our system can find the binaries and appropriate
126+
custom prefix we need to make sure our system can the binaries and appropriate
126127
libraries when we try and run it:
127128

128129
```text

branches/beta/src/doc/trpl/lifetimes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ We previously talked a little about [function syntax][functions], but we didn’
8181
discuss the `<>`s after a function’s name. A function can have ‘generic
8282
parameters’ between the `<>`s, of which lifetimes are one kind. We’ll discuss
8383
other kinds of generics [later in the book][generics], but for now, let’s
84-
just focus on the lifetimes aspect.
84+
just focus on the lifteimes aspect.
8585

8686
[functions]: functions.html
8787
[generics]: generics.html

branches/beta/src/doc/trpl/references-and-borrowing.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,6 @@ This will print `6`. We make `y` a mutable reference to `x`, then add one to
125125
the thing `y` points at. You’ll notice that `x` had to be marked `mut` as well,
126126
if it wasn’t, we couldn’t take a mutable borrow to an immutable value.
127127

128-
You'll also notice we added an asterisk (`*`) in front of `y`, making it `*y`,
129-
this is because `y` is an `&mut` reference. You'll also need to use them for
130-
accessing the contents of a reference as well.
131-
132128
Otherwise, `&mut` references are just like references. There _is_ a large
133129
difference between the two, and how they interact, though. You can tell
134130
something is fishy in the above example, because we need that extra scope, with

branches/beta/src/librustc/metadata/creader.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ impl<'a> CrateReader<'a> {
261261
let loader::Library { dylib, rlib, metadata } = lib;
262262

263263
let cnum_map = self.resolve_crate_deps(root, metadata.as_slice(), span);
264-
let staged_api = self.is_staged_api(metadata.as_slice());
265264

266265
let cmeta = Rc::new( cstore::crate_metadata {
267266
name: name.to_string(),
@@ -271,7 +270,6 @@ impl<'a> CrateReader<'a> {
271270
cnum: cnum,
272271
codemap_import_info: RefCell::new(vec![]),
273272
span: span,
274-
staged_api: staged_api
275273
});
276274

277275
let source = cstore::CrateSource {
@@ -285,17 +283,6 @@ impl<'a> CrateReader<'a> {
285283
(cnum, cmeta, source)
286284
}
287285

288-
fn is_staged_api(&self, data: &[u8]) -> bool {
289-
let attrs = decoder::get_crate_attributes(data);
290-
for attr in &attrs {
291-
if &attr.name()[..] == "staged_api" {
292-
match attr.node.value.node { ast::MetaWord(_) => return true, _ => (/*pass*/) }
293-
}
294-
}
295-
296-
return false;
297-
}
298-
299286
fn resolve_crate(&mut self,
300287
root: &Option<CratePaths>,
301288
ident: &str,

branches/beta/src/librustc/metadata/csearch.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use rbml::reader;
2222
use std::rc::Rc;
2323
use syntax::ast;
2424
use syntax::attr;
25+
use syntax::attr::AttrMetaMethods;
2526
use syntax::diagnostic::expect;
2627

2728
use std::collections::hash_map::HashMap;
@@ -385,7 +386,15 @@ pub fn get_stability(cstore: &cstore::CStore,
385386
}
386387

387388
pub fn is_staged_api(cstore: &cstore::CStore, krate: ast::CrateNum) -> bool {
388-
cstore.get_crate_data(krate).staged_api
389+
let cdata = cstore.get_crate_data(krate);
390+
let attrs = decoder::get_crate_attributes(cdata.data());
391+
for attr in &attrs {
392+
if &attr.name()[..] == "staged_api" {
393+
match attr.node.value.node { ast::MetaWord(_) => return true, _ => (/*pass*/) }
394+
}
395+
}
396+
397+
return false;
389398
}
390399

391400
pub fn get_repr_attrs(cstore: &cstore::CStore, def: ast::DefId)

branches/beta/src/librustc/metadata/cstore.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ pub struct crate_metadata {
6363
pub cnum: ast::CrateNum,
6464
pub codemap_import_info: RefCell<Vec<ImportedFileMap>>,
6565
pub span: codemap::Span,
66-
pub staged_api: bool
6766
}
6867

6968
#[derive(Copy, Debug, PartialEq, Clone)]
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use std::fmt;
12+
use std::cell::Cell;
13+
14+
/// A write-once variable. When constructed, it is empty, and
15+
/// can only be set once.
16+
///
17+
/// Ivars ensure that data that can only be initialised once. A full
18+
/// implementation is used for concurrency and blocks on a read of an
19+
/// unfulfilled value. This implementation is more minimal and panics
20+
/// if you attempt to read the value before it has been set. It is also
21+
/// not `Sync`, but may be extended in the future to be usable as a true
22+
/// concurrency type.
23+
#[derive(PartialEq)]
24+
pub struct Ivar<T: Copy> {
25+
data: Cell<Option<T>>
26+
}
27+
28+
impl<T: Copy> Ivar<T> {
29+
pub fn new() -> Ivar<T> {
30+
Ivar {
31+
data: Cell::new(None)
32+
}
33+
}
34+
35+
pub fn get(&self) -> Option<T> {
36+
self.data.get()
37+
}
38+
39+
pub fn fulfill(&self, value: T) {
40+
assert!(self.data.get().is_none(),
41+
"Value already set!");
42+
self.data.set(Some(value));
43+
}
44+
45+
pub fn is_fulfilled(&self) -> bool {
46+
self.data.get().is_some()
47+
}
48+
49+
pub fn unwrap(&self) -> T {
50+
self.get().unwrap()
51+
}
52+
}
53+
54+
impl<T: Copy+fmt::Debug> fmt::Debug for Ivar<T> {
55+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
56+
match self.get() {
57+
Some(val) => write!(f, "Ivar({:?})", val),
58+
None => f.write_str("Ivar(<unfulfilled>)")
59+
}
60+
}
61+
}
62+
63+
impl<T: Copy> Clone for Ivar<T> {
64+
fn clone(&self) -> Ivar<T> {
65+
match self.get() {
66+
Some(val) => Ivar { data: Cell::new(Some(val)) },
67+
None => Ivar::new()
68+
}
69+
}
70+
}

branches/beta/src/librustc_data_structures/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ extern crate serialize as rustc_serialize; // used by deriving
3636
pub mod snapshot_vec;
3737
pub mod graph;
3838
pub mod bitvec;
39+
pub mod ivar;
3940
pub mod unify;

branches/beta/src/librustc_trans/trans/base.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,11 +1299,12 @@ pub fn init_function<'a, 'tcx>(fcx: &'a FunctionContext<'a, 'tcx>,
12991299
let init_val = C_u8(fcx.ccx, adt::DTOR_NEEDED_HINT);
13001300
let llname = &format!("dropflag_hint_{}", id);
13011301
debug!("adding hint {}", llname);
1302-
let ty = tcx.types.u8;
1303-
let ptr = alloc_ty(entry_bcx, ty, llname);
1302+
let ptr = alloc_ty(entry_bcx, tcx.types.u8, llname);
13041303
Store(entry_bcx, init_val, ptr);
1304+
let ty = tcx.mk_ptr(ty::TypeAndMut { ty: tcx.types.u8, mutbl: ast::MutMutable });
13051305
let flag = datum::Lvalue::new_dropflag_hint("base::init_function");
1306-
datum::Datum::new(ptr, ty, flag)
1306+
let datum = datum::Datum::new(ptr, ty, flag);
1307+
datum
13071308
};
13081309

13091310
let (var, datum) = match info {

branches/beta/src/librustc_typeck/astconv.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,9 +1662,6 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
16621662
// handled specially and will not descend into this routine.
16631663
this.ty_infer(None, None, None, ast_ty.span)
16641664
}
1665-
ast::TyMac(_) => {
1666-
tcx.sess.span_bug(ast_ty.span, "unexpanded type macro found conversion")
1667-
}
16681665
};
16691666

16701667
tcx.ast_ty_to_ty_cache.borrow_mut().insert(ast_ty.id, typ);

branches/beta/src/librustdoc/clean/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,9 +1611,6 @@ impl Clean<Type> for ast::Ty {
16111611
TyTypeof(..) => {
16121612
panic!("Unimplemented type {:?}", self.node)
16131613
},
1614-
TyMac(ref m) => {
1615-
cx.tcx().sess.span_bug(m.span, "unexpanded type macro found during cleaning")
1616-
}
16171614
}
16181615
}
16191616
}

branches/beta/src/libsyntax/ast.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,8 +1471,6 @@ pub enum Ty_ {
14711471
/// TyInfer means the type should be inferred instead of it having been
14721472
/// specified. This can appear anywhere in a type.
14731473
TyInfer,
1474-
// A macro in the type position.
1475-
TyMac(Mac)
14761474
}
14771475

14781476
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]

0 commit comments

Comments
 (0)