Skip to content

Commit 1ece9ca

Browse files
authored
Auto merge of #35018 - cgswords:rope_tstream, r=nrc
Reimplement TokenStreams using ropes Title says it all; a reimplementation of TokenStreams as ropes. r? @nrc
2 parents 28ce3e8 + dc259de commit 1ece9ca

File tree

3 files changed

+374
-610
lines changed

3 files changed

+374
-610
lines changed

src/libsyntax/codemap.rs

+17
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,23 @@ pub fn dummy_spanned<T>(t: T) -> Spanned<T> {
7171
respan(DUMMY_SP, t)
7272
}
7373

74+
/// Build a span that covers the two provided spans.
75+
pub fn combine_spans(sp1: Span, sp2: Span) -> Span {
76+
if sp1 == DUMMY_SP && sp2 == DUMMY_SP {
77+
DUMMY_SP
78+
} else if sp1 == DUMMY_SP {
79+
sp2
80+
} else if sp2 == DUMMY_SP {
81+
sp1
82+
} else {
83+
Span {
84+
lo: if sp1.lo < sp2.lo { sp1.lo } else { sp2.lo },
85+
hi: if sp1.hi > sp2.hi { sp1.hi } else { sp2.hi },
86+
expn_id: if sp1.expn_id == sp2.expn_id { sp1.expn_id } else { NO_EXPANSION },
87+
}
88+
}
89+
}
90+
7491
#[derive(Clone, Hash, Debug)]
7592
pub struct NameAndSpan {
7693
/// The format with which the macro was invoked.

src/libsyntax/parse/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ pub fn new_parser_from_ts<'a>(sess: &'a ParseSess,
237237
cfg: ast::CrateConfig,
238238
ts: tokenstream::TokenStream)
239239
-> Parser<'a> {
240-
tts_to_parser(sess, ts.tts, cfg)
240+
tts_to_parser(sess, ts.to_tts(), cfg)
241241
}
242242

243243

0 commit comments

Comments
 (0)