File tree 1 file changed +14
-0
lines changed 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,20 @@ macro_rules! getsockopt_impl {
108
108
Errno :: result( res) ?;
109
109
110
110
match <$ty>:: try_from( getter. assume_init( ) ) {
111
+ // In most `getsockopt_impl!` implementations, `assume_init()`
112
+ // returns `$ty`, so calling `$ty`::try_from($ty) will always
113
+ // succeed. which makes the following `Err(_)` branch
114
+ // unreachable.
115
+ //
116
+ // However, there is indeed one exception, `sockopt::SockType`,
117
+ // `assume_init()` returns an `i32`, but `$ty` is `super::SockType`,
118
+ // this exception necessitates the use of that `try_from()`,
119
+ // and we have to allow the unreachable pattern wraning.
120
+ //
121
+ // For the reason why we are using `i32` as the underlying
122
+ // buffer type for this socket option, see issue:
123
+ // https://github.com/nix-rust/nix/issues/1819
124
+ #[ allow( unreachable_patterns) ]
111
125
Err ( _) => Err ( Errno :: EINVAL ) ,
112
126
Ok ( r) => Ok ( r) ,
113
127
}
You can’t perform that action at this time.
0 commit comments