File tree Expand file tree Collapse file tree 11 files changed +71
-46
lines changed Expand file tree Collapse file tree 11 files changed +71
-46
lines changed Original file line number Diff line number Diff line change 22rustflags = [
33 # "--cfg", "windows_debugger_visualizer",
44 # "--cfg", "windows_raw_dylib",
5+ # "--cfg", "windows_slim_errors",
56 # "-C", "target-feature=+crt-static",
67]
Original file line number Diff line number Diff line change 2929 run : cargo check -p windows-result --all-features
3030 - name : Check Default Features
3131 run : cargo check -p windows-result
32- - name : Check Slim Errors
33- shell : pwsh
34- run : |
35- $ErrorActionPreference = 'Stop'
36- $env:RUSTFLAGS = '--cfg=windows_slim_errors'
37-
38- # This will show the size of Error, which lets us confirm that RUSTFLAGS was set.
39- cargo test -p windows-result --lib -- --nocapture --test-threads=1
40-
41- cargo check -p windows-result
Original file line number Diff line number Diff line change 1+ name : slim_errors
2+
3+ on :
4+ pull_request :
5+ push :
6+ paths-ignore :
7+ - ' .github/ISSUE_TEMPLATE/**'
8+ branches :
9+ - master
10+
11+ env :
12+ RUSTFLAGS : -Dwarnings --cfg windows_slim_errors
13+
14+ jobs :
15+ check :
16+ strategy :
17+ matrix :
18+ include :
19+ - target : x86_64-pc-windows-msvc
20+ - target : i686-pc-windows-msvc
21+ - target : x86_64-pc-windows-gnu
22+ - target : i686-pc-windows-gnu
23+ runs-on :
24+ - windows-latest
25+ runs-on : ${{ matrix.runs-on }}
26+ steps :
27+ - name : Checkout
28+ uses : actions/checkout@v4
29+
30+ - name : Update toolchain
31+ run : rustup update --no-self-update nightly && rustup default nightly-${{ matrix.target }}
32+
33+ - name : Add toolchain target
34+ run : rustup target add ${{ matrix.target }}
35+
36+ - name : Fix environment
37+ uses : ./.github/actions/fix-environment
38+
39+ - name : Test
40+ run : cargo test -p test_result
Original file line number Diff line number Diff line change @@ -21,9 +21,6 @@ workspace = true
2121default-target = " x86_64-pc-windows-msvc"
2222targets = []
2323
24- [dependencies ]
25- static_assertions = " 1.0"
26-
2724[dependencies .windows-targets ]
2825version = " 0.52.5"
2926path = " ../targets"
Original file line number Diff line number Diff line change @@ -257,8 +257,6 @@ impl Ord for Error {
257257 }
258258}
259259
260- static_assertions:: assert_impl_all!( Error : Send , Sync ) ;
261-
262260use error_info:: * ;
263261
264262#[ cfg( all( windows, not( windows_slim_errors) ) ) ]
@@ -395,11 +393,4 @@ mod error_info {
395393 core:: ptr:: null_mut ( )
396394 }
397395 }
398-
399- // If we are using "slim" Error objects, then we can rely on Result<()>
400- // having a representation that is equivalent to HRESULT.
401- static_assertions:: const_assert_eq!(
402- size_of:: <core:: result:: Result <( ) , Error >>( ) ,
403- size_of:: <HRESULT >( )
404- ) ;
405396}
Original file line number Diff line number Diff line change @@ -36,6 +36,3 @@ pub use hresult::HRESULT;
3636
3737/// A specialized [`Result`] type that provides Windows error information.
3838pub type Result < T > = core:: result:: Result < T , Error > ;
39-
40- #[ cfg( test) ]
41- mod tests;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -16,3 +16,7 @@ path = "../../libs/targets"
1616
1717[dependencies ]
1818helpers = { package = " test_helpers" , path = " ../helpers" }
19+ static_assertions = " 1.0"
20+
21+ [lints .rust ]
22+ unexpected_cfgs = { level = " warn" , check-cfg = [' cfg(windows_slim_errors)' ] }
Original file line number Diff line number Diff line change @@ -24,8 +24,14 @@ fn new() {
2424
2525 let e = Error :: new ( E_INVALIDARG , "test message" ) ;
2626 assert_eq ! ( e. code( ) , E_INVALIDARG ) ;
27- assert ! ( !e. as_ptr( ) . is_null( ) ) ;
28- assert_eq ! ( e. message( ) , "test message" ) ;
27+
28+ if cfg ! ( windows_slim_errors) {
29+ assert ! ( e. as_ptr( ) . is_null( ) ) ;
30+ assert_eq ! ( e. message( ) , "The parameter is incorrect." ) ;
31+ } else {
32+ assert ! ( !e. as_ptr( ) . is_null( ) ) ;
33+ assert_eq ! ( e. message( ) , "test message" ) ;
34+ }
2935}
3036
3137#[ test]
Original file line number Diff line number Diff line change @@ -80,7 +80,12 @@ fn from_result() {
8080 let result: Result < ( ) > = Err ( Error :: new ( E_INVALIDARG , "test message" ) ) ;
8181 let err = HRESULT :: from ( result) . ok ( ) . unwrap_err ( ) ;
8282 assert_eq ! ( err. code( ) , E_INVALIDARG ) ;
83- assert_eq ! ( err. message( ) , "test message" ) ;
83+
84+ if cfg ! ( windows_slim_errors) {
85+ assert_eq ! ( err. message( ) , "The parameter is incorrect." ) ;
86+ } else {
87+ assert_eq ! ( err. message( ) , "test message" ) ;
88+ }
8489}
8590
8691#[ test]
You can’t perform that action at this time.
0 commit comments