Skip to content

Commit

Permalink
[AVR][HACK][NO UPSTREAM] Disable debug printing of function pointers
Browse files Browse the repository at this point in the history
Workaround for #143.
  • Loading branch information
dylanmckay committed Jun 8, 2019
1 parent f8add73 commit 8b7240e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2624,14 +2624,14 @@ macro_rules! fnptr_impls_safety_abi {
#[stable(feature = "fnptr_impls", since = "1.4.0")]
impl<Ret, $($Arg),*> fmt::Pointer for $FnTy {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Pointer::fmt(&(*self as *const ()), f)
"disabled due to avr-rust/rust#143".fmt(f)
}
}

#[stable(feature = "fnptr_impls", since = "1.4.0")]
impl<Ret, $($Arg),*> fmt::Debug for $FnTy {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Pointer::fmt(&(*self as *const ()), f)
"disabled due to avr-rust/rust#143".fmt(f)
}
}
}
Expand Down

5 comments on commit 8b7240e

@ecstatic-morse
Copy link

@ecstatic-morse ecstatic-morse commented on 8b7240e Jun 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dylanmckay I might try *self as usize as *const () first. I think going direct to an integer will inhibit the addrspace cast.

@dylanmckay
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point @ecstatic-morse, I originally tried *self a *const $FnTy but it still introduced addrspacecasts.

I will try that.

@dylanmckay
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've applied

diff --git a/src/libcore/ptr/mod.rs b/src/libcore/ptr/mod.rs
index a04bb11311..caef99ca47 100644
--- a/src/libcore/ptr/mod.rs
+++ b/src/libcore/ptr/mod.rs
@@ -2631,14 +2631,14 @@ macro_rules! fnptr_impls_safety_abi {
         #[stable(feature = "fnptr_impls", since = "1.4.0")]
         impl<Ret, $($Arg),*> fmt::Pointer for $FnTy {
             fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-                "disabled due to avr-rust/rust#143".fmt(f)
+                fmt::Pointer::fmt(&(*self as usize as *const ()), f)
             }
         }
 
         #[stable(feature = "fnptr_impls", since = "1.4.0")]
         impl<Ret, $($Arg),*> fmt::Debug for $FnTy {
             fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-                "disabled due to avr-rust/rust#143".fmt(f)
+                fmt::Pointer::fmt(&(*self as usize as *const ()), f)
             }
         }
     }

and triggered a build. Let's see how this goes in the morning.

@dylanmckay
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have pushed it up to #144

@shepmaster
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From an end goal standpoint, will the numeric values of the addresses ever overlap? That is, will we ever print 0x1000/space0 and 0x1000/space1 as the same value? If so, that would rather suck from a debugging persepective.

Please sign in to comment.