mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 22:11:01 +01:00
remove Clone derive from the Lexer
also fixes spans in some cases
This commit is contained in:
1 parent
fca3c2ea70
commit
626f5514b6
3 files changed
+30
-27
No files matched your search
@@ -243,7 +243,6 @@ fn is_word_part(c: char) -> bool {
|
||||
unicode_ident::is_xid_continue(c)
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub(in crate::front::wgsl) struct Lexer<'a> {
|
||||
/// The remaining unconsumed input.
|
||||
input: &'a str,
|
||||
@@ -330,13 +329,6 @@ impl<'a> Lexer<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn peek_token_and_rest(&mut self) -> (TokenSpan<'a>, &'a str) {
|
||||
let mut cloned = self.clone();
|
||||
let token = cloned.next();
|
||||
let rest = cloned.input;
|
||||
(token, rest)
|
||||
}
|
||||
|
||||
/// Collect all module doc comments until a non doc token is found.
|
||||
pub(in crate::front::wgsl) fn accumulate_module_doc_comments(&mut self) -> Vec<&'a str> {
|
||||
let mut doc_comments = Vec::new();
|
||||
@@ -426,10 +418,28 @@ impl<'a> Lexer<'a> {
|
||||
|
||||
#[must_use]
|
||||
pub(in crate::front::wgsl) fn peek(&mut self) -> TokenSpan<'a> {
|
||||
let (token, _) = self.peek_token_and_rest();
|
||||
let input = self.input;
|
||||
let last_end_offset = self.last_end_offset;
|
||||
let token = self.next();
|
||||
self.input = input;
|
||||
self.last_end_offset = last_end_offset;
|
||||
token
|
||||
}
|
||||
|
||||
/// If the next token matches it's consumed and true is returned
|
||||
pub(in crate::front::wgsl) fn next_if(&mut self, what: Token<'_>) -> bool {
|
||||
let input = self.input;
|
||||
let last_end_offset = self.last_end_offset;
|
||||
let token = self.next();
|
||||
if token.0 == what {
|
||||
true
|
||||
} else {
|
||||
self.input = input;
|
||||
self.last_end_offset = last_end_offset;
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub(in crate::front::wgsl) fn expect_span(&mut self, expected: Token<'a>) -> Result<'a, Span> {
|
||||
let next = self.next();
|
||||
if next.0 == expected {
|
||||
@@ -466,17 +476,6 @@ impl<'a> Lexer<'a> {
|
||||
self.next_if(Token::Separator(',')) && self.peek().0 != Token::Paren('>')
|
||||
}
|
||||
|
||||
/// If the next token matches it's consumed and true is returned
|
||||
pub(in crate::front::wgsl) fn next_if(&mut self, what: Token<'_>) -> bool {
|
||||
let (peeked_token, rest) = self.peek_token_and_rest();
|
||||
if peeked_token.0 == what {
|
||||
self.input = rest;
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub(in crate::front::wgsl) fn next_ident_with_span(&mut self) -> Result<'a, (&'a str, Span)> {
|
||||
match self.next() {
|
||||
(Token::Word("_"), span) => Err(Box::new(Error::InvalidIdentifierUnderscore(span))),
|
||||
|
||||
@@ -670,11 +670,14 @@ fn validation_error_messages() {
|
||||
"\
|
||||
error: Function [1] 'main' is invalid
|
||||
┌─ wgsl:7:17
|
||||
│ \n7 │ ╭ fn main() {
|
||||
│\x20\x20
|
||||
7 │ ╭ fn main() {
|
||||
8 │ │ foo();
|
||||
│ │ ^^^^ invalid function call
|
||||
│ ╰──────────────────────────^ naga::ir::Function [1]
|
||||
│ \n = Call to [0] is invalid
|
||||
│ │ ^^^^^ invalid function call
|
||||
9 │ │ }
|
||||
│ ╰─────────────────^ naga::ir::Function [1]
|
||||
│\x20\x20
|
||||
= Call to [0] is invalid
|
||||
= Requires 1 arguments, but 0 are provided
|
||||
|
||||
",
|
||||
|
||||
@@ -2933,7 +2933,7 @@ fn use_me(a: i32) {
|
||||
2 │ @must_use
|
||||
│ ^^^^^^^^
|
||||
3 │ fn use_me(a: i32) {
|
||||
│ ^^^^^^^^^^^^^
|
||||
│ ^^^^^^^^^^^^^^
|
||||
│
|
||||
= note: declare a return type or remove the attribute
|
||||
|
||||
@@ -3753,7 +3753,7 @@ fn inconsistent_type() {
|
||||
┌─ wgsl:2:20
|
||||
│
|
||||
2 │ return dot(vec4<f32>(), vec3<f32>());
|
||||
│ ^^^ ^^^^^^^^^^ ^^^^^^^^^^ argument #2 has type vec3<f32>
|
||||
│ ^^^ ^^^^^^^^^^^ ^^^^^^^^^^^ argument #2 has type vec3<f32>
|
||||
│ │\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
|
||||
│ this argument has type vec4<f32>, which constrains subsequent arguments
|
||||
│
|
||||
@@ -4301,7 +4301,8 @@ fn max_type_size_two_arrays_in_struct() {
|
||||
2 │ ╭ struct TwoArrays {
|
||||
3 │ │ arr1: array<u32, 1 << 27>,
|
||||
4 │ │ arr2: array<u32, (1 << 27) + 1>,
|
||||
│ ╰───────────────────────────────────────────────^ this type exceeds the maximum size
|
||||
5 │ │ }
|
||||
│ ╰─────────────^ this type exceeds the maximum size
|
||||
│\x20\x20
|
||||
= note: the maximum size is 1073741824 bytes
|
||||
|
||||
|
||||
Reference in new issue
Block a user