dtolnay / syn

Parser for Rust source code
Apache License 2.0
2.78k stars 306 forks source link

Make LitCStr peekable #1682

Closed dtolnay closed 1 month ago

dtolnay commented 1 month ago

Previously input.peek(syn::LitStr) worked but input.peek(syn::LitCStr) would fail to compile.

error[E0277]: the trait bound `LitCStr: CustomToken` is not satisfied
   --> src/lib.rs:7:19
    |
7   |     if input.peek(syn::LitCStr) {
    |              ---- ^^^^^^^^^^^^ the trait `CustomToken` is not implemented for `LitCStr`, which is required by `fn(syn::lookahead::TokenMarker) -> LitCStr {LitCStr}: Peek`
    |              |
    |              required by a bound introduced by this call
    |
    = help: the following other types implement trait `CustomToken`:
              syn::expr::parsing::kw::builtin
              syn::expr::parsing::kw::raw
              syn::ext::private::IdentAny
    = note: required for `LitCStr` to implement `Token`
    = note: required for `fn(syn::lookahead::TokenMarker) -> LitCStr {LitCStr}` to implement `Peek`
note: required by a bound in `ParseBuffer::<'a>::peek`
   --> .cargo/registry/src/index.crates.io-6f17d22bba15001f/syn-2.0.66/src/parse.rs:580:20
    |
580 |     pub fn peek<T: Peek>(&self, token: T) -> bool {
    |                    ^^^^ required by this bound in `ParseBuffer::<'a>::peek`