Skip to content

macros: stackless expansion #36214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Sep 8, 2016
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e1e5c14
In `Parser` and `ExtCtxt`, replace fields `filename` and `mod_path_st…
jseyfried Aug 31, 2016
234d68b
Improve `expand_type`.
jseyfried Aug 30, 2016
9b3bc7a
Remove `syntax::config::strip_unconfigured`, add `syntax::config::fea…
jseyfried Aug 31, 2016
de2e678
Add `Invocation` and `Expansion`, remove `MacroGenerable`.
jseyfried Aug 27, 2016
3cba93f
Refactor `with_exts_frame` from a macro to a function.
jseyfried Aug 27, 2016
fca80c9
Generalize `Invocation` to include modifiers/decorators.
jseyfried Sep 2, 2016
8be8cf8
Refactor away `expand_item`.
jseyfried Aug 28, 2016
2a83574
Refactor out `expand_item` (with better semantics than before).
jseyfried Aug 28, 2016
503a10b
Clean up module processing.
jseyfried Aug 28, 2016
4ed2c0e
Refactor `expand_*` into `expander.fold_*`.
jseyfried Aug 30, 2016
79fa9eb
Refactor `SyntaxEnv`.
jseyfried Sep 1, 2016
7a3ae57
Refactor `expand_invoc(.., fld)` -> `self.expand_invoc(..)`.
jseyfried Sep 1, 2016
c07ff8d
Add module `ext::placeholders` with `placeholder()` and `Placeholder…
jseyfried Aug 29, 2016
d986bbe
Implement stackless expansion.
jseyfried Sep 2, 2016
2c88b4b
Load macros from `extern crate`s in the `InvocationCollector` fold.
jseyfried Sep 2, 2016
3af0c65
Refactor code out of the folder implementation for `StripUnconfigured`.
jseyfried Sep 2, 2016
d76bf3e
Strip unconfigured nodes in the `InvocationCollector` fold.
jseyfried Sep 7, 2016
2d75904
Implement stackless placeholder expansion.
jseyfried Sep 2, 2016
9ac91fa
Improve `directory` computation during invocation collection.
jseyfried Sep 5, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Improve directory computation during invocation collection.
  • Loading branch information
jseyfried committed Sep 7, 2016
commit 9ac91fa48b3eb479cccb5695395faed8f59ece8e
14 changes: 9 additions & 5 deletions src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,16 +615,20 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
ast::ItemKind::Mod(ast::Mod { inner, .. }) => {
let mut paths = (*self.cx.syntax_env.paths()).clone();
paths.mod_path.push(item.ident);
if item.span.contains(inner) {

// Detect if this is an inline module (`mod m { ... }` as opposed to `mod m;`).
// In the non-inline case, `inner` is never the dummy span (c.f. `parse_item_mod`).
// Thus, if `inner` is the dummy span, we know the module is inline.
let inline_module = item.span.contains(inner) || inner == syntax_pos::DUMMY_SP;

if inline_module {
paths.directory.push(&*{
::attr::first_attr_value_str_by_name(&item.attrs, "path")
.unwrap_or(item.ident.name.as_str())
});
} else {
paths.directory = match inner {
syntax_pos::DUMMY_SP => PathBuf::new(),
_ => PathBuf::from(self.cx.parse_sess.codemap().span_to_filename(inner)),
};
paths.directory =
PathBuf::from(self.cx.parse_sess.codemap().span_to_filename(inner));
paths.directory.pop();
}

Expand Down