[librsvg: 1/2] (#757): Hack (?) to fix type inference on 32-bit builds




commit 66c0a47a5e84cfad987a68244cf94f1c590cebdb
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Jun 24 16:11:04 2021 -0500

    (#757): Hack (?) to fix type inference on 32-bit builds
    
    Sometimes when the build fails for whatever other reason, we get this:
    
    error[E0283]: type annotations needed
     --> src/rect.rs:126:26
        |
    126 |             self.width() == Zero::zero() || self.height() == Zero::zero()
        |                          ^^ cannot infer type
        |
        = note: cannot satisfy `i32: PartialEq<_>`
    
    as if type inference didn't work there.
    
    Now it seems to be recurrent on 32-bit builds.  No idea why.
    
    Hopefully fixes https://gitlab.gnome.org/GNOME/librsvg/-/issues/757
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/554>

 src/rect.rs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/src/rect.rs b/src/rect.rs
index da6829e2..a8325f17 100644
--- a/src/rect.rs
+++ b/src/rect.rs
@@ -123,7 +123,9 @@ mod rect {
     impl Rect<i32> {
         #[inline]
         pub fn is_empty(&self) -> bool {
-            self.width() == Zero::zero() || self.height() == Zero::zero()
+            // Give an explicit type to the right hand side of the ==, since sometimes
+            // type inference fails to figure it out.  I have no idea why.
+            self.width() == <i32 as Zero>::zero() || self.height() == <i32 as Zero>::zero()
         }
 
         #[inline]


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]