Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upOnly the first macro expansion of an `include!`d file is expanded. #35560
Comments
This comment has been minimized.
This comment has been minimized.
|
This is unrelated to the macros used in the included file, the following exhibits the same problem:
fn print(s: &str) { println!("{}", s); }
fn main() {
include!("helper.rs");
}
print("foo");
print("bar");
print("foobar");It looks like the issue is rather that Wrapping the contents of Also note that the documentation of
Thus the current behaviour is probably as documented. |
This comment has been minimized.
This comment has been minimized.
|
But the contents of |
This comment has been minimized.
This comment has been minimized.
|
Oh I see. If file contents are thrown away though, I think at least a warning would come handy, but yeah, I see now, thanks! |
emilio
added a commit
to emilio/servo
that referenced
this issue
Aug 10, 2016
emilio
added a commit
to emilio/servo
that referenced
this issue
Aug 11, 2016
emilio
referenced this issue
Nov 15, 2016
Merged
Generate a separate test function for every header #261
This comment has been minimized.
This comment has been minimized.
|
Someone reported a similar experience on users, trying to use While it doesn't surprise me that the result is limited to a single expression or statement, it seems like there ought to be an error message? |
Mark-Simulacrum
added
A-macros
A-syntaxext
labels
May 19, 2017
Mark-Simulacrum
added
the
C-bug
label
Jul 25, 2017
This comment has been minimized.
This comment has been minimized.
|
Still happens, just ran into this today. Braces can be used as a workaround. {
print("foo");
print("bar");
print("foobar");
}cc @jseyfried @nrc |
emilio commentedAug 10, 2016
If you have a file that invokes a macro and you
include!it, the following happens:main.rshelper.rsSTR
Expected output
Should print
fooandbar, just as if the code would have been inlined.Tested with latest nightly and stable: