Skip to content

Commit e593829

Browse files
author
Ruby
committed
---
yaml --- r: 223215 b: refs/heads/auto c: 855f1ff h: refs/heads/master i: 223213: e1636dc 223211: 6ea8cc9 223207: 2a84029 223199: b525570 v: v3
1 parent 8401bee commit e593829

26 files changed

+39
-277
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: 11deb083f5bc3e57e73fc82de4bef7b1d4dad7b1
11+
refs/heads/auto: 855f1ff3215e76d438783d8bdf743d6cb641ff89
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-
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/auto/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/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 and modifying `&` references 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_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/auto/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/auto/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/auto/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,

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

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,45 +1542,6 @@ fn expand_and_rename_method(sig: ast::MethodSig, body: P<ast::Block>,
15421542
}, rewritten_body)
15431543
}
15441544

1545-
pub fn expand_type(t: P<ast::Ty>, fld: &mut MacroExpander) -> P<ast::Ty> {
1546-
let t = match t.node.clone() {
1547-
ast::Ty_::TyMac(mac) => {
1548-
if fld.cx.ecfg.features.unwrap().type_macros {
1549-
let expanded_ty = match expand_mac_invoc(mac, t.span,
1550-
|r| r.make_ty(),
1551-
mark_ty,
1552-
fld) {
1553-
Some(ty) => ty,
1554-
None => {
1555-
return DummyResult::raw_ty(t.span);
1556-
}
1557-
};
1558-
1559-
// Keep going, outside-in.
1560-
let fully_expanded = fld.fold_ty(expanded_ty);
1561-
fld.cx.bt_pop();
1562-
1563-
fully_expanded.map(|t| ast::Ty {
1564-
id: ast::DUMMY_NODE_ID,
1565-
node: t.node,
1566-
span: t.span,
1567-
})
1568-
} else {
1569-
feature_gate::emit_feature_err(
1570-
&fld.cx.parse_sess.span_diagnostic,
1571-
"type_macros",
1572-
t.span,
1573-
"type macros are experimental (see issue: #27336)");
1574-
1575-
DummyResult::raw_ty(t.span)
1576-
}
1577-
}
1578-
_ => t
1579-
};
1580-
1581-
fold::noop_fold_ty(t, fld)
1582-
}
1583-
15841545
/// A tree-folder that performs macro expansion
15851546
pub struct MacroExpander<'a, 'b:'a> {
15861547
pub cx: &'a mut ExtCtxt<'b>,
@@ -1631,10 +1592,6 @@ impl<'a, 'b> Folder for MacroExpander<'a, 'b> {
16311592
.into_iter().map(|i| i.expect_impl_item()).collect()
16321593
}
16331594

1634-
fn fold_ty(&mut self, ty: P<ast::Ty>) -> P<ast::Ty> {
1635-
expand_type(ty, self)
1636-
}
1637-
16381595
fn new_span(&mut self, span: Span) -> Span {
16391596
new_span(self.cx, span)
16401597
}
@@ -1787,10 +1744,6 @@ fn mark_impl_item(ii: P<ast::ImplItem>, m: Mrk) -> P<ast::ImplItem> {
17871744
.expect_one("marking an impl item didn't return exactly one impl item")
17881745
}
17891746

1790-
fn mark_ty(ty: P<ast::Ty>, m: Mrk) -> P<ast::Ty> {
1791-
Marker { mark: m }.fold_ty(ty)
1792-
}
1793-
17941747
/// Check that there are no macro invocations left in the AST:
17951748
pub fn check_for_macros(sess: &parse::ParseSess, krate: &ast::Crate) {
17961749
visit::walk_crate(&mut MacroExterminator{sess:sess}, krate);

branches/auto/src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,6 @@ impl<'a> MacResult for ParserAnyMacro<'a> {
117117
self.ensure_complete_parse(false);
118118
Some(ret)
119119
}
120-
121-
fn make_ty(self: Box<ParserAnyMacro<'a>>) -> Option<P<ast::Ty>> {
122-
let ret = self.parser.borrow_mut().parse_ty();
123-
self.ensure_complete_parse(true);
124-
Some(ret)
125-
}
126120
}
127121

128122
struct MacroRulesMacroExpander {

branches/auto/src/libsyntax/feature_gate.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,6 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[
172172

173173
// Allows associated type defaults
174174
("associated_type_defaults", "1.2.0", Active),
175-
// Allows macros to appear in the type position.
176-
177-
("type_macros", "1.3.0", Active),
178175
];
179176
// (changing above list without updating src/doc/reference.md makes @cmr sad)
180177

@@ -357,7 +354,6 @@ pub struct Features {
357354
pub const_fn: bool,
358355
pub static_recursion: bool,
359356
pub default_type_parameter_fallback: bool,
360-
pub type_macros: bool,
361357
}
362358

363359
impl Features {
@@ -384,7 +380,6 @@ impl Features {
384380
const_fn: false,
385381
static_recursion: false,
386382
default_type_parameter_fallback: false,
387-
type_macros: false,
388383
}
389384
}
390385
}
@@ -888,7 +883,6 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler,
888883
const_fn: cx.has_feature("const_fn"),
889884
static_recursion: cx.has_feature("static_recursion"),
890885
default_type_parameter_fallback: cx.has_feature("default_type_parameter_fallback"),
891-
type_macros: cx.has_feature("type_macros"),
892886
}
893887
}
894888

branches/auto/src/libsyntax/fold.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,6 @@ pub fn noop_fold_ty<T: Folder>(t: P<Ty>, fld: &mut T) -> P<Ty> {
429429
TyPolyTraitRef(bounds) => {
430430
TyPolyTraitRef(bounds.move_map(|b| fld.fold_ty_param_bound(b)))
431431
}
432-
TyMac(mac) => {
433-
TyMac(fld.fold_mac(mac))
434-
}
435432
},
436433
span: fld.new_span(span)
437434
})

branches/auto/src/libsyntax/parse/parser.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ use ast::{SelfExplicit, SelfRegion, SelfStatic, SelfValue};
5151
use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef};
5252
use ast::{TtDelimited, TtSequence, TtToken};
5353
use ast::{TupleVariantKind, Ty, Ty_, TypeBinding};
54-
use ast::{TyMac};
5554
use ast::{TyFixedLengthVec, TyBareFn, TyTypeof, TyInfer};
5655
use ast::{TyParam, TyParamBound, TyParen, TyPath, TyPolyTraitRef, TyPtr};
5756
use ast::{TyRptr, TyTup, TyU32, TyVec, UnUniq};
@@ -1370,20 +1369,8 @@ impl<'a> Parser<'a> {
13701369
} else if self.check(&token::ModSep) ||
13711370
self.token.is_ident() ||
13721371
self.token.is_path() {
1373-
let path = try!(self.parse_path(LifetimeAndTypesWithoutColons));
1374-
if self.check(&token::Not) {
1375-
// MACRO INVOCATION
1376-
try!(self.bump());
1377-
let delim = try!(self.expect_open_delim());
1378-
let tts = try!(self.parse_seq_to_end(&token::CloseDelim(delim),
1379-
seq_sep_none(),
1380-
|p| p.parse_token_tree()));
1381-
let hi = self.span.hi;
1382-
TyMac(spanned(lo, hi, MacInvocTT(path, tts, EMPTY_CTXT)))
1383-
} else {
1384-
// NAMED TYPE
1385-
TyPath(None, path)
1386-
}
1372+
// NAMED TYPE
1373+
try!(self.parse_ty_path())
13871374
} else if try!(self.eat(&token::Underscore) ){
13881375
// TYPE TO BE INFERRED
13891376
TyInfer

branches/auto/src/libsyntax/print/pprust.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -734,9 +734,6 @@ impl<'a> State<'a> {
734734
ast::TyInfer => {
735735
try!(word(&mut self.s, "_"));
736736
}
737-
ast::TyMac(ref m) => {
738-
try!(self.print_mac(m, token::Paren));
739-
}
740737
}
741738
self.end()
742739
}

branches/auto/src/libsyntax/visit.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,6 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
405405
visitor.visit_expr(&**expression)
406406
}
407407
TyInfer => {}
408-
TyMac(ref mac) => {
409-
visitor.visit_mac(mac)
410-
}
411408
}
412409
}
413410

0 commit comments

Comments
 (0)