New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simple Display
impl doesn't render full output
#153
Comments
Wow, strange bug -- possible sources I think: syscall, memory allocator, RISC-V to NVM translation |
Thanks for the leads. Sam offered some tips too. It occurred to me I hadn't tried simplifying the @@ -7,11 +7,11 @@ use alloc::string::ToString;
use core::fmt::Display;
use nexus_rt::Write;
-struct Parens(u8);
+struct Parens;
impl Display for Parens {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
- write!(f, "({})", self.0)
+ write!(f, "({})", 0u8)
}
}
@@ -27,7 +27,7 @@ impl Display for Parens {
#[nexus_rt::main]
fn main() {
- let x = Parens(0);
+ let x = Parens;
// as expected, prints `(0)`
nexus_rt::println!("{}", x); I can look into this more and try to isolate the fault. Assigning to myself. |
Found some more clues with the help of Output without workaroundHere the first
Output with workaroundAnd when the aforementioned workaround is applied,
I also notice the |
I made some minor changes to the program in 0e1a90d to facilitate debugging, like adding more Full outputs are available in 4dacede. Excerpt of
|
TLDR: See the minimal example in 41d2649 on the
display-bug
branch and the following repro steps:$ git checkout display-bug $ cargo build --release --package nexus-tools --bin cargo-nexus $ cd examples $ ../target/release/cargo-nexus nexus run --bin display_bug (0) (0 PANIC
This
Display
impl doesn't render the trailing)
as expected when using the.to_string()
method.I'm unclear yet why the
.to_string()
method in particular doesn't work as expected yetnexus_rt::println!("{}", x);
does. I'm also not sure how to write the assertion without.to_string()
.Workaround
Using this
Display
implementation instead is apparently a viable workaround.The text was updated successfully, but these errors were encountered: