Skip to content

Commit ca51120

Browse files
committed
---
yaml --- r: 223223 b: refs/heads/auto c: b77d2f5 h: refs/heads/master i: 223221: ce19621 223219: f81c2d6 223215: e593829 v: v3
1 parent a158e51 commit ca51120

31 files changed

+305
-56
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: 607c70e50f6ed1827dadd548e367f02d34213f12
11+
refs/heads/auto: b77d2f5ac7684390c72c99511cb446db0f4ce20a
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/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-
generally consider passing in `0` for the size of an allocation as Undefined
89-
Behaviour.
88+
may return `nullptr` when a zero-sized allocation is requested, which is
89+
indistinguishable from out of memory.
9090

9191

9292

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

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

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:
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:
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 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:
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:
5757

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

6464
struct B {
65-
x: i32,
65+
a: 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* 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).
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.
7574

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

@@ -133,18 +132,21 @@ struct FooRepr {
133132
}
134133
```
135134

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>()`
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>()`.
143145

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

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

Lines changed: 6 additions & 7 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 the Rust everywhere. By contrast, native libraries
42-
(e.g. `libc` and `libm`) usually dynamically linked, but it is possible to
41+
installing Rust everywhere. By contrast, native libraries
42+
(e.g. `libc` and `libm`) are 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 — on some platforms, static linking
46-
may not be possible at all! This section assumes some basic familiarity with
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
4747
linking on your platform of choice.
4848

4949
## Linux
@@ -71,8 +71,7 @@ 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` - this must be
75-
enabled at Rust compile-time with some prerequisites available. You can compile
74+
Static linking is supported via an alternative `libc`, `musl`. You can compile
7675
your own version of Rust with `musl` enabled and install it into a custom
7776
directory with the instructions below:
7877

@@ -123,7 +122,7 @@ $ du -h musldist/bin/rustc
123122
```
124123

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

129128
```text

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ 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+
128132
Otherwise, `&mut` references are just like references. There _is_ a large
129133
difference between the two, and how they interact, though. You can tell
130134
something is fishy in the above example, because we need that extra scope, with

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ 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());
264265

265266
let cmeta = Rc::new( cstore::crate_metadata {
266267
name: name.to_string(),
@@ -270,6 +271,7 @@ impl<'a> CrateReader<'a> {
270271
cnum: cnum,
271272
codemap_import_info: RefCell::new(vec![]),
272273
span: span,
274+
staged_api: staged_api
273275
});
274276

275277
let source = cstore::CrateSource {
@@ -283,6 +285,17 @@ impl<'a> CrateReader<'a> {
283285
(cnum, cmeta, source)
284286
}
285287

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+
286299
fn resolve_crate(&mut self,
287300
root: &Option<CratePaths>,
288301
ident: &str,

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

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

2827
use std::collections::hash_map::HashMap;
@@ -386,15 +385,7 @@ pub fn get_stability(cstore: &cstore::CStore,
386385
}
387386

388387
pub fn is_staged_api(cstore: &cstore::CStore, krate: ast::CrateNum) -> bool {
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;
388+
cstore.get_crate_data(krate).staged_api
398389
}
399390

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

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ 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
6667
}
6768

6869
#[derive(Copy, Debug, PartialEq, Clone)]

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,12 +1299,11 @@ 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 ptr = alloc_ty(entry_bcx, tcx.types.u8, llname);
1302+
let ty = tcx.types.u8;
1303+
let ptr = alloc_ty(entry_bcx, ty, llname);
13031304
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-
let datum = datum::Datum::new(ptr, ty, flag);
1307-
datum
1306+
datum::Datum::new(ptr, ty, flag)
13081307
};
13091308

13101309
let (var, datum) = match info {

branches/auto/src/librustc_typeck/astconv.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,6 +1662,9 @@ 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+
}
16651668
};
16661669

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

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,9 @@ 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+
}
16141617
}
16151618
}
16161619
}

branches/auto/src/libsyntax/ast.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,6 +1471,8 @@ 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)
14741476
}
14751477

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

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,10 @@ 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+
}
293297
}
294298

295299
macro_rules! make_MacEager {
@@ -322,6 +326,7 @@ make_MacEager! {
322326
items: SmallVector<P<ast::Item>>,
323327
impl_items: SmallVector<P<ast::ImplItem>>,
324328
stmts: SmallVector<P<ast::Stmt>>,
329+
ty: P<ast::Ty>,
325330
}
326331

327332
impl MacResult for MacEager {
@@ -359,6 +364,10 @@ impl MacResult for MacEager {
359364
}
360365
None
361366
}
367+
368+
fn make_ty(self: Box<Self>) -> Option<P<ast::Ty>> {
369+
self.ty
370+
}
362371
}
363372

364373
/// Fill-in macro expansion result, to allow compilation to continue
@@ -405,15 +414,24 @@ impl DummyResult {
405414
}
406415
}
407416

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+
}
408424
}
409425

410426
impl MacResult for DummyResult {
411427
fn make_expr(self: Box<DummyResult>) -> Option<P<ast::Expr>> {
412428
Some(DummyResult::raw_expr(self.span))
413429
}
430+
414431
fn make_pat(self: Box<DummyResult>) -> Option<P<ast::Pat>> {
415432
Some(P(DummyResult::raw_pat(self.span)))
416433
}
434+
417435
fn make_items(self: Box<DummyResult>) -> Option<SmallVector<P<ast::Item>>> {
418436
// this code needs a comment... why not always just return the Some() ?
419437
if self.expr_only {
@@ -422,13 +440,15 @@ impl MacResult for DummyResult {
422440
Some(SmallVector::zero())
423441
}
424442
}
443+
425444
fn make_impl_items(self: Box<DummyResult>) -> Option<SmallVector<P<ast::ImplItem>>> {
426445
if self.expr_only {
427446
None
428447
} else {
429448
Some(SmallVector::zero())
430449
}
431450
}
451+
432452
fn make_stmts(self: Box<DummyResult>) -> Option<SmallVector<P<ast::Stmt>>> {
433453
Some(SmallVector::one(P(
434454
codemap::respan(self.span,

0 commit comments

Comments
 (0)