Skip to content
Closed
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
51a2e2f
Allow more Cell methods for non-Copy types
RalfJung Feb 13, 2017
044ed10
Remove Copy bound from some Cell trait impls
RalfJung Feb 14, 2017
ca54fc7
Show five traits implementation in help when there are exactly five
seppo0010 Feb 14, 2017
b2c4e74
rustc: Link statically to the MSVCRT
alexcrichton Feb 14, 2017
aebd94f
Stabilize field init shorthand
est31 Feb 12, 2017
5156ded
make doc consistent with var name
king6cong Feb 15, 2017
938fed7
Update procedural-macros.md
DaseinPhaos Feb 15, 2017
b821313
sys/mod doc update and mod import order adjust
king6cong Feb 15, 2017
577497b
Fix typo
comonadd Feb 15, 2017
b6a1618
book: don’t use GNU extensions in the example unnecessarily
mina86 Feb 13, 2017
cf20d8e
static recursion test added to compile-fail test suite
cseale Feb 15, 2017
d5a4db3
Fix parameter to GetUserProfileDirectoryW
retep998 Feb 15, 2017
e77f856
Add a test that -fPIC is applied
brson Feb 14, 2017
7a028e5
Rollup merge of #39761 - est31:master, r=aturon
frewsxcv Feb 16, 2017
016f73b
Rollup merge of #39775 - mina86:master, r=steveklabnik
frewsxcv Feb 16, 2017
54d75ac
Rollup merge of #39793 - RalfJung:cell, r=alexcrichton
frewsxcv Feb 16, 2017
10d2f6c
Rollup merge of #39803 - brson:fpic, r=alexcrichton
frewsxcv Feb 16, 2017
4f8d4be
Rollup merge of #39804 - seppo0010:recommend-five-traits, r=jonathand…
frewsxcv Feb 16, 2017
bf5604c
Rollup merge of #39834 - cseale:feature-gate-static-recursion, r=est31
frewsxcv Feb 16, 2017
e359698
Rollup merge of #39837 - alexcrichton:llvm-crt-static, r=brson
frewsxcv Feb 16, 2017
c6bdab9
Rollup merge of #39839 - king6cong:refine-doc, r=frewsxcv
frewsxcv Feb 16, 2017
1b28c13
Rollup merge of #39840 - DaseinPhaos:patch-2, r=frewsxcv
frewsxcv Feb 16, 2017
047e310
Rollup merge of #39844 - king6cong:sys, r=alexcrichton
frewsxcv Feb 16, 2017
034acc1
Rollup merge of #39846 - WRONGWAY4YOU:typo-fix, r=frewsxcv
frewsxcv Feb 16, 2017
6343542
Rollup merge of #39861 - retep998:small-fix, r=alexcrichton
frewsxcv Feb 16, 2017
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
14 changes: 6 additions & 8 deletions src/doc/book/src/macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,36 +261,34 @@ The metavariable `$x` is parsed as a single expression node, and keeps its
place in the syntax tree even after substitution.

Another common problem in macro systems is ‘variable capture’. Here’s a C
macro, using [a GNU C extension] to emulate Rust’s expression blocks.

[a GNU C extension]: https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
macro using a block with multiple statements.

```text
#define LOG(msg) ({ \
#define LOG(msg) do { \
int state = get_log_state(); \
if (state > 0) { \
printf("log(%d): %s\n", state, msg); \
} \
})
} while (0)
```

Here’s a simple use case that goes terribly wrong:

```text
const char *state = "reticulating splines";
LOG(state)
LOG(state);
```

This expands to

```text
const char *state = "reticulating splines";
{
do {
int state = get_log_state();
if (state > 0) {
printf("log(%d): %s\n", state, state);
}
}
} while (0);
```

The second variable named `state` shadows the first one. This is a problem
Expand Down