Skip to content

Commit d4f1b84

Browse files
committed
---
yaml --- r: 228659 b: refs/heads/try c: 07afe91 h: refs/heads/master i: 228657: 89dbbb2 228655: bf0cb5d v: v3
1 parent c18f085 commit d4f1b84

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
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: aca2057ed5fb7af3f8905b2bc01f72fa001c35c8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: cb5f0b4971481fd8985c78c7a24e422f45ea6560
4+
refs/heads/try: 07afe91fda3df8e3b7bbb14006a64d136627f33c
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

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