Skip to content

Remove anyhow from the WIT lexer#2461

Merged
alexcrichton merged 2 commits intobytecodealliance:mainfrom
PhoebeSzmucer:rm-lexer-anyhow
Mar 11, 2026
Merged

Remove anyhow from the WIT lexer#2461
alexcrichton merged 2 commits intobytecodealliance:mainfrom
PhoebeSzmucer:rm-lexer-anyhow

Conversation

@PhoebeSzmucer
Copy link
Contributor

  • Add 3 more variants to lex:Error - ControlCodepoint, DeprecatedCodepoint, ForbiddenCodepoint
  • Delete anyhow from the lexer API and implementation, by using core::result::Result instead of anyhow::Result. This way the consumer of the lexer can extract granular error information without having to parse the error message.
  • Introduce lex::Error::position()

Part of #2460

@PhoebeSzmucer PhoebeSzmucer requested a review from a team as a code owner March 10, 2026 20:14
@PhoebeSzmucer PhoebeSzmucer requested review from alexcrichton and removed request for a team March 10, 2026 20:14
Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

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

Thanks!

impl core::error::Error for Error {}

impl Error {
pub fn position(&self) -> u32 {
Copy link
Member

Choose a reason for hiding this comment

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

Could you add some docs to this method as well to indicate what the return value is? (e.g. a byte-offset from the start of the file)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. These are byte offsets but they're global to the source map (which holds many files), not just to the file itself.

@alexcrichton alexcrichton enabled auto-merge March 11, 2026 18:02
@alexcrichton alexcrichton added this pull request to the merge queue Mar 11, 2026
Merged via the queue into bytecodealliance:main with commit 599f7da Mar 11, 2026
36 checks passed
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