Skip to content
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

Cargo Build gets stuck compiling my code #135050

Open
drewcassidy opened this issue Jan 2, 2025 · 5 comments
Open

Cargo Build gets stuck compiling my code #135050

drewcassidy opened this issue Jan 2, 2025 · 5 comments
Labels
C-bug Category: This is a bug. I-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress.

Comments

@drewcassidy
Copy link

drewcassidy commented Jan 2, 2025

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

@drewcassidy drewcassidy added the C-bug Category: This is a bug. label Jan 2, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 2, 2025
@theemathas
Copy link
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.

@clubby789 clubby789 added I-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. S-needs-info Status: The issue lacks details necessary to triage or act on it. S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. and removed S-needs-info Status: The issue lacks details necessary to triage or act on it. labels Jan 3, 2025
@drewcassidy
Copy link
Author

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

@zachs18
Copy link
Contributor

zachs18 commented Jan 3, 2025

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?

@drewcassidy
Copy link
Author

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

@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 3, 2025
@clubby789
Copy link
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
Labels
C-bug Category: This is a bug. I-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress.
Projects
None yet
Development

No branches or pull requests

6 participants