Improve error messages received from Cranelift #583
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed in bytecodealliance/cranelift#1226, the context of Cranelift errors is lost after exiting the scope containing the Cranelift function.
CodegenErrorthen only contains something likeinst2: arg 0 (v4) has type i16x8, expected i8x16, which is rarely enough information for investigating a codegen failure. This change uses Cranelift'spretty_errorfunction to improve the error messages wrapped inCompileError;CompileErrorhas lost the reference toCodegenErrordue topretty_errortaking ownership but this seems preferable since no backtrace is attached and losing the pretty-printed context would be worse (ifCodegenErrorgains aBacktraceor implementsClonewe can revisit this).