Skip to content

Commit 30ef0ca

Browse files
committed
---
yaml --- r: 152246 b: refs/heads/try2 c: 7645982 h: refs/heads/master v: v3
1 parent 4e7a3c0 commit 30ef0ca

File tree

18 files changed

+222
-122
lines changed

18 files changed

+222
-122
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 3b5d6fd25486b29a70adfda6cb917ced614bc6d2
8+
refs/heads/try2: 7645982efcaced211ad60870e9986c6b9f0f2079
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,37 @@ Source layout:
55
| Path | Description |
66
| ------------------- | --------------------------------------------------------- |
77
| `librustc/` | The self-hosted compiler |
8+
| `liballoc/` | Rust's core allocation library |
9+
| `libcore/` | The Rust core library |
10+
| `libdebug/` | Debugging utilities |
811
| `libstd/` | The standard library (imported and linked by default) |
9-
| `libextra/` | The "extras" library (slightly more peripheral code) |
1012
| `libgreen/` | The M:N runtime library |
1113
| `libnative/` | The 1:1 runtime library |
1214
| `libsyntax/` | The Rust parser and pretty-printer |
13-
| `libcollections/` | A collection of useful data structures and containers |
14-
| `libnum/` | Extended number support library (complex, rational, etc) |
1515
| `libtest/` | Rust's test-runner code |
1616
| ------------------- | --------------------------------------------------------- |
1717
| `libarena/` | The arena (a fast but limited) memory allocator |
18+
| `libbacktrace/` | The libbacktrace library |
19+
| `libcollections/` | A collection of useful data structures and containers |
1820
| `libflate/` | Simple compression library |
21+
| `libfmt_macros/` | Macro support for format strings |
1922
| `libfourcc/` | Data format identifier library |
2023
| `libgetopts/` | Get command-line-options library |
2124
| `libglob/` | Unix glob patterns library |
25+
| `libgraphviz/` | Generating files for Graphviz |
26+
| `libhexfloat/` | Hexadecimal floating-point literals |
27+
| `liblibc/` | Bindings for the C standard library |
28+
| `liblog/` | Utilities for program-wide and customizable logging |
29+
| `libnum/` | Extended number support library (complex, rational, etc) |
30+
| `librand/` | Random numbers and distributions |
2231
| `libregex/` | Regular expressions |
32+
| `libregex_macros/` | The regex! syntax extension |
2333
| `libsemver/` | Rust's semantic versioning library |
2434
| `libserialize/` | Encode-Decode types library |
2535
| `libsync/` | Concurrency mechanisms and primitives |
2636
| `libterm/` | ANSI color library for terminals |
2737
| `libtime/` | Time operations library |
38+
| `liburl/` | URL handling lirary |
2839
| `libuuid/` | UUID's handling code |
2940
| ------------------- | --------------------------------------------------------- |
3041
| `rt/` | The runtime system |

branches/try2/src/doc/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ and its implications on a task that programmers usually find very difficult: con
1818

1919
Ownership is central to Rust,
2020
and is the feature from which many of Rust's powerful capabilities are derived.
21-
"Ownership" refers to which parts of your code are allowed read,
21+
"Ownership" refers to which parts of your code are allowed to read,
2222
write, and ultimately release, memory.
2323
Let's start by looking at some C++ code:
2424

branches/try2/src/liballoc/rc.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use core::option::{Option, Some, None};
3333
use core::ptr;
3434
use core::ptr::RawPtr;
3535
use core::mem::{min_align_of, size_of};
36+
use core::fmt;
3637

3738
use heap::deallocate;
3839

@@ -178,6 +179,12 @@ impl<T: Ord> Ord for Rc<T> {
178179
fn cmp(&self, other: &Rc<T>) -> Ordering { (**self).cmp(&**other) }
179180
}
180181

182+
impl<T: fmt::Show> fmt::Show for Rc<T> {
183+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
184+
(**self).fmt(f)
185+
}
186+
}
187+
181188
/// Weak reference to a reference-counted box
182189
#[unsafe_no_drop_flag]
183190
pub struct Weak<T> {

branches/try2/src/libregex/lib.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,16 @@
155155
//! # Unicode
156156
//!
157157
//! This implementation executes regular expressions **only** on sequences of
158-
//! UTF8 codepoints while exposing match locations as byte indices.
158+
//! Unicode code points while exposing match locations as byte indices into the
159+
//! search string.
159160
//!
160161
//! Currently, only naive case folding is supported. Namely, when matching
161162
//! case insensitively, the characters are first converted to their uppercase
162163
//! forms and then compared.
163164
//!
164165
//! Regular expressions themselves are also **only** interpreted as a sequence
165-
//! of UTF8 codepoints. This means you can embed Unicode characters directly
166-
//! into your expression:
166+
//! of Unicode code points. This means you can use Unicode characters
167+
//! directly in your expression:
167168
//!
168169
//! ```rust
169170
//! # #![feature(phase)]
@@ -229,10 +230,10 @@
229230
//! x*? zero or more of x (ungreedy)
230231
//! x+? one or more of x (ungreedy)
231232
//! x?? zero or one of x (ungreedy)
232-
//! x{n,m} at least n and at most x (greedy)
233+
//! x{n,m} at least n x and at most m x (greedy)
233234
//! x{n,} at least n x (greedy)
234235
//! x{n} exactly n x
235-
//! x{n,m}? at least n and at most x (ungreedy)
236+
//! x{n,m}? at least n x and at most m x (ungreedy)
236237
//! x{n,}? at least n x (ungreedy)
237238
//! x{n}? exactly n x
238239
//! </pre>
@@ -300,7 +301,7 @@
300301
//! \v vertical tab (\x0B)
301302
//! \123 octal character code (up to three digits)
302303
//! \x7F hex character code (exactly two digits)
303-
//! \x{10FFFF} any hex character code corresponding to a valid UTF8 codepoint
304+
//! \x{10FFFF} any hex character code corresponding to a Unicode code point
304305
//! </pre>
305306
//!
306307
//! ## Perl character classes (Unicode friendly)
@@ -390,7 +391,7 @@ mod vm;
390391
#[cfg(test, not(windows))]
391392
mod test;
392393

393-
/// The `program` module exists to support the `regex!` macro. Do not use.
394+
/// The `native` module exists to support the `regex!` macro. Do not use.
394395
#[doc(hidden)]
395396
pub mod native {
396397
// Exporting this stuff is bad form, but it's necessary for two reasons.

branches/try2/src/libregex/parse/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ pub fn parse(s: &str) -> Result<Ast, Error> {
201201

202202
impl<'a> Parser<'a> {
203203
fn parse(&mut self) -> Result<Ast, Error> {
204+
if self.chars.len() == 0 {
205+
return Ok(Nothing);
206+
}
204207
loop {
205208
let c = self.cur();
206209
match c {

branches/try2/src/libregex/re.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ use parse;
1818
use vm;
1919
use vm::{CaptureLocs, MatchKind, Exists, Location, Submatches};
2020

21-
/// Escapes all regular expression meta characters in `text` so that it may be
22-
/// safely used in a regular expression as a literal string.
21+
/// Escapes all regular expression meta characters in `text`.
22+
///
23+
/// The string returned may be safely used as a literal in a regular
24+
/// expression.
2325
pub fn quote(text: &str) -> String {
2426
let mut quoted = String::with_capacity(text.len());
2527
for c in text.chars() {
@@ -45,17 +47,18 @@ pub fn is_match(regex: &str, text: &str) -> Result<bool, parse::Error> {
4547
Regex::new(regex).map(|r| r.is_match(text))
4648
}
4749

48-
/// Regex is a compiled regular expression, represented as either a sequence
49-
/// of bytecode instructions (dynamic) or as a specialized Rust function
50-
/// (native). It can be used to search, split
50+
/// A compiled regular expression
51+
///
52+
/// It is represented as either a sequence of bytecode instructions (dynamic)
53+
/// or as a specialized Rust function (native). It can be used to search, split
5154
/// or replace text. All searching is done with an implicit `.*?` at the
5255
/// beginning and end of an expression. To force an expression to match the
5356
/// whole string (or a prefix or a suffix), you must use an anchor like `^` or
5457
/// `$` (or `\A` and `\z`).
5558
///
5659
/// While this crate will handle Unicode strings (whether in the regular
5760
/// expression or in the search text), all positions returned are **byte
58-
/// indices**. Every byte index is guaranteed to be at a UTF8 codepoint
61+
/// indices**. Every byte index is guaranteed to be at a Unicode code point
5962
/// boundary.
6063
///
6164
/// The lifetimes `'r` and `'t` in this crate correspond to the lifetime of a
@@ -189,7 +192,7 @@ impl Regex {
189192
///
190193
/// # Example
191194
///
192-
/// Find the start and end location of every word with exactly 13
195+
/// Find the start and end location of the first word with exactly 13
193196
/// characters:
194197
///
195198
/// ```rust
@@ -216,7 +219,7 @@ impl Regex {
216219
///
217220
/// # Example
218221
///
219-
/// Find the start and end location of the first word with exactly 13
222+
/// Find the start and end location of every word with exactly 13
220223
/// characters:
221224
///
222225
/// ```rust
@@ -577,8 +580,8 @@ impl<'t> Replacer for &'t str {
577580
}
578581
}
579582

580-
impl<'a> Replacer for |&Captures|: 'a -> String {
581-
fn reg_replace<'r>(&'r mut self, caps: &Captures) -> MaybeOwned<'r> {
583+
impl<'t> Replacer for |&Captures|: 't -> String {
584+
fn reg_replace<'a>(&'a mut self, caps: &Captures) -> MaybeOwned<'a> {
582585
Owned((*self)(caps))
583586
}
584587
}
@@ -823,8 +826,9 @@ impl<'t> Iterator<Option<(uint, uint)>> for SubCapturesPos<'t> {
823826
}
824827

825828
/// An iterator that yields all non-overlapping capture groups matching a
826-
/// particular regular expression. The iterator stops when no more matches can
827-
/// be found.
829+
/// particular regular expression.
830+
///
831+
/// The iterator stops when no more matches can be found.
828832
///
829833
/// `'r` is the lifetime of the compiled expression and `'t` is the lifetime
830834
/// of the matched string.

branches/try2/src/libregex/test/tests.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ fn split() {
2828
assert_eq!(subs, vec!("cauchy", "plato", "tyler", "binx"));
2929
}
3030

31+
#[test]
32+
fn empty_regex_empty_match() {
33+
let re = regex!("");
34+
let ms = re.find_iter("").collect::<Vec<(uint, uint)>>();
35+
assert_eq!(ms, vec![(0, 0)]);
36+
}
37+
38+
#[test]
39+
fn empty_regex_nonempty_match() {
40+
let re = regex!("");
41+
let ms = re.find_iter("abc").collect::<Vec<(uint, uint)>>();
42+
assert_eq!(ms, vec![(0, 0), (1, 1), (2, 2), (3, 3)]);
43+
}
44+
3145
macro_rules! replace(
3246
($name:ident, $which:ident, $re:expr,
3347
$search:expr, $replace:expr, $result:expr) => (

branches/try2/src/libregex_macros/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
html_root_url = "http://doc.rust-lang.org/")]
2121

2222
#![feature(macro_registrar, managed_boxes, quote)]
23-
#![allow(unused_imports)] // `quote_expr!` adds some `use` globs which may be unused
2423

2524
extern crate regex;
2625
extern crate syntax;

branches/try2/src/librustc/back/archive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl<'a> Archive<'a> {
110110
lto: bool) -> io::IoResult<()> {
111111
let object = format!("{}.o", name);
112112
let bytecode = format!("{}.bc.deflate", name);
113-
let mut ignore = vec!(METADATA_FILENAME, bytecode.as_slice());
113+
let mut ignore = vec!(bytecode.as_slice(), METADATA_FILENAME);
114114
if lto {
115115
ignore.push(object.as_slice());
116116
}

branches/try2/src/librustc/middle/typeck/check/demand.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
use middle::ty;
1313
use middle::typeck::check::FnCtxt;
1414
use middle::typeck::infer;
15+
use middle::typeck::infer::resolve_type;
16+
use middle::typeck::infer::resolve::try_resolve_tvar_shallow;
1517

1618
use std::result::{Err, Ok};
1719
use std::result;
1820
use syntax::ast;
1921
use syntax::codemap::Span;
22+
use util::ppaux::Repr;
2023

2124
// Requires that the two types unify, and prints an error message if they
2225
// don't.
@@ -58,6 +61,13 @@ pub fn eqtype(fcx: &FnCtxt, sp: Span, expected: ty::t, actual: ty::t) {
5861
// Checks that the type `actual` can be coerced to `expected`.
5962
pub fn coerce(fcx: &FnCtxt, sp: Span, expected: ty::t, expr: &ast::Expr) {
6063
let expr_ty = fcx.expr_ty(expr);
64+
debug!("demand::coerce(expected = {}, expr_ty = {})",
65+
expected.repr(fcx.ccx.tcx),
66+
expr_ty.repr(fcx.ccx.tcx));
67+
let expected = if ty::type_needs_infer(expected) {
68+
resolve_type(fcx.infcx(), expected,
69+
try_resolve_tvar_shallow).unwrap_or(expected)
70+
} else { expected };
6171
match fcx.mk_assignty(expr, expr_ty, expected) {
6272
result::Ok(()) => { /* ok */ }
6373
result::Err(ref err) => {

branches/try2/src/librustc/middle/typeck/check/mod.rs

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,6 @@ pub struct Inherited<'a> {
168168
upvar_borrow_map: RefCell<ty::UpvarBorrowMap>,
169169
}
170170

171-
#[deriving(Clone)]
172-
pub enum FnKind {
173-
// A do-closure.
174-
DoBlock,
175-
176-
// A normal closure or fn item.
177-
Vanilla
178-
}
179-
180171
#[deriving(Clone)]
181172
pub struct FnStyleState {
182173
pub def: ast::NodeId,
@@ -249,11 +240,6 @@ pub struct FnCtxt<'a> {
249240
// can actually be made to live as long as it needs to live.
250241
region_lb: Cell<ast::NodeId>,
251242

252-
// Says whether we're inside a for loop, in a do block
253-
// or neither. Helps with error messages involving the
254-
// function return type.
255-
fn_kind: FnKind,
256-
257243
inh: &'a Inherited<'a>,
258244

259245
ccx: &'a CrateCtxt<'a>,
@@ -289,7 +275,6 @@ fn blank_fn_ctxt<'a>(ccx: &'a CrateCtxt<'a>,
289275
ret_ty: rty,
290276
ps: RefCell::new(FnStyleState::function(ast::NormalFn, 0)),
291277
region_lb: Cell::new(region_bnd),
292-
fn_kind: Vanilla,
293278
inh: inh,
294279
ccx: ccx
295280
}
@@ -356,7 +341,7 @@ fn check_bare_fn(ccx: &CrateCtxt,
356341
ty::ty_bare_fn(ref fn_ty) => {
357342
let inh = Inherited::new(ccx.tcx, param_env);
358343
let fcx = check_fn(ccx, fn_ty.fn_style, &fn_ty.sig,
359-
decl, id, body, Vanilla, &inh);
344+
decl, id, body, &inh);
360345

361346
vtable::resolve_in_block(&fcx, body);
362347
regionck::regionck_fn(&fcx, body);
@@ -440,7 +425,6 @@ fn check_fn<'a>(ccx: &'a CrateCtxt<'a>,
440425
decl: &ast::FnDecl,
441426
id: ast::NodeId,
442427
body: &ast::Block,
443-
fn_kind: FnKind,
444428
inherited: &'a Inherited<'a>) -> FnCtxt<'a>
445429
{
446430
/*!
@@ -479,7 +463,6 @@ fn check_fn<'a>(ccx: &'a CrateCtxt<'a>,
479463
ret_ty: ret_ty,
480464
ps: RefCell::new(FnStyleState::function(fn_style, id)),
481465
region_lb: Cell::new(body.id),
482-
fn_kind: fn_kind,
483466
inh: inherited,
484467
ccx: ccx
485468
};
@@ -2295,7 +2278,6 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
22952278
store: ty::TraitStore,
22962279
decl: &ast::FnDecl,
22972280
body: ast::P<ast::Block>,
2298-
fn_kind: FnKind,
22992281
expected: Option<ty::t>) {
23002282
let tcx = fcx.ccx.tcx;
23012283

@@ -2373,7 +2355,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
23732355
};
23742356

23752357
check_fn(fcx.ccx, inherited_style, &fty_sig,
2376-
decl, id, body, fn_kind, fcx.inh);
2358+
decl, id, body, fcx.inh);
23772359
}
23782360

23792361

@@ -3044,7 +3026,6 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
30443026
ty::RegionTraitStore(region, ast::MutMutable),
30453027
decl,
30463028
body,
3047-
Vanilla,
30483029
expected);
30493030
}
30503031
ast::ExprProc(decl, body) => {
@@ -3053,7 +3034,6 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
30533034
ty::UniqTraitStore,
30543035
decl,
30553036
body,
3056-
Vanilla,
30573037
expected);
30583038
}
30593039
ast::ExprBlock(b) => {

0 commit comments

Comments
 (0)