Skip to content

Commit 8322f41

Browse files
committed
---
yaml --- r: 226171 b: refs/heads/snap-stage3 c: cf7e825 h: refs/heads/master i: 226169: d9c12cb 226167: fcc3aa1 v: v3
1 parent 32b0cd2 commit 8322f41

Some content is hidden

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

64 files changed

+2453
-388
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: e5d90d98402475b6e154ce216f9efcb80da1a747
3-
refs/heads/snap-stage3: eefeba08f8702481fdb38b915389d5470bc874d0
3+
refs/heads/snap-stage3: cf7e825ecdb00023f481e5648b356d40b606fa35
44
refs/heads/try: b53c0f93eedcdedd4fd89bccc5a3a09d1c5cd23e
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/snap-stage3/src/doc/reference.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,6 +2368,8 @@ The currently implemented features of the reference compiler are:
23682368
internally without imposing on callers
23692369
(i.e. making them behave like function calls in
23702370
terms of encapsulation).
2371+
* - `default_type_parameter_fallback` - Allows type parameter defaults to
2372+
influence type inference.
23712373

23722374
If a feature is promoted to a language feature, then all existing programs will
23732375
start to receive compilation warnings about `#![feature]` directives which enabled

branches/snap-stage3/src/doc/rust.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ a > code {
221221
color: #428BCA;
222222
}
223223

224+
.section-header > a > code {
225+
color: #8D1A38;
226+
}
227+
224228
/* Code highlighting */
225229
pre.rust .kw { color: #8959A8; }
226230
pre.rust .kw-2, pre.rust .prelude-ty { color: #4271AE; }

branches/snap-stage3/src/doc/trpl/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* [Iterators](iterators.md)
1717
* [Concurrency](concurrency.md)
1818
* [Error Handling](error-handling.md)
19+
* [Choosing your Guarantees](choosing-your-guarantees.md)
1920
* [FFI](ffi.md)
2021
* [Borrow and AsRef](borrow-and-asref.md)
2122
* [Release Channels](release-channels.md)

branches/snap-stage3/src/doc/trpl/choosing-your-guarantees.md

Lines changed: 356 additions & 0 deletions
Large diffs are not rendered by default.

branches/snap-stage3/src/libcore/char.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,18 @@ pub fn from_u32(i: u32) -> Option<char> {
8484
if (i > MAX as u32) || (i >= 0xD800 && i <= 0xDFFF) {
8585
None
8686
} else {
87-
Some(unsafe { transmute(i) })
87+
Some(unsafe { from_u32_unchecked(i) })
8888
}
8989
}
9090

91+
/// Converts a `u32` to an `char`, not checking whether it is a valid unicode
92+
/// codepoint.
93+
#[inline]
94+
#[unstable(feature = "char_from_unchecked", reason = "recently added API")]
95+
pub unsafe fn from_u32_unchecked(i: u32) -> char {
96+
transmute(i)
97+
}
98+
9199
/// Converts a number to the character representing it.
92100
///
93101
/// # Return value
@@ -115,12 +123,11 @@ pub fn from_digit(num: u32, radix: u32) -> Option<char> {
115123
panic!("from_digit: radix is too high (maximum 36)");
116124
}
117125
if num < radix {
118-
unsafe {
119-
if num < 10 {
120-
Some(transmute('0' as u32 + num))
121-
} else {
122-
Some(transmute('a' as u32 + num - 10))
123-
}
126+
let num = num as u8;
127+
if num < 10 {
128+
Some((b'0' + num) as char)
129+
} else {
130+
Some((b'a' + num - 10) as char)
124131
}
125132
} else {
126133
None
@@ -318,16 +325,13 @@ impl Iterator for EscapeUnicode {
318325
Some('{')
319326
}
320327
EscapeUnicodeState::Value(offset) => {
321-
let v = match ((self.c as i32) >> (offset * 4)) & 0xf {
322-
i @ 0 ... 9 => '0' as i32 + i,
323-
i => 'a' as i32 + (i - 10)
324-
};
328+
let c = from_digit(((self.c as u32) >> (offset * 4)) & 0xf, 16).unwrap();
325329
if offset == 0 {
326330
self.state = EscapeUnicodeState::RightBrace;
327331
} else {
328332
self.state = EscapeUnicodeState::Value(offset - 1);
329333
}
330-
Some(unsafe { transmute(v) })
334+
Some(c)
331335
}
332336
EscapeUnicodeState::RightBrace => {
333337
self.state = EscapeUnicodeState::Done;

branches/snap-stage3/src/librustc/ast_map/mod.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ pub enum Node<'ast> {
119119
NodeStructCtor(&'ast StructDef),
120120

121121
NodeLifetime(&'ast Lifetime),
122+
NodeTyParam(&'ast TyParam)
122123
}
123124

124125
/// Represents an entry and its parent NodeID.
@@ -142,6 +143,7 @@ enum MapEntry<'ast> {
142143
EntryBlock(NodeId, &'ast Block),
143144
EntryStructCtor(NodeId, &'ast StructDef),
144145
EntryLifetime(NodeId, &'ast Lifetime),
146+
EntryTyParam(NodeId, &'ast TyParam),
145147

146148
/// Roots for node trees.
147149
RootCrate,
@@ -175,7 +177,8 @@ impl<'ast> MapEntry<'ast> {
175177
NodePat(n) => EntryPat(p, n),
176178
NodeBlock(n) => EntryBlock(p, n),
177179
NodeStructCtor(n) => EntryStructCtor(p, n),
178-
NodeLifetime(n) => EntryLifetime(p, n)
180+
NodeLifetime(n) => EntryLifetime(p, n),
181+
NodeTyParam(n) => EntryTyParam(p, n),
179182
}
180183
}
181184

@@ -194,6 +197,7 @@ impl<'ast> MapEntry<'ast> {
194197
EntryBlock(id, _) => id,
195198
EntryStructCtor(id, _) => id,
196199
EntryLifetime(id, _) => id,
200+
EntryTyParam(id, _) => id,
197201
_ => return None
198202
})
199203
}
@@ -213,6 +217,7 @@ impl<'ast> MapEntry<'ast> {
213217
EntryBlock(_, n) => NodeBlock(n),
214218
EntryStructCtor(_, n) => NodeStructCtor(n),
215219
EntryLifetime(_, n) => NodeLifetime(n),
220+
EntryTyParam(_, n) => NodeTyParam(n),
216221
_ => return None
217222
})
218223
}
@@ -573,6 +578,7 @@ impl<'ast> Map<'ast> {
573578
Some(NodePat(pat)) => pat.span,
574579
Some(NodeBlock(block)) => block.span,
575580
Some(NodeStructCtor(_)) => self.expect_item(self.get_parent(id)).span,
581+
Some(NodeTyParam(ty_param)) => ty_param.span,
576582
_ => return None,
577583
};
578584
Some(sp)
@@ -815,6 +821,14 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
815821
self.parent_node = parent_node;
816822
}
817823

824+
fn visit_generics(&mut self, generics: &'ast Generics) {
825+
for ty_param in generics.ty_params.iter() {
826+
self.insert(ty_param.id, NodeTyParam(ty_param));
827+
}
828+
829+
visit::walk_generics(self, generics);
830+
}
831+
818832
fn visit_trait_item(&mut self, ti: &'ast TraitItem) {
819833
let parent_node = self.parent_node;
820834
self.parent_node = ti.id;
@@ -1015,7 +1029,7 @@ impl<'a> NodePrinter for pprust::State<'a> {
10151029
NodePat(a) => self.print_pat(&*a),
10161030
NodeBlock(a) => self.print_block(&*a),
10171031
NodeLifetime(a) => self.print_lifetime(&*a),
1018-
1032+
NodeTyParam(_) => panic!("cannot print TyParam"),
10191033
// these cases do not carry enough information in the
10201034
// ast_map to reconstruct their full structure for pretty
10211035
// printing.
@@ -1123,6 +1137,9 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
11231137
format!("lifetime {}{}",
11241138
pprust::lifetime_to_string(&**l), id_str)
11251139
}
1140+
Some(NodeTyParam(ref ty_param)) => {
1141+
format!("typaram {:?}{}", ty_param, id_str)
1142+
}
11261143
None => {
11271144
format!("unknown node{}", id_str)
11281145
}

0 commit comments

Comments
 (0)