Additional to `testlib` also check for `test` in `Error::name`. This is required by a subsequent patch that (indirectly) uses `Error` in test cases.
Showing the changes to rust/kernel (1 of 1 file). Show all
Unified · Split
| @@ -161,7 +161,7 @@ impl Error { · 160 unmodified lines | |||
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | /// Returns a string representing the error, if one exists. | 163 | /// Returns a string representing the error, if one exists. |
| 164 | #[cfg(not(testlib))] | 164 | #[cfg(not(any(test, testlib)))] |
| 165 | pub fn name(&self) -> Option<&'static CStr> { | 165 | pub fn name(&self) -> Option<&'static CStr> { |
| 166 | // SAFETY: Just an FFI call, there are no extra safety requirements. | 166 | // SAFETY: Just an FFI call, there are no extra safety requirements. |
| 167 | let ptr = unsafe { bindings::errname(-self.0.get()) }; | 167 | let ptr = unsafe { bindings::errname(-self.0.get()) }; |
| @@ -178,7 +178,7 @@ impl Error { · 10 unmodified lines | |||
| 178 | /// When `testlib` is configured, this always returns `None` to avoid the dependency on a | 178 | /// When `testlib` is configured, this always returns `None` to avoid the dependency on a |
| 179 | /// kernel function so that tests that use this (e.g., by calling [`Result::unwrap`]) can still | 179 | /// kernel function so that tests that use this (e.g., by calling [`Result::unwrap`]) can still |
| 180 | /// run in userspace. | 180 | /// run in userspace. |
| 181 | #[cfg(testlib)] | 181 | #[cfg(any(test, testlib))] |
| 182 | pub fn name(&self) -> Option<&'static CStr> { | 182 | pub fn name(&self) -> Option<&'static CStr> { |
| 183 | None | 183 | None |
| 184 | } | 184 | } |