Skip to content

Commit 1397f7f

Browse files
committed
---
yaml --- r: 233146 b: refs/heads/beta c: 607c70e h: refs/heads/master v: v3
1 parent 13ec47f commit 1397f7f

32 files changed

+57
-306
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: 871fd5eb73828561c07fd0f9d44a341b87c59f52
26+
refs/heads/beta: 607c70e50f6ed1827dadd548e367f02d34213f12
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/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 lifteimes aspect.
84+
just focus on the lifetimes 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)]

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)]

branches/beta/src/libsyntax/ext/base.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,6 @@ pub trait MacResult {
290290
fn make_stmts(self: Box<Self>) -> Option<SmallVector<P<ast::Stmt>>> {
291291
make_stmts_default!(self)
292292
}
293-
294-
fn make_ty(self: Box<Self>) -> Option<P<ast::Ty>> {
295-
None
296-
}
297293
}
298294

299295
macro_rules! make_MacEager {
@@ -326,7 +322,6 @@ make_MacEager! {
326322
items: SmallVector<P<ast::Item>>,
327323
impl_items: SmallVector<P<ast::ImplItem>>,
328324
stmts: SmallVector<P<ast::Stmt>>,
329-
ty: P<ast::Ty>,
330325
}
331326

332327
impl MacResult for MacEager {
@@ -364,10 +359,6 @@ impl MacResult for MacEager {
364359
}
365360
None
366361
}
367-
368-
fn make_ty(self: Box<Self>) -> Option<P<ast::Ty>> {
369-
self.ty
370-
}
371362
}
372363

373364
/// Fill-in macro expansion result, to allow compilation to continue
@@ -414,24 +405,15 @@ impl DummyResult {
414405
}
415406
}
416407

417-
pub fn raw_ty(sp: Span) -> P<ast::Ty> {
418-
P(ast::Ty {
419-
id: ast::DUMMY_NODE_ID,
420-
node: ast::TyInfer,
421-
span: sp
422-
})
423-
}
424408
}
425409

426410
impl MacResult for DummyResult {
427411
fn make_expr(self: Box<DummyResult>) -> Option<P<ast::Expr>> {
428412
Some(DummyResult::raw_expr(self.span))
429413
}
430-
431414
fn make_pat(self: Box<DummyResult>) -> Option<P<ast::Pat>> {
432415
Some(P(DummyResult::raw_pat(self.span)))
433416
}
434-
435417
fn make_items(self: Box<DummyResult>) -> Option<SmallVector<P<ast::Item>>> {
436418
// this code needs a comment... why not always just return the Some() ?
437419
if self.expr_only {
@@ -440,15 +422,13 @@ impl MacResult for DummyResult {
440422
Some(SmallVector::zero())
441423
}
442424
}
443-
444425
fn make_impl_items(self: Box<DummyResult>) -> Option<SmallVector<P<ast::ImplItem>>> {
445426
if self.expr_only {
446427
None
447428
} else {
448429
Some(SmallVector::zero())
449430
}
450431
}
451-
452432
fn make_stmts(self: Box<DummyResult>) -> Option<SmallVector<P<ast::Stmt>>> {
453433
Some(SmallVector::one(P(
454434
codemap::respan(self.span,

0 commit comments

Comments
 (0)