Skip to content

Reimplement TokenStreams using ropes #35018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/libsyntax/codemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,23 @@ pub fn dummy_spanned<T>(t: T) -> Spanned<T> {
respan(DUMMY_SP, t)
}

/// Build a span that covers the two provided spans.
pub fn combine_spans(sp1: Span, sp2: Span) -> Span {
if sp1 == DUMMY_SP && sp2 == DUMMY_SP {
DUMMY_SP
} else if sp1 == DUMMY_SP {
sp2
} else if sp2 == DUMMY_SP {
sp1
} else {
Span {
lo: if sp1.lo < sp2.lo { sp1.lo } else { sp2.lo },
hi: if sp1.hi > sp2.hi { sp1.hi } else { sp2.hi },
expn_id: if sp1.expn_id == sp2.expn_id { sp1.expn_id } else { NO_EXPANSION },
}
}
}

#[derive(Clone, Hash, Debug)]
pub struct NameAndSpan {
/// The format with which the macro was invoked.
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub fn new_parser_from_ts<'a>(sess: &'a ParseSess,
cfg: ast::CrateConfig,
ts: tokenstream::TokenStream)
-> Parser<'a> {
tts_to_parser(sess, ts.tts, cfg)
tts_to_parser(sess, ts.to_tts(), cfg)
}


Expand Down
Loading