History

rust: error: check for config `test` in `Error::name`

Additional to `testlib` also check for `test` in `Error::name`. This is required by a subsequent patch that (indirectly) uses `Error` in test cases.

Danilo Krummrich committed 2 years ago

Commit 4a28ab41 parent 29a48d21 file · +2 −2Browse files

Unified · Split

rust/kernel/error.rs+2−2
@@ -161,7 +161,7 @@ impl Error { · 160 unmodified lines
161161 }
162162
163163 /// Returns a string representing the error, if one exists.
164− #[cfg(not(testlib))]
164+ #[cfg(not(any(test, testlib)))]
165165 pub fn name(&self) -> Option<&'static CStr> {
166166 // SAFETY: Just an FFI call, there are no extra safety requirements.
167167 let ptr = unsafe { bindings::errname(-self.0.get()) };
@@ -178,7 +178,7 @@ impl Error { · 10 unmodified lines
178178 /// When `testlib` is configured, this always returns `None` to avoid the dependency on a
179179 /// kernel function so that tests that use this (e.g., by calling [`Result::unwrap`]) can still
180180 /// run in userspace.
181− #[cfg(testlib)]
181+ #[cfg(any(test, testlib))]
182182 pub fn name(&self) -> Option<&'static CStr> {
183183 None
184184 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t