-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
cyclic trait inheritance leads to a rustc stack overflow #12511
Comments
I would expect an error message. |
Yeah, I think we need to be checking for logical cycles in a lot of places. |
cc me and #5527 |
cc me |
This is related to the work on trait-reform and where clauses, actually. The immediate cause for this is that typeck's collect phase attempts to gather both the bounds and the set of type parameters in one step. It should do a first-pass that just collects, for each nominal type, what its type parameter names are. Then a second pass to gather bounds. This is natural with where clauses. The next problem will occur when gathering up "implied" trait bounds -- if we're not careful, we'll get a cycle there too, as we go from A to B and back again. But we can patch that too, both by checking for recursion and reporting an error (no matter what), but also by seeing if we've already visited one of the type-trait-pairs and avoiding recursion in that case (this would allow us to reach a fixed point). |
I'll fix this soon. |
This no longer reproduces: $ rustc main.rs
main.rs:1:1: 2:2 error: unsupported cyclic reference between types/traits detected
main.rs:1 trait t1 : t2 {
main.rs:2 }
note: the cycle begins when computing the supertraits of `t1`...
note: ...which then requires computing the supertraits of `t2`...
note: ...which then again requires computing the supertraits of `t1`, completing the cycle.
main.rs:3:1: 4:2 error: unsupported cyclic reference between types/traits detected
main.rs:3 trait t2 : t1 {
main.rs:4 }
note: the cycle begins when computing the supertraits of `t2`...
note: ...which then requires computing the supertraits of `t1`...
note: ...which then again requires computing the supertraits of `t2`, completing the cycle.
error: aborting due to 2 previous errors |
…r=Alexendoo `assigning_clones` should respect MSRV Fixes: rust-lang#12502 This PR fixes the `assigning_clones` lint suggesting to use `clone_from` or `clone_into` on incompatible MSRVs. `assigning_clones` will suggest using either `clone_from` or `clone_into`, both of which were stabilized in 1.63. If the current MSRV is below 1.63, the lint should not trigger. changelog: [`assigning_clones`]: don't lint when the MSRV is below 1.63.
…r=Alexendoo Make `assigning_clones` MSRV check more precise Continuation of rust-lang#12511 `clone_into` is the only suggestion subject to the 1.63 MSRV requirement, and the lint should still emit other suggestions regardless of the MSRV. changelog: [assigning_clones]: only apply MSRV check to `clone_into` suggestions.
or even
gives a stack overflow:
task 'rustc' has overflowed its stack
./build.sh: line 1: 22351 Illegal instruction (core dumped) /home/nick/rust2/x86_64-unknown-linux-gnu/stage1/bin/rustc $1.rs -o $1
The text was updated successfully, but these errors were encountered: