Skip to content

Commit 12b8201

Browse files
committed
---
yaml --- r: 96246 b: refs/heads/dist-snap c: 9ba473f h: refs/heads/master v: v3
1 parent bf257fd commit 12b8201

20 files changed

+616
-365
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: ae5a13d64321e49b8a35c120d7f2fa0d5578d8fa
9+
refs/heads/dist-snap: 9ba473f86f900bf5a5009bf0695b6d9618df83ca
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/front/feature_gate.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use syntax::attr::AttrMetaMethods;
2323
use syntax::codemap::Span;
2424
use syntax::visit;
2525
use syntax::visit::Visitor;
26+
use syntax::parse::token;
2627

2728
use driver::session::Session;
2829

@@ -36,6 +37,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
3637
("once_fns", Active),
3738
("asm", Active),
3839
("managed_boxes", Active),
40+
("non_ascii_idents", Active),
3941

4042
// These are used to test this portion of the compiler, they don't actually
4143
// mean anything
@@ -76,6 +78,15 @@ impl Context {
7678
}
7779

7880
impl Visitor<()> for Context {
81+
fn visit_ident(&mut self, sp: Span, id: ast::Ident, _: ()) {
82+
let s = token::ident_to_str(&id);
83+
84+
if !s.is_ascii() {
85+
self.gate_feature("non_ascii_idents", sp,
86+
"non-ascii idents are not fully supported.");
87+
}
88+
}
89+
7990
fn visit_view_item(&mut self, i: &ast::view_item, _: ()) {
8091
match i.node {
8192
ast::view_item_use(ref paths) => {

branches/dist-snap/src/librustc/middle/typeck/infer/region_inference/mod.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use middle::graph::{Direction, NodeIndex};
2424
use util::common::indenter;
2525
use util::ppaux::{Repr};
2626

27-
use std::cell::Cell;
2827
use std::hashmap::{HashMap, HashSet};
2928
use std::uint;
3029
use std::vec;
@@ -106,16 +105,15 @@ pub struct RegionVarBindings {
106105
undo_log: ~[UndoLogEntry],
107106

108107
// This contains the results of inference. It begins as an empty
109-
// cell and only acquires a value after inference is complete.
110-
// We use a cell vs a mutable option to circumvent borrowck errors.
111-
values: Cell<~[VarValue]>,
108+
// option and only acquires a value after inference is complete.
109+
values: Option<~[VarValue]>,
112110
}
113111

114112
pub fn RegionVarBindings(tcx: ty::ctxt) -> RegionVarBindings {
115113
RegionVarBindings {
116114
tcx: tcx,
117115
var_origins: ~[],
118-
values: Cell::new_empty(),
116+
values: None,
119117
constraints: HashMap::new(),
120118
lubs: HashMap::new(),
121119
glbs: HashMap::new(),
@@ -226,7 +224,7 @@ impl RegionVarBindings {
226224
constraint: Constraint,
227225
origin: SubregionOrigin) {
228226
// cannot add constraints once regions are resolved
229-
assert!(self.values.is_empty());
227+
assert!(self.values.is_none());
230228

231229
debug!("RegionVarBindings: add_constraint({:?})", constraint);
232230

@@ -242,7 +240,7 @@ impl RegionVarBindings {
242240
sub: Region,
243241
sup: Region) {
244242
// cannot add constraints once regions are resolved
245-
assert!(self.values.is_empty());
243+
assert!(self.values.is_none());
246244

247245
debug!("RegionVarBindings: make_subregion({:?}, {:?})", sub, sup);
248246
match (sub, sup) {
@@ -277,7 +275,7 @@ impl RegionVarBindings {
277275
b: Region)
278276
-> Region {
279277
// cannot add constraints once regions are resolved
280-
assert!(self.values.is_empty());
278+
assert!(self.values.is_none());
281279

282280
debug!("RegionVarBindings: lub_regions({:?}, {:?})", a, b);
283281
match (a, b) {
@@ -300,7 +298,7 @@ impl RegionVarBindings {
300298
b: Region)
301299
-> Region {
302300
// cannot add constraints once regions are resolved
303-
assert!(self.values.is_empty());
301+
assert!(self.values.is_none());
304302

305303
debug!("RegionVarBindings: glb_regions({:?}, {:?})", a, b);
306304
match (a, b) {
@@ -319,14 +317,14 @@ impl RegionVarBindings {
319317
}
320318

321319
pub fn resolve_var(&mut self, rid: RegionVid) -> ty::Region {
322-
if self.values.is_empty() {
323-
self.tcx.sess.span_bug(
320+
let v = match self.values {
321+
None => self.tcx.sess.span_bug(
324322
self.var_origins[rid.to_uint()].span(),
325323
format!("Attempt to resolve region variable before values have \
326-
been computed!"));
327-
}
324+
been computed!")),
325+
Some(ref values) => values[rid.to_uint()]
326+
};
328327

329-
let v = self.values.with_ref(|values| values[rid.to_uint()]);
330328
debug!("RegionVarBindings: resolve_var({:?}={})={:?}",
331329
rid, rid.to_uint(), v);
332330
match v {
@@ -482,7 +480,7 @@ impl RegionVarBindings {
482480
debug!("RegionVarBindings: resolve_regions()");
483481
let mut errors = opt_vec::Empty;
484482
let v = self.infer_variable_values(&mut errors);
485-
self.values.put_back(v);
483+
self.values = Some(v);
486484
errors
487485
}
488486
}

branches/dist-snap/src/libstd/ascii.rs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,74 @@ impl Ascii {
5555
pub fn eq_ignore_case(self, other: Ascii) -> bool {
5656
ASCII_LOWER_MAP[self.chr] == ASCII_LOWER_MAP[other.chr]
5757
}
58+
59+
// the following methods are like ctype, and the implementation is inspired by musl
60+
61+
/// Check if the character is a letter (a-z, A-Z)
62+
#[inline]
63+
pub fn is_alpha(&self) -> bool {
64+
(self.chr >= 0x41 && self.chr <= 0x5A) || (self.chr >= 0x61 && self.chr <= 0x7A)
65+
}
66+
67+
/// Check if the character is a number (0-9)
68+
#[inline]
69+
pub fn is_digit(&self) -> bool {
70+
self.chr >= 0x31 && self.chr <= 0x39
71+
}
72+
73+
/// Check if the character is a letter or number
74+
#[inline]
75+
pub fn is_alnum(&self) -> bool {
76+
self.is_alpha() || self.is_digit()
77+
}
78+
79+
/// Check if the character is a space or horizontal tab
80+
#[inline]
81+
pub fn is_blank(&self) -> bool {
82+
self.chr == ' ' as u8 || self.chr == '\t' as u8
83+
}
84+
85+
/// Check if the character is a control character
86+
#[inline]
87+
pub fn is_control(&self) -> bool {
88+
self.chr <= 0x20 || self.chr == 0x7F
89+
}
90+
91+
/// Checks if the character is printable (except space)
92+
#[inline]
93+
pub fn is_graph(&self) -> bool {
94+
(self.chr - 0x21) < 0x5E
95+
}
96+
97+
/// Checks if the character is printable (including space)
98+
#[inline]
99+
pub fn is_print(&self) -> bool {
100+
(self.chr - 0x20) < 0x5F
101+
}
102+
103+
/// Checks if the character is lowercase
104+
#[inline]
105+
pub fn is_lower(&self) -> bool {
106+
(self.chr - 'a' as u8) < 26
107+
}
108+
109+
/// Checks if the character is uppercase
110+
#[inline]
111+
pub fn is_upper(&self) -> bool {
112+
(self.chr - 'A' as u8) < 26
113+
}
114+
115+
/// Checks if the character is punctuation
116+
#[inline]
117+
pub fn is_punctuation(&self) -> bool {
118+
self.is_graph() && !self.is_alnum()
119+
}
120+
121+
/// Checks if the character is a valid hex digit
122+
#[inline]
123+
pub fn is_hex(&self) -> bool {
124+
self.is_digit() || ((self.chr | 32u8) - 'a' as u8) < 6
125+
}
58126
}
59127

60128
impl ToStr for Ascii {

0 commit comments

Comments
 (0)