diff options
| author | bors <bors@rust-lang.org> | 2019-12-03 13:21:03 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-12-03 13:21:03 +0000 |
| commit | f577b0ef6e637ab7a6095cdfe0b51fa3faf97050 (patch) | |
| tree | 3acfc5e36ad8991bf613d5b85e3274c816a8b970 /src/libsyntax/tokenstream.rs | |
| parent | 7d808659cdc6c979a992fe3db345c0cfb53d973e (diff) | |
| parent | bce77980a2611da10b42dbd8a672c8cd17f79a94 (diff) | |
| download | rust-f577b0ef6e637ab7a6095cdfe0b51fa3faf97050.tar.gz rust-f577b0ef6e637ab7a6095cdfe0b51fa3faf97050.zip | |
Auto merge of #66982 - Centril:rollup-yq2281i, r=Centril
Rollup of 6 pull requests Successful merges: - #66148 (Show the sign for signed ops on `exact_div`) - #66651 (Add `enclosing scope` parameter to `rustc_on_unimplemented`) - #66904 (Adding docs for keyword match, move) - #66935 (syntax: Unify macro and attribute arguments in AST) - #66941 (Remove `ord` lang item) - #66967 (Remove hack for top-level or-patterns in match checking) Failed merges: r? @ghost
Diffstat (limited to 'src/libsyntax/tokenstream.rs')
| -rw-r--r-- | src/libsyntax/tokenstream.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libsyntax/tokenstream.rs b/src/libsyntax/tokenstream.rs index 6a0523dd655..491b9a9ade4 100644 --- a/src/libsyntax/tokenstream.rs +++ b/src/libsyntax/tokenstream.rs @@ -225,6 +225,14 @@ impl TokenStream { self.0.len() } + pub fn span(&self) -> Option<Span> { + match &**self.0 { + [] => None, + [(tt, _)] => Some(tt.span()), + [(tt_start, _), .., (tt_end, _)] => Some(tt_start.span().to(tt_end.span())), + } + } + pub fn from_streams(mut streams: SmallVec<[TokenStream; 2]>) -> TokenStream { match streams.len() { 0 => TokenStream::default(), |
