Skip to content

Commit ef020a8

Browse files
committed
---
yaml --- r: 152030 b: refs/heads/try2 c: 69070ac h: refs/heads/master v: v3
1 parent a4cc35e commit ef020a8

File tree

24 files changed

+242
-883
lines changed

24 files changed

+242
-883
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: db2ddb1bba9a78b0791266805bdeca9f3fce89fc
8+
refs/heads/try2: 69070ac85fcf930b02e2c75bc161a75c5742e138
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/guide-runtime.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The runtime is designed with a few goals in mind:
4545
support as well.
4646

4747
* The runtime should not enforce separate "modes of compilation" in order to
48-
work in multiple circumstances. It is an explicit goal that you compile a Rust
48+
work in multiple circumstances. Is it an explicit goal that you compile a Rust
4949
library once and use it forever (in all environments).
5050

5151
* The runtime should be fast. There should be no architectural design barrier

branches/try2/src/doc/rustdoc.md

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,6 @@ pub fn recalibrate() {
4141
# }
4242
~~~
4343

44-
Documentation can also be controlled via the `doc` attribute on items. This is
45-
implicitly done by the compiler when using the above form of doc comments
46-
(converting the slash-based comments to `#[doc]` attributes).
47-
48-
~~~
49-
#[doc = "
50-
Calculates the factorial of a number.
51-
52-
Given the input integer `n`, this function will calculate `n!` and return it.
53-
"]
54-
pub fn factorial(n: int) -> int { if n < 2 {1} else {n * factorial(n)} }
55-
# fn main() {}
56-
~~~
57-
58-
The `doc` attribute can also be used to control how rustdoc emits documentation
59-
in some cases.
60-
61-
```
62-
// Rustdoc will inline documentation of a `pub use` into this crate when the
63-
// `pub use` reaches across crates, but this behavior can also be disabled.
64-
#[doc(no_inline)]
65-
pub use std::option::Option;
66-
# fn main() {}
67-
```
68-
6944
Doc comments are markdown, and are currently parsed with the
7045
[sundown][sundown] library. rustdoc does not yet do any fanciness such as
7146
referencing other items inline, like javadoc's `@see`. One exception to this

branches/try2/src/libregex/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ pub mod native {
401401
// undesirable consequences (such as requiring a dependency on
402402
// `libsyntax`).
403403
//
404-
// Secondly, the code generated by `regex!` must *also* be able
404+
// Secondly, the code generated generated by `regex!` must *also* be able
405405
// to access various functions in this crate to reduce code duplication
406406
// and to provide a value with precisely the same `Regex` type in this
407407
// crate. This, AFAIK, is impossible to mitigate.

branches/try2/src/libregex/re.rs

Lines changed: 34 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -100,45 +100,38 @@ pub fn is_match(regex: &str, text: &str) -> Result<bool, parse::Error> {
100100
/// documentation.
101101
#[deriving(Clone)]
102102
#[allow(visible_private_types)]
103-
pub enum Regex {
104-
// The representation of `Regex` is exported to support the `regex!`
105-
// syntax extension. Do not rely on it.
106-
//
107-
// See the comments for the `program` module in `lib.rs` for a more
108-
// detailed explanation for what `regex!` requires.
103+
pub struct Regex {
104+
/// The representation of `Regex` is exported to support the `regex!`
105+
/// syntax extension. Do not rely on it.
106+
///
107+
/// See the comments for the `program` module in `lib.rs` for a more
108+
/// detailed explanation for what `regex!` requires.
109109
#[doc(hidden)]
110-
Dynamic(Dynamic),
110+
pub original: String,
111111
#[doc(hidden)]
112-
Native(Native),
113-
}
114-
115-
#[deriving(Clone)]
116-
#[doc(hidden)]
117-
pub struct Dynamic {
118-
original: String,
119-
names: Vec<Option<String>>,
112+
pub names: Vec<Option<String>>,
120113
#[doc(hidden)]
121-
pub prog: Program
114+
pub p: MaybeNative,
122115
}
123116

124-
#[doc(hidden)]
125-
pub struct Native {
126-
#[doc(hidden)]
127-
pub original: &'static str,
128-
#[doc(hidden)]
129-
pub names: &'static [Option<&'static str>],
130-
#[doc(hidden)]
131-
pub prog: fn(MatchKind, &str, uint, uint) -> Vec<Option<uint>>
117+
impl fmt::Show for Regex {
118+
/// Shows the original regular expression.
119+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
120+
write!(f, "{}", self.original)
121+
}
132122
}
133123

134-
impl Clone for Native {
135-
fn clone(&self) -> Native { *self }
124+
pub enum MaybeNative {
125+
Dynamic(Program),
126+
Native(fn(MatchKind, &str, uint, uint) -> Vec<Option<uint>>),
136127
}
137128

138-
impl fmt::Show for Regex {
139-
/// Shows the original regular expression.
140-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
141-
write!(f, "{}", self.as_str())
129+
impl Clone for MaybeNative {
130+
fn clone(&self) -> MaybeNative {
131+
match *self {
132+
Dynamic(ref p) => Dynamic(p.clone()),
133+
Native(fp) => Native(fp),
134+
}
142135
}
143136
}
144137

@@ -153,11 +146,10 @@ impl Regex {
153146
pub fn new(re: &str) -> Result<Regex, parse::Error> {
154147
let ast = try!(parse::parse(re));
155148
let (prog, names) = Program::new(ast);
156-
Ok(Dynamic(Dynamic {
149+
Ok(Regex {
157150
original: re.to_strbuf(),
158-
names: names,
159-
prog: prog,
160-
}))
151+
names: names, p: Dynamic(prog),
152+
})
161153
}
162154

163155
/// Returns true if and only if the regex matches the string given.
@@ -503,46 +495,6 @@ impl Regex {
503495
}
504496
new.append(text.slice(last_match, text.len()))
505497
}
506-
507-
/// Returns the original string of this regex.
508-
pub fn as_str<'a>(&'a self) -> &'a str {
509-
match *self {
510-
Dynamic(Dynamic { ref original, .. }) => original.as_slice(),
511-
Native(Native { ref original, .. }) => original.as_slice(),
512-
}
513-
}
514-
515-
#[doc(hidden)]
516-
#[allow(visible_private_types)]
517-
#[experimental]
518-
pub fn names_iter<'a>(&'a self) -> NamesIter<'a> {
519-
match *self {
520-
Native(ref n) => NamesIterNative(n.names.iter()),
521-
Dynamic(ref d) => NamesIterDynamic(d.names.iter())
522-
}
523-
}
524-
525-
fn names_len(&self) -> uint {
526-
match *self {
527-
Native(ref n) => n.names.len(),
528-
Dynamic(ref d) => d.names.len()
529-
}
530-
}
531-
532-
}
533-
534-
enum NamesIter<'a> {
535-
NamesIterNative(::std::slice::Items<'a, Option<&'static str>>),
536-
NamesIterDynamic(::std::slice::Items<'a, Option<String>>)
537-
}
538-
539-
impl<'a> Iterator<Option<String>> for NamesIter<'a> {
540-
fn next(&mut self) -> Option<Option<String>> {
541-
match *self {
542-
NamesIterNative(ref mut i) => i.next().map(|x| x.map(|s| s.to_strbuf())),
543-
NamesIterDynamic(ref mut i) => i.next().map(|x| x.as_ref().map(|s| s.to_strbuf())),
544-
}
545-
}
546498
}
547499

548500
/// NoExpand indicates literal string replacement.
@@ -660,23 +612,22 @@ pub struct Captures<'t> {
660612
}
661613

662614
impl<'t> Captures<'t> {
663-
#[allow(experimental)]
664615
fn new(re: &Regex, search: &'t str, locs: CaptureLocs)
665616
-> Option<Captures<'t>> {
666617
if !has_match(&locs) {
667618
return None
668619
}
669620

670621
let named =
671-
if re.names_len() == 0 {
622+
if re.names.len() == 0 {
672623
None
673624
} else {
674625
let mut named = HashMap::new();
675-
for (i, name) in re.names_iter().enumerate() {
626+
for (i, name) in re.names.iter().enumerate() {
676627
match name {
677-
None => {},
678-
Some(name) => {
679-
named.insert(name, i);
628+
&None => {},
629+
&Some(ref name) => {
630+
named.insert(name.to_strbuf(), i);
680631
}
681632
}
682633
}
@@ -911,9 +862,9 @@ fn exec(re: &Regex, which: MatchKind, input: &str) -> CaptureLocs {
911862

912863
fn exec_slice(re: &Regex, which: MatchKind,
913864
input: &str, s: uint, e: uint) -> CaptureLocs {
914-
match *re {
915-
Dynamic(Dynamic { ref prog, .. }) => vm::run(which, prog, input, s, e),
916-
Native(Native { prog, .. }) => prog(which, input, s, e),
865+
match re.p {
866+
Dynamic(ref prog) => vm::run(which, prog, input, s, e),
867+
Native(exec) => exec(which, input, s, e),
917868
}
918869
}
919870

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ mod native_bench;
2020
#[path = "tests.rs"]
2121
mod native_tests;
2222

23-
#[cfg(not(stage1))]
24-
mod native_static;
25-
2623
// Due to macro scoping rules, this definition only applies for the modules
2724
// defined below. Effectively, it allows us to use the same tests for both
2825
// native and dynamic regexes.

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

Lines changed: 0 additions & 26 deletions
This file was deleted.

branches/try2/src/libregex_macros/lib.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ pub fn macro_registrar(register: |ast::Name, SyntaxExtension|) {
7575
/// It is strongly recommended to read the dynamic implementation in vm.rs
7676
/// first before trying to understand the code generator. The implementation
7777
/// strategy is identical and vm.rs has comments and will be easier to follow.
78-
#[allow(experimental)]
7978
fn native(cx: &mut ExtCtxt, sp: codemap::Span, tts: &[ast::TokenTree])
8079
-> Box<MacResult> {
8180
let regex = match parse(cx, tts) {
@@ -90,14 +89,14 @@ fn native(cx: &mut ExtCtxt, sp: codemap::Span, tts: &[ast::TokenTree])
9089
return DummyResult::any(sp)
9190
}
9291
};
93-
let prog = match re {
94-
Dynamic(Dynamic { ref prog, .. }) => prog.clone(),
92+
let prog = match re.p {
93+
Dynamic(ref prog) => prog.clone(),
9594
Native(_) => unreachable!(),
9695
};
9796

9897
let mut gen = NfaGen {
9998
cx: &*cx, sp: sp, prog: prog,
100-
names: re.names_iter().collect(), original: re.as_str().to_strbuf(),
99+
names: re.names.clone(), original: re.original.clone(),
101100
};
102101
MacExpr::new(gen.code())
103102
}
@@ -120,7 +119,7 @@ impl<'a> NfaGen<'a> {
120119
|cx, name| match *name {
121120
Some(ref name) => {
122121
let name = name.as_slice();
123-
quote_expr!(cx, Some($name))
122+
quote_expr!(cx, Some($name.to_strbuf()))
124123
}
125124
None => cx.expr_none(self.sp),
126125
}
@@ -142,11 +141,9 @@ impl<'a> NfaGen<'a> {
142141
let regex = self.original.as_slice();
143142

144143
quote_expr!(self.cx, {
145-
static CAP_NAMES: &'static [Option<&'static str>] = &$cap_names;
146144
fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
147145
start: uint, end: uint) -> Vec<Option<uint>> {
148146
#![allow(unused_imports)]
149-
#![allow(unused_mut)]
150147
use regex::native::{
151148
MatchKind, Exists, Location, Submatches,
152149
StepState, StepMatchEarlyReturn, StepMatch, StepContinue,
@@ -313,11 +310,11 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
313310
}
314311
}
315312

316-
::regex::native::Native(::regex::native::Native {
317-
original: $regex,
318-
names: CAP_NAMES,
319-
prog: exec,
320-
})
313+
::regex::Regex {
314+
original: $regex.to_strbuf(),
315+
names: vec!$cap_names,
316+
p: ::regex::native::Native(exec),
317+
}
321318
})
322319
}
323320

branches/try2/src/librustc/metadata/common.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,6 @@ pub static tag_crate_triple: uint = 0x66;
206206

207207
pub static tag_dylib_dependency_formats: uint = 0x67;
208208

209-
pub static tag_method_argument_names: uint = 0x8e;
210-
pub static tag_method_argument_name: uint = 0x8f;
211-
212209
#[deriving(Clone, Show)]
213210
pub struct LinkMeta {
214211
pub crateid: CrateId,

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,3 @@ pub fn get_missing_lang_items(cstore: &cstore::CStore, cnum: ast::CrateNum)
306306
let cdata = cstore.get_crate_data(cnum);
307307
decoder::get_missing_lang_items(&*cdata)
308308
}
309-
310-
pub fn get_method_arg_names(cstore: &cstore::CStore, did: ast::DefId)
311-
-> Vec<String>
312-
{
313-
let cdata = cstore.get_crate_data(did.krate);
314-
decoder::get_method_arg_names(&*cdata, did.node)
315-
}

branches/try2/src/librustc/metadata/decoder.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,18 +1309,3 @@ pub fn get_missing_lang_items(cdata: Cmd)
13091309
});
13101310
return result;
13111311
}
1312-
1313-
pub fn get_method_arg_names(cdata: Cmd, id: ast::NodeId) -> Vec<String> {
1314-
let mut ret = Vec::new();
1315-
let method_doc = lookup_item(id, cdata.data());
1316-
match reader::maybe_get_doc(method_doc, tag_method_argument_names) {
1317-
Some(args_doc) => {
1318-
reader::tagged_docs(args_doc, tag_method_argument_name, |name_doc| {
1319-
ret.push(name_doc.as_str_slice().to_strbuf());
1320-
true
1321-
});
1322-
}
1323-
None => {}
1324-
}
1325-
return ret;
1326-
}

0 commit comments

Comments
 (0)