Skip to content

samples: inline windows_main.rs into main.rs - #4362

Merged
Kenny Kerr (kennykerr) merged 5 commits into
masterfrom
copilot/cleanup-bifurcated-code
May 1, 2026
Merged

samples: inline windows_main.rs into main.rs#4362
Kenny Kerr (kennykerr) merged 5 commits into
masterfrom
copilot/cleanup-bifurcated-code

Conversation

Copilot AI commented May 1, 2026

Copy link
Copy Markdown
Contributor
  • Refactor 42 sample crates: inline windows_main.rs body into main.rs wrapped in #[cfg(windows)] mod imp, delete windows_main.rs
  • Preserve crate-level inner attributes (e.g. core_app's #![cfg_attr(windows, windows_subsystem = "windows")])
  • Promote mod bindings; (in services/time and windows/webview) to crate root with #[cfg(windows)] so files resolve correctly
  • Clippy fixes for nightly: windows-core::imp::encode_pointer (not_unsafe_ptr_arg_deref) and HRESULT::message non-windows branch (needless_return)
  • Further simplification: collapse mod imp { use …; pub fn main(){…} } + fn main(){imp::main()} directly into #[cfg(windows)] fn main(){ use …; … }. Items declared inside mod imp (helper fns, #[implement] structs, impls) now live as nested items inside fn main and inherit its use statements.
    • fn main is not pub.
    • Return type chosen per-sample ((), windows::core::Result<()>, std::io::Result<()>) — fully qualified in the signature so it's resolvable without needing top-level use.
    • services/time and windows/webview: use super::bindings::*use crate::bindings::* (the inline fn main is at crate root, not inside a module).
    • direct3d12 keeps the mod imp shape: it contains a nested mod d3d12_hello_triangle { use super::*; } whose super cannot reach into a fn.
    • Removed two now-unused imports (core::* in device_watcher, core::Result in thread_pool_work).
  • cargo check --workspace (Linux) passes
  • cargo check --workspace --target x86_64-pc-windows-gnu passes (with --exclude test_no_std, which has an unrelated pre-existing duplicate-lang-item issue)
  • cargo fmt --all applied

Copilot AI and others added 2 commits May 1, 2026 13:24
Agent-Logs-Url: https://github.com/microsoft/windows-rs/sessions/6ef2a781-f2cf-4f7b-b14d-785227a50c1a

Co-authored-by: kennykerr <9845234+kennykerr@users.noreply.github.com>
@kennykerr
Kenny Kerr (kennykerr) merged commit 21e630c into master May 1, 2026
31 checks passed
@kennykerr
Kenny Kerr (kennykerr) deleted the copilot/cleanup-bifurcated-code branch May 1, 2026 15:42
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