-
-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can renderer of related errors (optionally) preserve source code? #99
Comments
This can be done pretty easily by using an error wrapper that "forwards" the Would that work for you? It seemed to work pretty well for engine-q. |
This means I should make a manual wrapper with a fn related<'a>(&'a self) -> Option<Box<dyn Iterator<Item = &'a dyn Diagnostic> + 'a>> {
Some(self.other.iter().map(|e| ErrorWrapper { source: &self.source, error: e }))
} But it's impossible to do as iterator should return a reference and I can not get a reference for the temporary object like above. So it will need to end up something like this: struct ParentError {
#[source_code]
source: Arc<String>,
#[related]
other: Vec<ErrorWrapper<ChildError>>,
} Still having an Arc to clone the source code into every error. |
The scenario is like:
I can use
Arc
to copy source code to every child error, but this is a bit inconvenient. Parsers usually only propagate byte range as a span so I have to either wrap every error into another wrapper having source code, or propagate some custom span that includesArc<SourceCode>
.Can handler propagate that source code while rendering or are there any big downsides of that?
The text was updated successfully, but these errors were encountered: