Skip to content

Commit 72752b4

Browse files
committed
---
yaml --- r: 235730 b: refs/heads/stable c: 07afe91 h: refs/heads/master v: v3
1 parent 530a84c commit 72752b4

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
@@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: cb5f0b4971481fd8985c78c7a24e422f45ea6560
32+
refs/heads/stable: 07afe91fda3df8e3b7bbb14006a64d136627f33c
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

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