Skip to content

Commit 725c483

Browse files
committed
---
yaml --- r: 221041 b: refs/heads/auto c: 07afe91 h: refs/heads/master i: 221039: 7107a9b v: v3
1 parent faf7da7 commit 725c483

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
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: cb5f0b4971481fd8985c78c7a24e422f45ea6560
11+
refs/heads/auto: 07afe91fda3df8e3b7bbb14006a64d136627f33c
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/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)