diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
commit | d1b2d29528b7794b41e66fc2136e395a02f8529b (patch) | |
tree | a4a17504b260206dec3cf55b2dca82929a348ac2 /compiler/rustc_span/src/source_map.rs | |
parent | Releasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip |
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_span/src/source_map.rs')
-rw-r--r-- | compiler/rustc_span/src/source_map.rs | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs index 86716da17..983b2ab04 100644 --- a/compiler/rustc_span/src/source_map.rs +++ b/compiler/rustc_span/src/source_map.rs @@ -973,24 +973,21 @@ impl SourceMap { Span::new(BytePos(start_of_next_point), end_of_next_point, sp.ctxt(), None) } - /// Returns a new span to check next none-whitespace character or some specified expected character - /// If `expect` is none, the first span of non-whitespace character is returned. - /// If `expect` presented, the first span of the character `expect` is returned - /// Otherwise, the span reached to limit is returned. - pub fn span_look_ahead(&self, span: Span, expect: Option<&str>, limit: Option<usize>) -> Span { + /// Check whether span is followed by some specified expected string in limit scope + pub fn span_look_ahead(&self, span: Span, expect: &str, limit: Option<usize>) -> Option<Span> { let mut sp = span; for _ in 0..limit.unwrap_or(100_usize) { sp = self.next_point(sp); if let Ok(ref snippet) = self.span_to_snippet(sp) { - if expect.is_some_and(|es| snippet == es) { - break; + if snippet == expect { + return Some(sp); } - if expect.is_none() && snippet.chars().any(|c| !c.is_whitespace()) { + if snippet.chars().any(|c| !c.is_whitespace()) { break; } } } - sp + None } /// Finds the width of the character, either before or after the end of provided span, |