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 2
2
rustflags = [
3
3
# "--cfg", "windows_debugger_visualizer",
4
4
# "--cfg", "windows_raw_dylib",
5
+ # "--cfg", "windows_slim_errors",
5
6
# "-C", "target-feature=+crt-static",
6
7
]
Original file line number Diff line number Diff line change 29
29
run : cargo check -p windows-result --all-features
30
30
- name : Check Default Features
31
31
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
21
21
default-target = " x86_64-pc-windows-msvc"
22
22
targets = []
23
23
24
- [dependencies ]
25
- static_assertions = " 1.0"
26
-
27
24
[dependencies .windows-targets ]
28
25
version = " 0.52.5"
29
26
path = " ../targets"
Original file line number Diff line number Diff line change @@ -257,8 +257,6 @@ impl Ord for Error {
257
257
}
258
258
}
259
259
260
- static_assertions:: assert_impl_all!( Error : Send , Sync ) ;
261
-
262
260
use error_info:: * ;
263
261
264
262
#[ cfg( all( windows, not( windows_slim_errors) ) ) ]
@@ -395,11 +393,4 @@ mod error_info {
395
393
core:: ptr:: null_mut ( )
396
394
}
397
395
}
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
- ) ;
405
396
}
Original file line number Diff line number Diff line change @@ -36,6 +36,3 @@ pub use hresult::HRESULT;
36
36
37
37
/// A specialized [`Result`] type that provides Windows error information.
38
38
pub 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"
16
16
17
17
[dependencies ]
18
18
helpers = { 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() {
24
24
25
25
let e = Error :: new ( E_INVALIDARG , "test message" ) ;
26
26
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
+ }
29
35
}
30
36
31
37
#[ test]
Original file line number Diff line number Diff line change @@ -80,7 +80,12 @@ fn from_result() {
80
80
let result: Result < ( ) > = Err ( Error :: new ( E_INVALIDARG , "test message" ) ) ;
81
81
let err = HRESULT :: from ( result) . ok ( ) . unwrap_err ( ) ;
82
82
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
+ }
84
89
}
85
90
86
91
#[ test]
You can’t perform that action at this time.
0 commit comments