Skip to content

ICE when using + or - instead of named methods of Num #3790

Closed
@burg

Description

@burg

Test case: https://github.com/pcwalton/rust-geom/blob/master/rect.rs

This is really simple code. If any of the .add (say, in union or intersect) are changed to +, then compilation is terminated with an internal compiler error.

Activity

burg

burg commented on Oct 17, 2012

@burg
Author

This bug blocks progress on Servo's inline layout.

This seems to be triggered even without + or -. Either of the two (correct) Rect::union implementations below will ICE, while the (wrong) one linked above works:

    pure fn union(other: &Rect<T>) -> Rect<T> {   
        let upper_left = Point2D(min(self.origin.x, other.origin.x),
                                 min(self.origin.y, other.origin.y));

        let lower_right = Point2D(max(self.origin.x + self.size.width,
                                     other.origin.x + other.size.width,
                                  max(self.origin.y + self.size.height,
                                     other.origin.y + other.size.height));

        Rect {
            origin: upper_left,
            size: Size2D(lower_right.x - upper_left.x, lower_right.y - upper_left.y))
        }
    }

Also broken (all vars inlined, no + or -):

    pure fn union(other: &Rect<T>) -> Rect<T> {   
        Rect {
            origin: Point2D(min(self.origin.x, other.origin.x),
                            min(self.origin.y, other.origin.y)),
            size:   Size2D(max(self.origin.x.add(&self.size.width),
                               other.origin.x.add(&other.size.width).sub(&min(self.origin.x, other.origin.x))),
                           max(self.origin.y.add(&self.size.height),
                               other.origin.y.add(&other.size.height).sub(&min(self.origin.y, other.origin.y))))
        }
    }
burg

burg commented on Oct 17, 2012

@burg
Author

Servo is unblocked, but still changing any .add to + will cause an ICE.

added a commit that references this issue on Aug 5, 2024

Auto merge of rust-lang#3790 - RalfJung:ui-test-folder, r=RalfJung

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @burg@pcwalton

        Issue actions

          ICE when using + or - instead of named methods of Num · Issue #3790 · rust-lang/rust