Skip to content

Commit 74d2b3e

Browse files
lhtbrson
authored andcommitted
---
yaml --- r: 6457 b: refs/heads/master c: 3e303af h: refs/heads/master i: 6455: 727ac15 v: v3
1 parent 75a523e commit 74d2b3e

File tree

13 files changed

+58
-45
lines changed

13 files changed

+58
-45
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 547ec241bd50e86752e4c39047b417550f655349
2+
refs/heads/master: 3e303af86b5380c7d53a8879d883cd36ad2a69a6

trunk/doc/rust.texi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,9 +1030,11 @@ An example of a crate:
10301030
use std (ver = "1.0");
10311031
10321032
// Define some modules.
1033-
mod foo = "foo.rs";
1033+
#[path = "foo.rs"]
1034+
mod foo;
10341035
mod bar @{
1035-
mod quux = "quux.rs";
1036+
#[path = "quux.rs"]
1037+
mod quux;
10361038
@}
10371039
@end example
10381040

trunk/src/comp/rustc.rc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ mod middle {
4040
mod tstate {
4141
mod ck;
4242
mod annotate;
43-
mod aux = "auxiliary.rs";
43+
#[path = "auxiliary.rs"]
44+
mod aux;
4445
mod bitvectors;
4546
mod collect_locals;
4647
mod pre_post_conditions;

trunk/src/comp/syntax/ast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ type crate_ =
5858
config: crate_cfg};
5959

6060
tag crate_directive_ {
61-
cdir_src_mod(ident, option::t<filename>, [attribute]);
62-
cdir_dir_mod(ident, option::t<filename>, [@crate_directive], [attribute]);
61+
cdir_src_mod(ident, [attribute]);
62+
cdir_dir_mod(ident, [@crate_directive], [attribute]);
6363
cdir_view_item(@view_item);
6464
cdir_syntax(path);
6565
}

trunk/src/comp/syntax/fold.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ fn noop_fold_crate(c: crate_, fld: ast_fold) -> crate_ {
159159
fn noop_fold_crate_directive(cd: crate_directive_, fld: ast_fold) ->
160160
crate_directive_ {
161161
ret alt cd {
162-
cdir_src_mod(id, fname, attrs) {
163-
cdir_src_mod(fld.fold_ident(id), fname, attrs)
162+
cdir_src_mod(id, attrs) {
163+
cdir_src_mod(fld.fold_ident(id), attrs)
164164
}
165-
cdir_dir_mod(id, fname, cds, attrs) {
166-
cdir_dir_mod(fld.fold_ident(id), fname,
165+
cdir_dir_mod(id, cds, attrs) {
166+
cdir_dir_mod(fld.fold_ident(id),
167167
vec::map(fld.fold_crate_directive, cds), attrs)
168168
}
169169
cdir_view_item(vi) { cdir_view_item(fld.fold_view_item(vi)) }

trunk/src/comp/syntax/parse/eval.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
import front::attr;
23
import std::{option, result, io, fs};
34
import std::option::{some, none};
45
import syntax::ast;
@@ -86,13 +87,21 @@ fn parse_companion_mod(cx: ctx, prefix: str, suffix: option::t<str>)
8687
}
8788
}
8889

90+
fn cdir_path_opt(id: str, attrs: [ast::attribute]) -> str {
91+
alt attr::get_meta_item_value_str_by_name(attrs, "path") {
92+
some(d) {
93+
ret d;
94+
}
95+
none. { ret id; }
96+
}
97+
}
98+
8999
fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: str,
90100
&view_items: [@ast::view_item],
91101
&items: [@ast::item]) {
92102
alt cdir.node {
93-
ast::cdir_src_mod(id, file_opt, attrs) {
94-
let file_path = id + ".rs";
95-
alt file_opt { some(f) { file_path = f; } none. { } }
103+
ast::cdir_src_mod(id, attrs) {
104+
let file_path = cdir_path_opt(id + ".rs", attrs);
96105
let full_path =
97106
if std::fs::path_is_absolute(file_path) {
98107
file_path
@@ -113,9 +122,8 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: str,
113122
cx.byte_pos = p0.get_byte_pos();
114123
items += [i];
115124
}
116-
ast::cdir_dir_mod(id, dir_opt, cdirs, attrs) {
117-
let path = id;
118-
alt dir_opt { some(d) { path = d; } none. { } }
125+
ast::cdir_dir_mod(id, cdirs, attrs) {
126+
let path = cdir_path_opt(id, attrs);
119127
let full_path =
120128
if std::fs::path_is_absolute(path) {
121129
path

trunk/src/comp/syntax/parse/parser.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2475,19 +2475,12 @@ fn parse_crate_directive(p: parser, first_outer_attr: [ast::attribute]) ->
24752475
if expect_mod || is_word(p, "mod") {
24762476
expect_word(p, "mod");
24772477
let id = parse_ident(p);
2478-
let file_opt =
2479-
alt p.peek() {
2480-
token::EQ. { p.bump(); some(parse_str(p)) }
2481-
_ {
2482-
attr::get_meta_item_value_str_by_name(outer_attrs, "path")
2483-
}
2484-
};
24852478
alt p.peek() {
24862479
// mod x = "foo.rs";
24872480
token::SEMI. {
24882481
let hi = p.get_hi_pos();
24892482
p.bump();
2490-
ret spanned(lo, hi, ast::cdir_src_mod(id, file_opt, outer_attrs));
2483+
ret spanned(lo, hi, ast::cdir_src_mod(id, outer_attrs));
24912484
}
24922485
// mod x = "foo_dir" { ...directives... }
24932486
token::LBRACE. {
@@ -2500,7 +2493,7 @@ fn parse_crate_directive(p: parser, first_outer_attr: [ast::attribute]) ->
25002493
let hi = p.get_hi_pos();
25012494
expect(p, token::RBRACE);
25022495
ret spanned(lo, hi,
2503-
ast::cdir_dir_mod(id, file_opt, cdirs, mod_attrs));
2496+
ast::cdir_dir_mod(id, cdirs, mod_attrs));
25042497
}
25052498
t { unexpected(p, t); }
25062499
}

trunk/src/comp/syntax/visit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ fn visit_crate<E>(c: crate, e: E, v: vt<E>) {
5656

5757
fn visit_crate_directive<E>(cd: @crate_directive, e: E, v: vt<E>) {
5858
alt cd.node {
59-
cdir_src_mod(_, _, _) { }
60-
cdir_dir_mod(_, _, cdirs, _) {
59+
cdir_src_mod(_, _) { }
60+
cdir_dir_mod(_, cdirs, _) {
6161
for cdir: @crate_directive in cdirs {
6262
visit_crate_directive(cdir, e, v);
6363
}

trunk/src/lib/std.rc

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ mod comm;
4040
mod fs;
4141
mod io;
4242
mod net;
43-
mod run = "run_program.rs";
43+
#[path = "run_program.rs"]
44+
mod run;
4445
mod sys;
4546
mod task;
4647

@@ -100,19 +101,25 @@ mod test;
100101
mod generic_os;
101102

102103
#[cfg(target_os = "win32")]
103-
mod os = "win32_os.rs";
104+
#[path = "win32_os.rs"]
105+
mod os;
104106
#[cfg(target_os = "win32")]
105-
mod os_fs = "win32_fs.rs";
107+
#[path = "win32_fs.rs"]
108+
mod os_fs;
106109

107110
#[cfg(target_os = "macos")]
108-
mod os = "macos_os.rs";
111+
#[path = "macos_os.rs"]
112+
mod os;
109113
#[cfg(target_os = "macos")]
110-
mod os_fs = "posix_fs.rs";
114+
#[path = "posix_fs.rs"]
115+
mod os_fs;
111116

112117
#[cfg(target_os = "linux")]
113-
mod os = "linux_os.rs";
118+
#[path = "linux_os.rs"]
119+
mod os;
114120
#[cfg(target_os = "linux")]
115-
mod os_fs = "posix_fs.rs";
121+
#[path = "posix_fs.rs"]
122+
mod os_fs;
116123

117124
// Local Variables:
118125
// mode: rust;

trunk/src/test/compile-fail/mod-name-non-str.rc

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// Test that crates and directory modules can contain code
22

3-
mod a = "companionmod-src" {
3+
#[path = "companionmod-src"]
4+
mod a {
45
mod b {
56
mod x;
67
}
7-
mod c = "d" {
8+
#[path = "d"]
9+
mod c {
810
mod x;
911
}
10-
}
12+
}

trunk/src/test/run-pass/crate-attributes.rc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
#[vers = "1.0"];
33

44
#[attr1]
5-
mod m = "crate-attributes-src" {
5+
#[path = "crate-attributes-src"]
6+
mod m {
67
#[attr_inner];
78

89
#[attr2]

trunk/src/test/run-pass/multi.rc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
mod multi = "multi-src" {
1+
#[path = "multi-src"]
2+
mod multi {
3+
// implicitly #[path = "foo.rs"]
4+
mod foo;
25

3-
mod foo; // implicitly = "foo.rs"
4-
5-
mod bar = "bar.rs";
6+
#[path = "bar.rs"]
7+
mod bar;
68
}

0 commit comments

Comments
 (0)