Skip to content

Commit bb68c92

Browse files
committed
Fix a warning on no_std and the expected output for Result
Since invalid `Result<T>` output changed, the expected file had to be updated. The output actually got better, since now the location of the actual declaration of the offending struct is also shown, not only the usage.
1 parent b11a622 commit bb68c92

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/.lib.rs.swp

16 KB
Binary file not shown.

src/result.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use alloc::boxed::Box;
55
use alloc::string::ToString;
66
use core::fmt::Display;
7+
#[cfg(feature = "std")]
78
use core::mem::MaybeUninit;
89
use core::ptr::NonNull;
910
use core::slice;

tests/ui/result_no_display.stderr

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
error[E0277]: `NonError` doesn't implement `std::fmt::Display`
1+
error[E0599]: the method `to_cxx_exception` exists for reference `&NonError`, but its trait bounds were not satisfied
22
--> tests/ui/result_no_display.rs:4:19
33
|
44
4 | fn f() -> Result<()>;
5-
| ^^^^^^^^^^ `NonError` cannot be formatted with the default formatter
5+
| ^^^^^^^^^^ method cannot be called on `&NonError` due to unsatisfied trait bounds
6+
...
7+
8 | pub struct NonError;
8+
| ------------------- doesn't satisfy `NonError: std::fmt::Display`
69
|
7-
= help: the trait `std::fmt::Display` is not implemented for `NonError`
8-
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
10+
= note: the following trait bounds were not satisfied:
11+
`NonError: std::fmt::Display`
12+
which is required by `&NonError: ToCxxExceptionDefault`
13+
note: the trait `std::fmt::Display` must be implemented
14+
--> $RUST/core/src/fmt/mod.rs
15+
= note: this error originates in the macro `::cxx::map_rust_error_to_cxx_exception` (in Nightly builds, run with -Z macro-backtrace for more info)

0 commit comments

Comments
 (0)