Skip to content

Commit 3523b94

Browse files
committed
---
yaml --- r: 224147 b: refs/heads/beta c: 07afe91 h: refs/heads/master i: 224145: 9884993 224143: 48134a4 v: v3
1 parent 4408e86 commit 3523b94

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: cb5f0b4971481fd8985c78c7a24e422f45ea6560
26+
refs/heads/beta: 07afe91fda3df8e3b7bbb14006a64d136627f33c
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 938f5d7af401e2d8238522fed4a612943b6e77fd
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/libsyntax/ext/expand.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,23 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
5050
callee: NameAndSpan {
5151
name: expansion_desc.to_string(),
5252
format: CompilerExpansion,
53+
54+
// This does *not* mean code generated after
55+
// `push_compiler_expansion` is automatically exempt
56+
// from stability lints; must also tag such code with
57+
// an appropriate span from `fld.cx.backtrace()`.
5358
allow_internal_unstable: true,
59+
5460
span: None,
5561
},
5662
});
5763
}
5864

65+
// Sets the expn_id so that we can use unstable methods.
66+
fn allow_unstable(fld: &mut MacroExpander, span: Span) -> Span {
67+
Span { expn_id: fld.cx.backtrace(), ..span }
68+
}
69+
5970
let expr_span = e.span;
6071
return e.and_then(|ast::Expr {id, node, span}| match node {
6172

@@ -101,6 +112,8 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
101112
&fld.cx.parse_sess.span_diagnostic,
102113
expr_span);
103114

115+
push_compiler_expansion(fld, expr_span, "placement-in expansion");
116+
104117
let value_span = value_expr.span;
105118
let placer_span = placer.span;
106119

@@ -121,9 +134,14 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
121134
let inplace_finalize = ["ops", "InPlace", "finalize"];
122135

123136
let make_call = |fld: &mut MacroExpander, p, args| {
124-
let path = mk_core_path(fld, placer_span, p);
137+
// We feed in the `expr_span` because codemap's span_allows_unstable
138+
// allows the call_site span to inherit the `allow_internal_unstable`
139+
// setting.
140+
let span_unstable = allow_unstable(fld, expr_span);
141+
let path = mk_core_path(fld, span_unstable, p);
125142
let path = fld.cx.expr_path(path);
126-
fld.cx.expr_call(span, path, args)
143+
let expr_span_unstable = allow_unstable(fld, span);
144+
fld.cx.expr_call(expr_span_unstable, path, args)
127145
};
128146

129147
let stmt_let = |fld: &mut MacroExpander, bind, expr| {
@@ -166,7 +184,9 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
166184
};
167185

168186
let block = fld.cx.block_all(span, vec![s1, s2, s3], expr);
169-
fld.cx.expr_block(block)
187+
let result = fld.cx.expr_block(block);
188+
fld.cx.bt_pop();
189+
result
170190
}
171191

172192
// Issue #22181:

0 commit comments

Comments
 (0)