Skip to content

Make naga span methods take path as generic AsRef Path #7643

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

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

atlv24
Copy link
Collaborator

@atlv24 atlv24 commented Apr 28, 2025

Connections
none

Description
These methods dont match naga/src/front/wgsl/error.rs and are harder to use than them.

Testing
It compiles.

Squash or Rebase?

Doesn't matter

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy --tests. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo xtask test to run tests.
  • If this contains user-facing changes, add a CHANGELOG.md entry.

Copy link
Member

@ErichDonGubler ErichDonGubler left a comment

Choose a reason for hiding this comment

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

lgtm yo

…minus a teeny nit. 🙂 Approving conditional on resolution.

Copy link
Member

@ErichDonGubler ErichDonGubler left a comment

Choose a reason for hiding this comment

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

Ahhh, but wait, just checked CI failures. The Windows one looks spurious, but the wasm32 build failure is a problem. These APIs exposed in no_std environments; no_std means no std::path::Path1. 💦 We need to resolve this conflict to proceed.

😐 Sorry for the whiplash!

Footnotes

  1. That seems counter-intuitive with the stderr name—CC @bushrat011899!

@@ -283,12 +283,14 @@ impl<E> WithSpan<E> {

/// Emits a summary of the error to standard error stream.
#[cfg(feature = "stderr")]
pub fn emit_to_stderr_with_path(&self, source: &str, path: &str)
pub fn emit_to_stderr_with_path<P>(&self, source: &str, path: P)
Copy link
Member

Choose a reason for hiding this comment

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

issue: We should add a CHANGELOG entry.

@bushrat011899
Copy link
Contributor

Re. no_std: I've created a little Gist here that I think solves the issue quite cleanly. The idea is to create a new trait, AsPath, which exposes the methods you need (e.g., to_string_lossy) and either:

  • Blanket implement for anything implementing AsRef<Path> when std is available; or
  • Specifically implement for the subset of types that implement AsRef<Path> but are available without std (e.g., String and str).

This ensures the std feature is still additive and gives the same ergonomic benefit to std users, and gives a lesser (but still positive) boost to no_std too.

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.

3 participants