Skip to content

Commit

Permalink
Fix a warning on no_std and the expected output for Result
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
schreter committed Feb 25, 2023
1 parent b11a622 commit a4c2566
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Binary file added src/.lib.rs.swp
Binary file not shown.
1 change: 1 addition & 0 deletions src/result.rs
Expand Up @@ -4,6 +4,7 @@
use alloc::boxed::Box;
use alloc::string::ToString;
use core::fmt::Display;
#[cfg(feature = "std")]
use core::mem::MaybeUninit;
use core::ptr::NonNull;
use core::slice;
Expand Down
18 changes: 14 additions & 4 deletions tests/ui/result_no_display.stderr
@@ -1,8 +1,18 @@
error[E0277]: `NonError` doesn't implement `std::fmt::Display`
error[E0599]: the method `to_cxx_exception` exists for reference `&NonError`, but its trait bounds were not satisfied
--> tests/ui/result_no_display.rs:4:19
|
4 | fn f() -> Result<()>;
| ^^^^^^^^^^ `NonError` cannot be formatted with the default formatter
| ^^^^^^^^^^ method cannot be called on `&NonError` due to unsatisfied trait bounds
...
8 | pub struct NonError;
| ------------------- doesn't satisfy `NonError: std::fmt::Display`
|
= help: the trait `std::fmt::Display` is not implemented for `NonError`
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
= note: the following trait bounds were not satisfied:
`NonError: std::fmt::Display`
which is required by `&NonError: ToCxxExceptionDefault`
note: the trait `std::fmt::Display` must be implemented
--> $RUST/core/src/fmt/mod.rs
|
| pub trait Display {
| ^^^^^^^^^^^^^^^^^
= 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 comments on commit a4c2566

Please sign in to comment.