Skip to content

windows-rdl writer: add writer_err! macro to reduce error construction boilerplate#4140

Merged
kennykerr merged 6 commits intomasterfrom
copilot/improve-error-reporting-writer
Apr 6, 2026
Merged

windows-rdl writer: add writer_err! macro to reduce error construction boilerplate#4140
kennykerr merged 6 commits intomasterfrom
copilot/improve-error-reporting-writer

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 5, 2026

The writer accumulated ~15 repetitions of Error::new(&format!("…"), "", 0, 0) — all writer errors have no source position (empty file, line 0, col 0), making the three trailing arguments pure noise.

Changes

  • writer/mod.rs — defines macro_rules! writer_err that wraps Error::new(&format!(…), "", 0, 0), then re-exports it with pub(crate) use writer_err so all sub-modules pick it up via their existing use super::*
  • callback.rs, class.rs, delegate.rs, enum.rs, fn.rs, mod.rs — replace all 15 bare Error::new(…, "", 0, 0) call sites with writer_err!(…); the two Error::new calls with non-empty file names are intentionally left untouched
  • tests/writer_errors.rs — fix two I/O failure tests that used /nonexistent/deeply/nested/… as an "unwritable" path; on Windows that resolves to C:\nonexistent\… which the CI runner can write to. Tests now create a regular temp file as a blocker and attempt to use it as a directory component — create_dir_all cannot replace a file with a directory on any platform.

Before:

return Err(Error::new(
    &format!("GuidAttribute d1: expected U32, got {v:?}"),
    "",
    0,
    0,
));

After:

return Err(writer_err!("GuidAttribute d1: expected U32, got {v:?}"));

Copilot AI and others added 3 commits April 4, 2026 19:19
… 0) boilerplate

Agent-Logs-Url: https://github.com/microsoft/windows-rs/sessions/f23c82e3-0137-49d3-a52f-5e6e6c9266d9

Co-authored-by: kennykerr <9845234+kennykerr@users.noreply.github.com>
@kennykerr
Copy link
Copy Markdown
Collaborator

@copilot fix build errors

…path (Windows CI fix)

Agent-Logs-Url: https://github.com/microsoft/windows-rs/sessions/bbedb6e3-feca-4013-b120-26dcf5eb2312

Co-authored-by: kennykerr <9845234+kennykerr@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 5, 2026

@copilot fix build errors

Fixed in 8de931b. The two failing tests (writer_returns_err_for_bad_output_path and writer_split_returns_err_for_bad_output_dir) used /nonexistent/deeply/nested/... as the "unwritable" path. On Linux that fails, but on Windows the path resolves to C:\nonexistent\... which the CI runner can write to. The tests now create a regular temp file as a "blocker" and try to use it as a directory — create_dir_all cannot replace a file with a directory on any platform.

Copilot AI requested a review from kennykerr April 5, 2026 03:00
@kennykerr kennykerr marked this pull request as ready for review April 5, 2026 22:31
@kennykerr kennykerr merged commit 948deee into master Apr 6, 2026
30 checks passed
@kennykerr kennykerr deleted the copilot/improve-error-reporting-writer branch April 6, 2026 15:36
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.

2 participants