Skip to content

Conversation

@cgettys-microsoft
Copy link
Contributor

@cgettys-microsoft cgettys-microsoft commented Sep 25, 2025

  • Add a 2-line utility method to MietteSpanContents - MietteSpanContents::with_name. You could easily do the same thing anyway, but it'd be pretty ugly today - make it easy.
  • Fix some tests under src/ not being gated under #[cfg(test)]. Yes, LTO would eliminate them at link time most likely, but still, may improve compile times downstream a bit, and definitely better cleanliness wise unless I'm missing something. I did add modules to contain the tests, but I can undo that part if you rather - the #[cfg(all(test, feature = ..)] bit is enough.
  • Improve discoverability of how SourceCode actually communicates the file name and language. This is well documented in the lib.rs docs on the index, but not super discoverable if you miss it there. I came across the comment on NamedSource that says SourceCode provides the name, and then looked at SourceCode looking for a trait method or something, and found nothing. So document in both those places. To be clear, I think the design is good - as it allows a SourceCode implementation to provide different names or languages for different spans, which can be useful in scenarios like a .md file containing a code block in another language - it just wasn't clear to me at first.
  • Also close Debug implementation for NamedSource missing call to .finish() #449 - call finish, replace the Ok(()) with returning the result of finish

Happy to split out this PR into 4 PRs if you prefer. Thanks for the awesome library!

@cgettys-microsoft
Copy link
Contributor Author

cgettys-microsoft commented Sep 26, 2025

I can't reproduce any of these failures either on main or on my branch on 1.88. The enum does look unused though.

I'll see if I can get rustup to install 1.70 and see if I can work out what's going on

@cgettys-microsoft
Copy link
Contributor Author

Ah wait, it's 1.90, not 1.70. Got it. Looks to be pre-existing, but let me see if I can lend a hand anyway :)

@cgettys-microsoft
Copy link
Contributor Author

This is getting strange.... fixing the "unnecessary" parantheses results in:
warning: error finalizing incremental compilation session directory\?\REPO_LOCATION_REMOVED\miette\target\debug\incremental\miette-0e64h1vlgbg44\s-hbgqkx5vnp-1q0dav7-working: Access is denied. (os error 5)

@cgettys-microsoft
Copy link
Contributor Author

cgettys-microsoft commented Sep 26, 2025

I fixed a few of the errors in PR #451

The one that happens if I remove the "unnecessary" parentheses remains baffling to me. I'm assuming it's a proc macro issue even though it's not giving a nice error message, and that the proc macro is not parsing expressions it needs to parse unless there are parens.
I just... can't quite work out where in the proc macro the issue is if so. I can of course just suppress the warning I guess... but that's unsatisfying.
Edit: looks like Windows Defender was just being uncooperative with certain Rustc versions... fun

@cgettys-microsoft
Copy link
Contributor Author

cgettys-microsoft commented Sep 26, 2025

This is now stacked on top of #451 and should pass CI, finally (pass on my fork: https://github.com/cgettys-microsoft/miette/actions/runs/18043812032). But given that #451 bumps MSRV and the like, that should probably be reviewed prior to merging this, and then this rebased? Up to you :)

@zkat zkat merged commit df7bcfa into zkat:main Sep 29, 2025
30 checks passed
@cgettys-microsoft cgettys-microsoft deleted the dev/chgettys/lvxkzkwlqoky branch September 30, 2025 00:18
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.

Debug implementation for NamedSource missing call to .finish()

2 participants