diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-10-29 01:21:43 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-10-29 01:40:20 -0700 |
| commit | e0f44730e8dc75c17dc86fcb48769d62a4dbcaae (patch) | |
| tree | f11e4626c0fad600fe133c0a2551c1d23ff17d8e /src/comp/syntax/parse/parser.rs | |
| parent | 2cebef095e61608a3d35710cb5fd3d7de18b68ac (diff) | |
| download | rust-e0f44730e8dc75c17dc86fcb48769d62a4dbcaae.tar.gz rust-e0f44730e8dc75c17dc86fcb48769d62a4dbcaae.zip | |
rustc: Support 'companion mod's for crates and directory mods
Under this scheme when parsing foo.rc the parser will also look for foo.rs to fill in the crate-level module, and when evaluating a directory module directive it will look for a .rs file with the same name as the directory.
Diffstat (limited to 'src/comp/syntax/parse/parser.rs')
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index f605a2fb699..98dcb141192 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -1,5 +1,5 @@ -import std::{io, vec, str, option, either, result}; +import std::{io, vec, str, option, either, result, fs}; import std::option::{some, none}; import std::either::{left, right}; import std::map::{hashmap, new_str_hash}; @@ -2599,13 +2599,15 @@ fn parse_crate_from_crate_file(input: str, cfg: ast::crate_cfg, mutable chpos: p.get_chpos(), mutable byte_pos: p.get_byte_pos(), cfg: p.get_cfg()}; - let m = eval::eval_crate_directives_to_mod(cx, cdirs, prefix); + let (companionmod, _) = fs::splitext(fs::basename(input)); + let (m, attrs) = eval::eval_crate_directives_to_mod( + cx, cdirs, prefix, option::some(companionmod)); let hi = p.get_hi_pos(); expect(p, token::EOF); ret @spanned(lo, hi, {directives: cdirs, module: m, - attrs: crate_attrs, + attrs: crate_attrs + attrs, config: p.get_cfg()}); } |
