Revert "Rollup merge of #76285 - matklad:censor-spacing, r=petrochenkov"
This reverts commit85cee57fd7
, reversing changes made tob4d3873024
.
This commit is contained in:
parent
97eb606e4b
commit
fdff7defc9
4 changed files with 16 additions and 25 deletions
|
@ -403,8 +403,8 @@ impl Cursor {
|
||||||
self.index = index;
|
self.index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn look_ahead(&self, n: usize) -> Option<&TokenTree> {
|
pub fn look_ahead(&self, n: usize) -> Option<TokenTree> {
|
||||||
self.stream.0[self.index..].get(n).map(|(tree, _)| tree)
|
self.stream.0[self.index..].get(n).map(|(tree, _)| tree.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,26 +47,15 @@ impl ToInternal<token::DelimToken> for Delimiter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl
|
impl FromInternal<(TreeAndJoint, &'_ ParseSess, &'_ mut Vec<Self>)>
|
||||||
FromInternal<(
|
for TokenTree<Group, Punct, Ident, Literal>
|
||||||
TreeAndJoint,
|
|
||||||
Option<&'_ tokenstream::TokenTree>,
|
|
||||||
&'_ ParseSess,
|
|
||||||
&'_ mut Vec<Self>,
|
|
||||||
)> for TokenTree<Group, Punct, Ident, Literal>
|
|
||||||
{
|
{
|
||||||
fn from_internal(
|
fn from_internal(
|
||||||
((tree, is_joint), look_ahead, sess, stack): (
|
((tree, is_joint), sess, stack): (TreeAndJoint, &ParseSess, &mut Vec<Self>),
|
||||||
TreeAndJoint,
|
|
||||||
Option<&tokenstream::TokenTree>,
|
|
||||||
&ParseSess,
|
|
||||||
&mut Vec<Self>,
|
|
||||||
),
|
|
||||||
) -> Self {
|
) -> Self {
|
||||||
use rustc_ast::token::*;
|
use rustc_ast::token::*;
|
||||||
|
|
||||||
let joint = is_joint == Joint
|
let joint = is_joint == Joint;
|
||||||
&& matches!(look_ahead, Some(tokenstream::TokenTree::Token(t)) if t.is_op());
|
|
||||||
let Token { kind, span } = match tree {
|
let Token { kind, span } = match tree {
|
||||||
tokenstream::TokenTree::Delimited(span, delim, tts) => {
|
tokenstream::TokenTree::Delimited(span, delim, tts) => {
|
||||||
let delimiter = Delimiter::from_internal(delim);
|
let delimiter = Delimiter::from_internal(delim);
|
||||||
|
@ -456,8 +445,7 @@ impl server::TokenStreamIter for Rustc<'_> {
|
||||||
loop {
|
loop {
|
||||||
let tree = iter.stack.pop().or_else(|| {
|
let tree = iter.stack.pop().or_else(|| {
|
||||||
let next = iter.cursor.next_with_joint()?;
|
let next = iter.cursor.next_with_joint()?;
|
||||||
let lookahead = iter.cursor.look_ahead(0);
|
Some(TokenTree::from_internal((next, self.sess, &mut iter.stack)))
|
||||||
Some(TokenTree::from_internal((next, lookahead, self.sess, &mut iter.stack)))
|
|
||||||
})?;
|
})?;
|
||||||
// A hack used to pass AST fragments to attribute and derive macros
|
// A hack used to pass AST fragments to attribute and derive macros
|
||||||
// as a single nonterminal token instead of a token stream.
|
// as a single nonterminal token instead of a token stream.
|
||||||
|
|
|
@ -262,7 +262,10 @@ impl<'a> TokenTreesReader<'a> {
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let tt = TokenTree::Token(self.token.take());
|
let tt = TokenTree::Token(self.token.take());
|
||||||
let is_joint = self.bump();
|
let mut is_joint = self.bump();
|
||||||
|
if !self.token.is_op() {
|
||||||
|
is_joint = NonJoint;
|
||||||
|
}
|
||||||
Ok((tt, is_joint))
|
Ok((tt, is_joint))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -822,15 +822,15 @@ impl<'a> Parser<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let frame = &self.token_cursor.frame;
|
let frame = &self.token_cursor.frame;
|
||||||
match frame.tree_cursor.look_ahead(dist - 1) {
|
looker(&match frame.tree_cursor.look_ahead(dist - 1) {
|
||||||
Some(tree) => match tree {
|
Some(tree) => match tree {
|
||||||
TokenTree::Token(token) => looker(token),
|
TokenTree::Token(token) => token,
|
||||||
TokenTree::Delimited(dspan, delim, _) => {
|
TokenTree::Delimited(dspan, delim, _) => {
|
||||||
looker(&Token::new(token::OpenDelim(delim.clone()), dspan.open))
|
Token::new(token::OpenDelim(delim), dspan.open)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None => looker(&Token::new(token::CloseDelim(frame.delim), frame.span.close)),
|
None => Token::new(token::CloseDelim(frame.delim), frame.span.close),
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether any of the given keywords are `dist` tokens ahead of the current one.
|
/// Returns whether any of the given keywords are `dist` tokens ahead of the current one.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue