File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 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 {
108108 Errno :: result( res) ?;
109109
110110 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) ]
111125 Err ( _) => Err ( Errno :: EINVAL ) ,
112126 Ok ( r) => Ok ( r) ,
113127 }
You can’t perform that action at this time.
0 commit comments