Skip to content

Cargo Build gets stuck compiling my code #135050

Open

Description

@drewcassidy

While writing some code I wanted to see if it compiled, and instead cargo build just hung, either forever or longer than I was willing to late. It's a bug either way. I think I got it stuck in an infinite loop resolving traits

Code is here. I was editing mask.rs when I encountered the issue.

I think the problem code is

pub trait Maskable<T>: Copy {
    type Mask: Mask;

    fn set_masked<R: Splat<Self>>(&mut self, mask: Self::Mask, value: R);
}

impl<T, const N: usize> Maskable<T> for Col<T, N>
where
    T: Copy,
{
    type Mask = Col<bool, N>;

    fn set_masked<R: Splat<Self>>(&mut self, mask: Self::Mask, value: R) {
        let value: Self = value.splat();
        for (i, &m) in mask.iter().enumerate() {
            if m {
                self[i] = value[i]
            }
        }
    }
}

impl<S: Copy, T: Copy, const H: usize, const W: usize> Maskable<T> for Mat<S, W, H>
where
    Col<S, W>: Copy + Maskable<T>,
{
    type Mask = Col<Col<S, W>::Mask, H>;

    fn set_masked<R: Splat<Self>>(&mut self, mask: Self::Mask, value: R) {
        let value: Self = value.splat();
        for (i, &m) in mask.iter().enumerate() {
            self[i].set_masked(m, value[i]);
        }
    }
}

(this code is bad and wrong but it probably shouldn't do this)

I cant include a backtrace because Cargo never terminates

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jan 2, 2025
  2. theemathas commented on Jan 3, 2025

    @theemathas
    Contributor

    Could you provide the entire code that can be used to reproduce the bug? I tried some similar code and it compiled without any issues.

  3. added
    I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.
    S-needs-infoStatus: The issue lacks details necessary to triage or act on it.
    S-needs-reproStatus: This issue has no reproduction and needs a reproduction to make progress.
    and removed
    S-needs-infoStatus: The issue lacks details necessary to triage or act on it.
    on Jan 3, 2025
  4. drewcassidy commented on Jan 3, 2025

    @drewcassidy
    Author

    oops, meant to link that: drewcassidy/vector-victor@94abf34

  5. zachs18 commented on Jan 3, 2025

    @zachs18
    Contributor

    cargo build on that commit hangs on 1.83.0 stable, and errors on beta and nightly.

    Looks like #130654 turned this from a hang into an error?

  6. drewcassidy commented on Jan 3, 2025

    @drewcassidy
    Author

    Ah good to know, didn't think to try the new trait resolver.

  7. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jan 3, 2025
  8. clubby789 commented on Jan 3, 2025

    @clubby789
    Contributor

    Is this a regression, or should we close this as an intended error?

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

    C-bugCategory: This is a bug.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.S-needs-reproStatus: This issue has no reproduction and needs a reproduction to make progress.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions