From 53db83709e0f436a4f5f179dd92bed23bbb7f5d2 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 31 May 2025 17:00:11 -0700 Subject: [PATCH 1/4] Unwrap windows_subsystem --- src/runtime.md | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/runtime.md b/src/runtime.md index f6ffb8b1d..a67644de3 100644 --- a/src/runtime.md +++ b/src/runtime.md @@ -13,24 +13,19 @@ r[runtime.windows_subsystem] ## The `windows_subsystem` attribute r[runtime.windows_subsystem.intro] -The *`windows_subsystem` attribute* may be applied at the crate level to set -the [subsystem] when linking on a Windows target. +The *`windows_subsystem` attribute* may be applied at the crate level to set the [subsystem] when linking on a Windows target. r[runtime.windows_subsystem.syntax] -It uses the [MetaNameValueStr] syntax to specify the subsystem with a value of either -`console` or `windows`. +It uses the [MetaNameValueStr] syntax to specify the subsystem with a value of either `console` or `windows`. r[runtime.windows_subsystem.ignored] This attribute is ignored on non-Windows targets, and for non-`bin` [crate types]. r[runtime.windows_subsystem.console] -The "console" subsystem is the default. If a console process is run from an -existing console then it will be attached to that console, otherwise a new -console window will be created. +The "console" subsystem is the default. If a console process is run from an existing console then it will be attached to that console, otherwise a new console window will be created. r[runtime.windows_subsystem.windows] -The "windows" subsystem is commonly used by GUI applications that do not want to -display a console window on startup. It will run detached from any existing console. +The "windows" subsystem is commonly used by GUI applications that do not want to display a console window on startup. It will run detached from any existing console. ```rust #![windows_subsystem = "windows"] From 080aa1ebb49f7319f6ab09f66be845da7451f952 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 31 May 2025 17:00:45 -0700 Subject: [PATCH 2/4] Move windows_subsystem example to the intro --- src/runtime.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/runtime.md b/src/runtime.md index a67644de3..0a27c633f 100644 --- a/src/runtime.md +++ b/src/runtime.md @@ -15,6 +15,11 @@ r[runtime.windows_subsystem] r[runtime.windows_subsystem.intro] The *`windows_subsystem` attribute* may be applied at the crate level to set the [subsystem] when linking on a Windows target. +> [!EXAMPLE] +> ```rust +> #![windows_subsystem = "windows"] +> ``` + r[runtime.windows_subsystem.syntax] It uses the [MetaNameValueStr] syntax to specify the subsystem with a value of either `console` or `windows`. @@ -27,10 +32,6 @@ The "console" subsystem is the default. If a console process is run from an exis r[runtime.windows_subsystem.windows] The "windows" subsystem is commonly used by GUI applications that do not want to display a console window on startup. It will run detached from any existing console. -```rust -#![windows_subsystem = "windows"] -``` - [`GlobalAlloc`]: alloc::alloc::GlobalAlloc [crate types]: linkage.md [static item]: items/static-items.md From 987ab56f646c572739b1a63c6085a6829a1a7263 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 31 May 2025 17:05:58 -0700 Subject: [PATCH 3/4] Update windows_subsystem to use the attribute template --- src/runtime.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/runtime.md b/src/runtime.md index 0a27c633f..e4e629f72 100644 --- a/src/runtime.md +++ b/src/runtime.md @@ -13,7 +13,7 @@ r[runtime.windows_subsystem] ## The `windows_subsystem` attribute r[runtime.windows_subsystem.intro] -The *`windows_subsystem` attribute* may be applied at the crate level to set the [subsystem] when linking on a Windows target. +The *`windows_subsystem` [attribute][attributes]* sets the [subsystem] when linking on a Windows target. > [!EXAMPLE] > ```rust @@ -21,10 +21,19 @@ The *`windows_subsystem` attribute* may be applied at the crate level to set the > ``` r[runtime.windows_subsystem.syntax] -It uses the [MetaNameValueStr] syntax to specify the subsystem with a value of either `console` or `windows`. +The `windows_subsystem` attribute uses the [MetaNameValueStr] syntax to specify the subsystem with a value of either `console` or `windows`. + +r[runtime.windows_subsystem.allowed-positions] +The `windows_subsystem` attribute may only be applied to the crate root. + +r[runtime.windows_subsystem.duplicates] +Only the first instance of `windows_subsystem` on an item is honored. Subsequent `example` attributes are ignored. + +> [!NOTE] +> `rustc` currently warns on subsequent duplicate `example` attributes. This may become an error in the future. r[runtime.windows_subsystem.ignored] -This attribute is ignored on non-Windows targets, and for non-`bin` [crate types]. +The `windows_subsystem` attribute is ignored on non-Windows targets, and for non-`bin` [crate types]. r[runtime.windows_subsystem.console] The "console" subsystem is the default. If a console process is run from an existing console then it will be attached to that console, otherwise a new console window will be created. From a239b4b6c2a4acc7288c8b151bcf22d4be52c7a1 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Sun, 10 Aug 2025 14:10:28 +0000 Subject: [PATCH 4/4] Revise `windows_subsystem` text --- src/runtime.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/runtime.md b/src/runtime.md index e4e629f72..87b348cd0 100644 --- a/src/runtime.md +++ b/src/runtime.md @@ -21,25 +21,28 @@ The *`windows_subsystem` [attribute][attributes]* sets the [subsystem] when link > ``` r[runtime.windows_subsystem.syntax] -The `windows_subsystem` attribute uses the [MetaNameValueStr] syntax to specify the subsystem with a value of either `console` or `windows`. +The `windows_subsystem` attribute uses the [MetaNameValueStr] syntax. Accepted values are `"console"` and `"windows"`. r[runtime.windows_subsystem.allowed-positions] The `windows_subsystem` attribute may only be applied to the crate root. r[runtime.windows_subsystem.duplicates] -Only the first instance of `windows_subsystem` on an item is honored. Subsequent `example` attributes are ignored. +Only the first use of `windows_subsystem` is honored. > [!NOTE] -> `rustc` currently warns on subsequent duplicate `example` attributes. This may become an error in the future. +> `rustc` currently lints against uses following the first. This may become a hard error in the future. r[runtime.windows_subsystem.ignored] -The `windows_subsystem` attribute is ignored on non-Windows targets, and for non-`bin` [crate types]. +The `windows_subsystem` attribute is ignored on non-Windows targets and non-`bin` [crate types]. r[runtime.windows_subsystem.console] -The "console" subsystem is the default. If a console process is run from an existing console then it will be attached to that console, otherwise a new console window will be created. +The `"console"` subsystem is the default. If a console process is run from an existing console then it will be attached to that console; otherwise a new console window will be created. r[runtime.windows_subsystem.windows] -The "windows" subsystem is commonly used by GUI applications that do not want to display a console window on startup. It will run detached from any existing console. +The `"windows"` subsystem will run detached from any existing console. + +> [!NOTE] +> The `"windows"` subsystem is commonly used by GUI applications that do not want to display a console window on startup. [`GlobalAlloc`]: alloc::alloc::GlobalAlloc [crate types]: linkage.md