Skip to content
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

Don't override provided source code #300

Merged
merged 1 commit into from
Feb 4, 2024

Conversation

gavrilikhin-d
Copy link
Contributor

Fixes #299


use crate::{Diagnostic, LabeledSpan, Report, SourceCode, SourceSpan};

#[derive(Error, Debug)]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't use derive macro here. Looks like it always expands to miette::, instead of crate::. This may be fixed with $crate:: in macro implementation, I think

Copy link
Owner

Choose a reason for hiding this comment

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

This would be a good patch to have

Comment on lines +282 to +292
let underlined = String::from_utf8(
report
.source_code()
.unwrap()
.read_span(&(0..5).into(), 0, 0)
.unwrap()
.data()
.to_vec(),
)
.unwrap();
assert_eq!(underlined, "hello");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe there is a better way to check that sources are equal?

})
.with_source_code(outer_source.to_string());

let message = format!("{:?}", report);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Debug printing without fancy feature is broken

@zkat zkat merged commit 0d5c2ce into zkat:main Feb 4, 2024
11 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.

Report::with_source_code overrides already provided source code
2 participants