Skip to content

Add line information to error messages in generate!() invocations - #1729

Merged
alexcrichton merged 1 commit into
bytecodealliance:mainfrom
Qix-:line-info-in-errors
Oct 1, 2026
Merged

alexcrichton merged 1 commit into
bytecodealliance:mainfrom
Qix-:line-info-in-errors

Conversation

@Qix-

@Qix- Qix- commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Closes #1725.

Had to re-create the functionality from wit-parser. In theory wit-parser could simply accept a &(dyn std::error::Error + 'static) instead of a full-blown Anyhow error to perform the downcasting, but that's not part of this repo so I left that as an extracurricular exercise. If that were to happen, this could just shell out to that function.

Anyway, before:

 1  error: failed to resolve directory while parsing WIT for path [/opt/src/snip/snip/crates/snip-wasm-wit/wit]
                                                                                                                       
        Caused by:                                                                                                     
          failed to parse package: /opt/src/snip/snip/crates/snip-wasm-wit/wit                                 
                                                                                                                       
        Caused by:                                                                                                     
          expected `world`, `interface` or `use`, found '}'                                                            

after:

 1  error: failed to resolve directory while parsing WIT for path [/opt/src/snip/snip/crates/snip-wasm-wit/wit]
                                                                                                                       
        Caused by:                                                                                                     
          failed to parse package: /opt/src/snip/snip/crates/snip-wasm-wit/wit                                 
                                                                                                                       
        Caused by:                                                                                                     
          expected `world`, `interface` or `use`, found '}'                                                            
             --> /opt/src/snip/snip/crates/snip-wasm-wit/wit/cursor.wit:5:2                                    
              |                                                                                                        
            5 | }}                                                                                                     
              |  ^                                                                                                     

Small thing, but huge QoL improvement when writing out types. Thanks for letting me do this!

@alexcrichton
alexcrichton added this pull request to the merge queue Oct 1, 2026
Merged via the queue into bytecodealliance:main with commit 917fdc1 Oct 1, 2026
29 checks passed
@Qix-
Qix- deleted the line-info-in-errors branch October 1, 2026 15:04
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.

WIT errors don't include any positioning information.

2 participants