Skip to content

Greatly improve error messages on nightly#525

Merged
Kijewski merged 3 commits intoaskama-rs:masterfrom
GuillaumeGomez:span-nightly
Jul 20, 2025
Merged

Greatly improve error messages on nightly#525
Kijewski merged 3 commits intoaskama-rs:masterfrom
GuillaumeGomez:span-nightly

Conversation

@GuillaumeGomez
Copy link
Copy Markdown
Collaborator

Part of #420.

This PR (not ready yet, need to check the in-doc feature display regression) emits better errors when Span information is available. Currently it gives:

error: the `urlencode` filter requires the `urlencode` feature to be enabled
         --> Example.html:2:6
       "| urlencode }}\n"
 --> src/main.rs:5:18
  |
5 |           source = "
  |  __________________^
6 | | {{ 12 | urlencode }}
7 | | ",
  | |_^

error[E0599]: no method named `render` found for struct `Example` in the current scope
   --> src/main.rs:14:17
    |
10  |     struct Example;
    |     -------------- method `render` not found for this struct
...
14  |         Example.render().unwrap(),
    |                 ^^^^^^
    |

With this PR it gives:

error: the `urlencode` filter requires the `urlencode` feature to be enabled
 --> src/main.rs:6:6
  |
6 | {{ 12 | urlencode }}
  |      ^^^^^^^^^^^^^

error[E0599]: no method named `render` found for struct `Example` in the current scope
   --> src/main.rs:14:17
    |
10  |     struct Example;
    |     -------------- method `render` not found for this struct
...
14  |         Example.render().unwrap(),
    |                 ^^^^^^
    |

Considering how big it is already, I'm not gonna add span information into the generated code in here, gonna be a (likely massive again T_T) follow-up.

@Kijewski
Copy link
Copy Markdown
Member

I invited you to an experiment I'm currently working on. The want to refactor the parser a lot -- that is, after the current version working version is released. This will change the way how spans are collected quite severely, too.

@GuillaumeGomez
Copy link
Copy Markdown
Collaborator Author

Well, the parser is the least impacting part here. What I want to change the most is the generator. 😆

@GuillaumeGomez
Copy link
Copy Markdown
Collaborator Author

So about the current situation: do you want to postpone this work for after next release and I wait for you to be done on the new lexer before updating the generator or can I finish the current changes and then we'll add the new lexer?

@Kijewski
Copy link
Copy Markdown
Member

Kijewski commented Jul 11, 2025

The PR is an improvement over the current state! The new lexer might replicate/replace your work to take the span, but given that it will surely take a while until my changes land, a good thing is a good thing even if it only lasts for a few months / is improved upon afterwards. :) So, no need to wait for me. (I did not look at the PR properly when I posted my previous comment.)

@GuillaumeGomez
Copy link
Copy Markdown
Collaborator Author

Perfect, then whenever I have time, I'll finish the current PR and send a follow-up for the generator (and the generated code).

@GuillaumeGomez GuillaumeGomez force-pushed the span-nightly branch 7 times, most recently from 1b9dd0b to 825390d Compare July 15, 2025 21:16
@GuillaumeGomez GuillaumeGomez marked this pull request as ready for review July 15, 2025 21:20
@GuillaumeGomez
Copy link
Copy Markdown
Collaborator Author

PR is ready for review. Although I have no clue what's wrong with the CI Book task. Any idea @Kijewski?

@GuillaumeGomez
Copy link
Copy Markdown
Collaborator Author

Restarting the CI fixed it. Oh well, dark magic.

@GuillaumeGomez
Copy link
Copy Markdown
Collaborator Author

PR is ready and CI passed. :)

Copy link
Copy Markdown
Member

@Kijewski Kijewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks!

@Kijewski Kijewski merged commit d8bf389 into askama-rs:master Jul 20, 2025
42 checks passed
@GuillaumeGomez GuillaumeGomez deleted the span-nightly branch July 20, 2025 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants