Skip to content

Commit 29f0760

Browse files
committed
work around #33684, which affects NLL more than the old typeck
1 parent fe44e5d commit 29f0760

File tree

9 files changed

+68
-66
lines changed

9 files changed

+68
-66
lines changed

src/libsyntax/ext/quote.rs

+32-32
Original file line numberDiff line numberDiff line change
@@ -480,68 +480,68 @@ pub fn expand_quote_pat<'cx>(cx: &'cx mut ExtCtxt,
480480
base::MacEager::expr(expanded)
481481
}
482482

483-
pub fn expand_quote_arm(cx: &mut ExtCtxt,
484-
sp: Span,
485-
tts: &[TokenTree])
486-
-> Box<base::MacResult+'static> {
483+
pub fn expand_quote_arm<'cx>(cx: &'cx mut ExtCtxt,
484+
sp: Span,
485+
tts: &[TokenTree])
486+
-> Box<base::MacResult+'cx> {
487487
let expanded = expand_parse_call(cx, sp, "parse_arm_panic", vec![], tts);
488488
base::MacEager::expr(expanded)
489489
}
490490

491-
pub fn expand_quote_ty(cx: &mut ExtCtxt,
492-
sp: Span,
493-
tts: &[TokenTree])
494-
-> Box<base::MacResult+'static> {
491+
pub fn expand_quote_ty<'cx>(cx: &'cx mut ExtCtxt,
492+
sp: Span,
493+
tts: &[TokenTree])
494+
-> Box<base::MacResult+'cx> {
495495
let expanded = expand_parse_call(cx, sp, "parse_ty_panic", vec![], tts);
496496
base::MacEager::expr(expanded)
497497
}
498498

499-
pub fn expand_quote_stmt(cx: &mut ExtCtxt,
500-
sp: Span,
501-
tts: &[TokenTree])
502-
-> Box<base::MacResult+'static> {
499+
pub fn expand_quote_stmt<'cx>(cx: &'cx mut ExtCtxt,
500+
sp: Span,
501+
tts: &[TokenTree])
502+
-> Box<base::MacResult+'cx> {
503503
let expanded = expand_parse_call(cx, sp, "parse_stmt_panic", vec![], tts);
504504
base::MacEager::expr(expanded)
505505
}
506506

507-
pub fn expand_quote_attr(cx: &mut ExtCtxt,
508-
sp: Span,
509-
tts: &[TokenTree])
510-
-> Box<base::MacResult+'static> {
507+
pub fn expand_quote_attr<'cx>(cx: &'cx mut ExtCtxt,
508+
sp: Span,
509+
tts: &[TokenTree])
510+
-> Box<base::MacResult+'cx> {
511511
let expanded = expand_parse_call(cx, sp, "parse_attribute_panic",
512512
vec![cx.expr_bool(sp, true)], tts);
513513

514514
base::MacEager::expr(expanded)
515515
}
516516

517-
pub fn expand_quote_arg(cx: &mut ExtCtxt,
518-
sp: Span,
519-
tts: &[TokenTree])
520-
-> Box<base::MacResult+'static> {
517+
pub fn expand_quote_arg<'cx>(cx: &'cx mut ExtCtxt,
518+
sp: Span,
519+
tts: &[TokenTree])
520+
-> Box<base::MacResult+'cx> {
521521
let expanded = expand_parse_call(cx, sp, "parse_arg_panic", vec![], tts);
522522
base::MacEager::expr(expanded)
523523
}
524524

525-
pub fn expand_quote_block(cx: &mut ExtCtxt,
526-
sp: Span,
527-
tts: &[TokenTree])
528-
-> Box<base::MacResult+'static> {
525+
pub fn expand_quote_block<'cx>(cx: &'cx mut ExtCtxt,
526+
sp: Span,
527+
tts: &[TokenTree])
528+
-> Box<base::MacResult+'cx> {
529529
let expanded = expand_parse_call(cx, sp, "parse_block_panic", vec![], tts);
530530
base::MacEager::expr(expanded)
531531
}
532532

533-
pub fn expand_quote_meta_item(cx: &mut ExtCtxt,
534-
sp: Span,
535-
tts: &[TokenTree])
536-
-> Box<base::MacResult+'static> {
533+
pub fn expand_quote_meta_item<'cx>(cx: &'cx mut ExtCtxt,
534+
sp: Span,
535+
tts: &[TokenTree])
536+
-> Box<base::MacResult+'cx> {
537537
let expanded = expand_parse_call(cx, sp, "parse_meta_item_panic", vec![], tts);
538538
base::MacEager::expr(expanded)
539539
}
540540

541-
pub fn expand_quote_path(cx: &mut ExtCtxt,
542-
sp: Span,
543-
tts: &[TokenTree])
544-
-> Box<base::MacResult+'static> {
541+
pub fn expand_quote_path<'cx>(cx: &'cx mut ExtCtxt,
542+
sp: Span,
543+
tts: &[TokenTree])
544+
-> Box<base::MacResult+'cx> {
545545
let mode = mk_parser_path(cx, sp, &["PathStyle", "Type"]);
546546
let expanded = expand_parse_call(cx, sp, "parse_path_panic", vec![mode], tts);
547547
base::MacEager::expr(expanded)

src/libsyntax/ext/source_util.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ use rustc_data_structures::sync::Lrc;
3131
// a given file into the current one.
3232

3333
/// line!(): expands to the current line number
34-
pub fn expand_line(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
35-
-> Box<base::MacResult+'static> {
34+
pub fn expand_line<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
35+
-> Box<base::MacResult+'cx> {
3636
base::check_zero_tts(cx, sp, tts, "line!");
3737

3838
let topmost = cx.expansion_cause().unwrap_or(sp);
@@ -42,8 +42,8 @@ pub fn expand_line(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
4242
}
4343

4444
/* column!(): expands to the current column number */
45-
pub fn expand_column(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
46-
-> Box<base::MacResult+'static> {
45+
pub fn expand_column<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
46+
-> Box<base::MacResult+'cx> {
4747
base::check_zero_tts(cx, sp, tts, "column!");
4848

4949
let topmost = cx.expansion_cause().unwrap_or(sp);
@@ -53,8 +53,8 @@ pub fn expand_column(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
5353
}
5454

5555
/* __rust_unstable_column!(): expands to the current column number */
56-
pub fn expand_column_gated(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
57-
-> Box<base::MacResult+'static> {
56+
pub fn expand_column_gated<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
57+
-> Box<base::MacResult+'cx> {
5858
if sp.allows_unstable() {
5959
expand_column(cx, sp, tts)
6060
} else {
@@ -65,23 +65,23 @@ pub fn expand_column_gated(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::Token
6565
/// file!(): expands to the current filename */
6666
/// The filemap (`loc.file`) contains a bunch more information we could spit
6767
/// out if we wanted.
68-
pub fn expand_file(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
69-
-> Box<base::MacResult+'static> {
68+
pub fn expand_file<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
69+
-> Box<base::MacResult+'cx> {
7070
base::check_zero_tts(cx, sp, tts, "file!");
7171

7272
let topmost = cx.expansion_cause().unwrap_or(sp);
7373
let loc = cx.codemap().lookup_char_pos(topmost.lo());
7474
base::MacEager::expr(cx.expr_str(topmost, Symbol::intern(&loc.file.name.to_string())))
7575
}
7676

77-
pub fn expand_stringify(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
78-
-> Box<base::MacResult+'static> {
77+
pub fn expand_stringify<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
78+
-> Box<base::MacResult+'cx> {
7979
let s = pprust::tts_to_string(tts);
8080
base::MacEager::expr(cx.expr_str(sp, Symbol::intern(&s)))
8181
}
8282

83-
pub fn expand_mod(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
84-
-> Box<base::MacResult+'static> {
83+
pub fn expand_mod<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
84+
-> Box<base::MacResult+'cx> {
8585
base::check_zero_tts(cx, sp, tts, "module_path!");
8686
let mod_path = &cx.current_expansion.module.mod_path;
8787
let string = mod_path.iter().map(|x| x.to_string()).collect::<Vec<String>>().join("::");
@@ -130,8 +130,8 @@ pub fn expand_include<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::T
130130
}
131131

132132
// include_str! : read the given file, insert it as a literal string expr
133-
pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
134-
-> Box<base::MacResult+'static> {
133+
pub fn expand_include_str<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
134+
-> Box<base::MacResult+'cx> {
135135
let file = match get_single_str_from_tts(cx, sp, tts, "include_str!") {
136136
Some(f) => f,
137137
None => return DummyResult::expr(sp)
@@ -165,8 +165,8 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenT
165165
}
166166
}
167167

168-
pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
169-
-> Box<base::MacResult+'static> {
168+
pub fn expand_include_bytes<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
169+
-> Box<base::MacResult+'cx> {
170170
let file = match get_single_str_from_tts(cx, sp, tts, "include_bytes!") {
171171
Some(f) => f,
172172
None => return DummyResult::expr(sp)

src/libsyntax_ext/cfg.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ use syntax::tokenstream;
2020
use syntax::parse::token;
2121
use syntax_pos::Span;
2222

23-
pub fn expand_cfg<'cx>(cx: &mut ExtCtxt,
23+
pub fn expand_cfg<'cx>(cx: &'cx mut ExtCtxt,
2424
sp: Span,
2525
tts: &[tokenstream::TokenTree])
26-
-> Box<base::MacResult + 'static> {
26+
-> Box<base::MacResult + 'cx> {
2727
let sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark));
2828
let mut p = cx.new_parser_from_tts(tts);
2929
let cfg = panictry!(p.parse_meta_item());

src/libsyntax_ext/concat.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ use syntax::tokenstream;
1717

1818
use std::string::String;
1919

20-
pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
21-
sp: syntax_pos::Span,
22-
tts: &[tokenstream::TokenTree])
23-
-> Box<base::MacResult + 'static> {
20+
pub fn expand_syntax_ext<'cx>(
21+
cx: &'cx mut base::ExtCtxt,
22+
sp: syntax_pos::Span,
23+
tts: &[tokenstream::TokenTree]
24+
) -> Box<base::MacResult + 'cx> {
2425
let es = match base::get_exprs_from_tts(cx, sp, tts) {
2526
Some(e) => e,
2627
None => return base::DummyResult::expr(sp),

src/libsyntax_ext/trace_macros.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ use syntax::symbol::keywords;
1515
use syntax_pos::Span;
1616
use syntax::tokenstream::TokenTree;
1717

18-
pub fn expand_trace_macros(cx: &mut ExtCtxt,
19-
sp: Span,
20-
tt: &[TokenTree])
21-
-> Box<base::MacResult + 'static> {
18+
pub fn expand_trace_macros<'cx>(
19+
cx: &'cx mut ExtCtxt,
20+
sp: Span,
21+
tt: &[TokenTree]
22+
) -> Box<base::MacResult + 'cx> {
2223
if !cx.ecfg.enable_trace_macros() {
2324
feature_gate::emit_feature_err(&cx.parse_sess,
2425
"trace_macros",

src/test/run-pass-fulldeps/auxiliary/issue-16723.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ pub fn plugin_registrar(reg: &mut Registry) {
2929
reg.register_macro("multiple_items", expand)
3030
}
3131

32-
fn expand(cx: &mut ExtCtxt, _: syntax_pos::Span, _: &[tokenstream::TokenTree])
33-
-> Box<MacResult+'static> {
32+
fn expand<'cx>(cx: &'cx mut ExtCtxt, _: syntax_pos::Span, _: &[tokenstream::TokenTree])
33+
-> Box<MacResult+'cx> {
3434
MacEager::items(SmallVector::many(vec![
3535
quote_item!(cx, struct Struct1;).unwrap(),
3636
quote_item!(cx, struct Struct2;).unwrap()

src/test/run-pass-fulldeps/auxiliary/macro_crate_test.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ pub fn plugin_registrar(reg: &mut Registry) {
4747
MultiDecorator(Box::new(expand_caller)));
4848
}
4949

50-
fn expand_make_a_1(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<MacResult + 'static> {
50+
fn expand_make_a_1<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<MacResult + 'cx> {
5151
if !tts.is_empty() {
5252
cx.span_fatal(sp, "make_a_1 takes no arguments");
5353
}
5454
MacEager::expr(quote_expr!(cx, 1))
5555
}
5656

5757
// See Issue #15750
58-
fn expand_identity(cx: &mut ExtCtxt, _span: Span, tts: &[TokenTree]) -> Box<MacResult + 'static> {
58+
fn expand_identity<'cx>(cx: &'cx mut ExtCtxt, _span: Span, tts: &[TokenTree]) -> Box<MacResult + 'cx> {
5959
// Parse an expression and emit it unchanged.
6060
let mut parser = parse::new_parser_from_tts(cx.parse_sess(), tts.to_vec());
6161
let expr = parser.parse_expr().unwrap();

src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ use rustc_plugin::Registry;
3434

3535
use std::cell::RefCell;
3636

37-
fn expand_mbe_matches(cx: &mut ExtCtxt, _: Span, args: &[TokenTree])
38-
-> Box<MacResult + 'static> {
37+
fn expand_mbe_matches<'cx>(cx: &'cx mut ExtCtxt, _: Span, args: &[TokenTree])
38+
-> Box<MacResult + 'cx> {
3939

4040
let mbe_matcher = quote_tokens!(cx, $$matched:expr, $$($$pat:pat)|+);
4141
let mbe_matcher = quoted::parse(mbe_matcher.into_iter().collect(),

src/test/run-pass-fulldeps/auxiliary/syntax_extension_with_dll_deps_2.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ pub fn plugin_registrar(reg: &mut Registry) {
3030
reg.register_macro("foo", expand_foo);
3131
}
3232

33-
fn expand_foo(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree])
34-
-> Box<MacResult+'static> {
33+
fn expand_foo(cx: &'cx mut ExtCtxt, sp: Span, tts: &[TokenTree])
34+
-> Box<MacResult+'cx> {
3535
let answer = other::the_answer();
3636
MacEager::expr(quote_expr!(cx, $answer))
3737
}

0 commit comments

Comments
 (0)