about summary refs log tree commit diff
path: root/src/tools
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-12-11 12:29:04 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2024-12-18 10:31:39 +1100
commit3575e7943b4d4a47c30716c50884d4ceee1b7dcd (patch)
tree5da82514a016b43bbb8d5fee3660f124cd138e8c /src/tools
parent0bf6e82c540c838c277ef3ae54c2ac125391dde9 (diff)
Simplify `RefTokenTreeCursor::look_ahead`.
It's only ever used with a lookahead of 0, so this commit removes the
lookahead and renames it `peek`.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/clippy/clippy_lints/src/crate_in_macro_def.rs2
-rw-r--r--src/tools/rustfmt/src/macros.rs4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/tools/clippy/clippy_lints/src/crate_in_macro_def.rs b/src/tools/clippy/clippy_lints/src/crate_in_macro_def.rs
index c8f81413728..76b88b746cb 100644
--- a/src/tools/clippy/clippy_lints/src/crate_in_macro_def.rs
+++ b/src/tools/clippy/clippy_lints/src/crate_in_macro_def.rs
@@ -86,7 +86,7 @@ fn contains_unhygienic_crate_reference(tts: &TokenStream) -> Option<Span> {
     while let Some(curr) = cursor.next() {
         if !prev_is_dollar
             && let Some(span) = is_crate_keyword(curr)
-            && let Some(next) = cursor.look_ahead(0)
+            && let Some(next) = cursor.peek()
             && is_token(next, &TokenKind::PathSep)
         {
             return Some(span);
diff --git a/src/tools/rustfmt/src/macros.rs b/src/tools/rustfmt/src/macros.rs
index fa281cab724..dad074440b4 100644
--- a/src/tools/rustfmt/src/macros.rs
+++ b/src/tools/rustfmt/src/macros.rs
@@ -1190,7 +1190,7 @@ impl<'a> MacroParser<'a> {
     // (`(` ... `)` `=>` `{` ... `}`)*
     fn parse(&mut self) -> Option<Macro> {
         let mut branches = vec![];
-        while self.toks.look_ahead(0).is_some() {
+        while self.toks.peek().is_some() {
             branches.push(self.parse_branch()?);
         }
 
@@ -1237,7 +1237,7 @@ impl<'a> MacroParser<'a> {
                 span,
             },
             _,
-        )) = self.toks.look_ahead(0)
+        )) = self.toks.peek()
         {
             hi = span.hi();
             self.toks.next();