Skip to content

Commit b090d82

Browse files
committed
---
yaml --- r: 11740 b: refs/heads/master c: c19ea05 h: refs/heads/master v: v3
1 parent 5652cb8 commit b090d82

19 files changed

+1389
-602
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: e8c7b5347d3b834a2c467677cfa8670316b2c574
2+
refs/heads/master: c19ea057faed3e4b1abe03c1d760b7741b135e1b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/README.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ This is preliminary version of the Rust compiler.
22

33
Source layout:
44

5-
comp/ The self-hosted compiler
5+
rustc/ The self-hosted compiler
66

77
cargo/ The package manager
88

trunk/src/rustc/driver/driver.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,6 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
163163
let mutbl_map =
164164
time(time_passes, "mutability checking",
165165
bind middle::mutbl::check_crate(ty_cx, crate));
166-
time(time_passes, "region checking",
167-
bind middle::regionck::check_crate(ty_cx, crate));
168166
let (copy_map, ref_map) =
169167
time(time_passes, "alias checking",
170168
bind middle::alias::check_crate(ty_cx, crate));

trunk/src/rustc/middle/regionck.rs

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

trunk/src/rustc/rustc.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ mod middle {
4545
mod capture;
4646
mod pat_util;
4747
mod region;
48-
mod regionck;
4948

5049
mod tstate {
5150
mod ck;

trunk/src/rustdoc/attr_parser.rs

Lines changed: 110 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ import rustc::syntax::ast;
99
import rustc::front::attr;
1010
import core::tuple;
1111

12-
export crate_attrs, basic_attrs, variant_attrs;
13-
export parse_crate, parse_basic, parse_variant;
12+
export crate_attrs, basic_attrs, fn_attrs, arg_attrs,
13+
variant_attrs, res_attrs, method_attrs;
14+
export parse_crate, parse_basic, parse_fn,
15+
parse_variant, parse_res, parse_method;
1416
export parse_hidden;
1517

1618
type crate_attrs = {
@@ -22,10 +24,27 @@ type basic_attrs = {
2224
desc: option<str>
2325
};
2426

27+
type fn_attrs = {
28+
args: [arg_attrs],
29+
return: option<str>,
30+
failure: option<str>
31+
};
32+
33+
type arg_attrs = {
34+
name: str,
35+
desc: str
36+
};
37+
2538
type variant_attrs = {
2639
desc: option<str>
2740
};
2841

42+
type res_attrs = {
43+
args: [arg_attrs]
44+
};
45+
46+
type method_attrs = fn_attrs;
47+
2948
#[cfg(test)]
3049
mod test {
3150

@@ -212,6 +231,72 @@ fn parse_long_doc<T>(
212231
}
213232
}
214233

234+
fn parse_fn(attrs: [ast::attribute]) -> fn_attrs {
235+
parse_long_doc(attrs, parse_fn_long_doc)
236+
}
237+
238+
fn parse_fn_long_doc(items: [@ast::meta_item]) -> fn_attrs {
239+
let return = attr::meta_item_value_from_list(items, "return");
240+
let failure = attr::meta_item_value_from_list(items, "failure");
241+
let args = parse_args(items);
242+
243+
{
244+
args: args,
245+
return: return,
246+
failure: failure
247+
}
248+
}
249+
250+
fn parse_args(items: [@ast::meta_item]) -> [arg_attrs] {
251+
alt attr::meta_item_list_from_list(items, "args") {
252+
some(items) {
253+
vec::filter_map(items) {|item|
254+
option::map(attr::name_value_str_pair(item)) { |pair|
255+
{
256+
name: tuple::first(pair),
257+
desc: tuple::second(pair)
258+
}
259+
}
260+
}
261+
}
262+
none { [] }
263+
}
264+
}
265+
266+
#[test]
267+
fn parse_fn_should_handle_undocumented_functions() {
268+
let source = "";
269+
let attrs = test::parse_attributes(source);
270+
let attrs = parse_fn(attrs);
271+
assert attrs.return == none;
272+
assert vec::len(attrs.args) == 0u;
273+
}
274+
275+
#[test]
276+
fn parse_fn_should_parse_the_return_value_description() {
277+
let source = "#[doc(return = \"return value\")]";
278+
let attrs = test::parse_attributes(source);
279+
let attrs = parse_fn(attrs);
280+
assert attrs.return == some("return value");
281+
}
282+
283+
#[test]
284+
fn parse_fn_should_parse_the_argument_descriptions() {
285+
let source = "#[doc(args(a = \"arg a\", b = \"arg b\"))]";
286+
let attrs = test::parse_attributes(source);
287+
let attrs = parse_fn(attrs);
288+
assert attrs.args[0] == {name: "a", desc: "arg a"};
289+
assert attrs.args[1] == {name: "b", desc: "arg b"};
290+
}
291+
292+
#[test]
293+
fn parse_fn_should_parse_failure_conditions() {
294+
let source = "#[doc(failure = \"it's the fail\")]";
295+
let attrs = test::parse_attributes(source);
296+
let attrs = parse_fn(attrs);
297+
assert attrs.failure == some("it's the fail");
298+
}
299+
215300
fn parse_variant(attrs: [ast::attribute]) -> variant_attrs {
216301
parse_short_doc_or(
217302
attrs,
@@ -257,6 +342,29 @@ fn should_parse_variant_long_doc() {
257342
assert attrs.desc == some("a");
258343
}
259344

345+
fn parse_res(attrs: [ast::attribute]) -> res_attrs {
346+
parse_long_doc(attrs, parse_res_long_doc)
347+
}
348+
349+
fn parse_res_long_doc(items: [@ast::meta_item]) -> res_attrs {
350+
{
351+
args: parse_args(items)
352+
}
353+
}
354+
355+
#[test]
356+
fn shoulde_parse_resource_arg() {
357+
let source = "#[doc(args(a = \"b\"))]";
358+
let attrs = test::parse_attributes(source);
359+
let attrs = parse_res(attrs);
360+
assert attrs.args[0].name == "a";
361+
assert attrs.args[0].desc == "b";
362+
}
363+
364+
fn parse_method(attrs: [ast::attribute]) -> method_attrs {
365+
parse_fn(attrs)
366+
}
367+
260368
fn parse_hidden(attrs: [ast::attribute]) -> bool {
261369
parse_short_doc_or(
262370
attrs,

0 commit comments

Comments
 (0)