Skip to content

mutually referential traits cause infinite recursion in rustc #9817

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

Closed
dcrewi opened this issue Oct 12, 2013 · 1 comment
Closed

mutually referential traits cause infinite recursion in rustc #9817

dcrewi opened this issue Oct 12, 2013 · 1 comment

Comments

@dcrewi
Copy link
Contributor

dcrewi commented Oct 12, 2013

The offending code:

trait A<T: B<Self>> {}
trait B<T: A<Self>> {}

pub fn main() {
}

The gdb backtrace looks like the compiler recursing endlessly until it hits some stack size limit.

[omitting repetitions]
#17104 0x00007ffff616b4aa in middle::typeck::collect::trait_def_of_item::h61bb7c944e35871ca9::v0.9$x2dpre () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.9-pre.so
#17105 0x00007ffff615224a in middle::typeck::collect::get_trait_def::h87abf4c14526775as::v0.9$x2dpre () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.9-pre.so
#17106 0x00007ffff6156d50 in middle::typeck::astconv::ast_path_to_trait_ref::h49ff12f26c22e54fa0::v0.9$x2dpre ()
   from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.9-pre.so
#17107 0x00007ffff6165276 in middle::typeck::collect::instantiate_trait_ref::had78f9fdcce09feaU::v0.9$x2dpre ()
   from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.9-pre.so
#17108 0x00007ffff61738fd in middle::typeck::collect::ty_generics::compute_bounds::hcb86b3308d74d51baG::v0.9$x2dpre ()
   from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.9-pre.so
#17109 0x00007ffff61607d3 in middle::typeck::collect::ty_generics::h264e3285aeb97c4caA::v0.9$x2dpre () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.9-pre.so
#17110 0x00007ffff616bb4a in middle::typeck::collect::mk_item_substs::h3b85d67131af11faG::v0.9$x2dpre () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.9-pre.so
#17111 0x00007ffff616b4aa in middle::typeck::collect::trait_def_of_item::h61bb7c944e35871ca9::v0.9$x2dpre () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.9-pre.so

*** here is where the cycle begins ***

#17112 0x00007ffff614aeec in middle::typeck::collect::convert::hf12338bf4af8fd6aO::v0.9$x2dpre () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.9-pre.so
#17113 0x00007ffff6149aab in middle::typeck::collect::Visitor$CollectItemTypesVisitor::visit_item::hb81cd925e312c3c5UFaW::v0.9$x2dpre ()
   from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.9-pre.so
#17114 0x00007ffff614f0ee in middle::typeck::collect::collect_item_types::ha47316e9329a9b19at::v0.9$x2dpre () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.9-pre.so
#17115 0x00007ffff618712c in util::common::time::hffc0442c9653491aao::v0.9$x2dpre ()
   from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.9-pre.so
#17116 0x00007ffff6186c88 in middle::typeck::check_crate::h6e4aa652a1ea891aL::v0.9$x2dpre () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.9-pre.so
#17117 0x00007ffff642cd0a in driver::driver::phase_3_run_analysis_passes::h405af92a1617ff5ba5::v0.9$x2dpre () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.9-pre.so
#17118 0x00007ffff6430158 in driver::driver::compile_input::h6d55a4e9e4fea194ao::v0.9$x2dpre () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.9-pre.so
#17119 0x00007ffff6453583 in run_compiler::h47b2e3227fef69eeaR::v0.9$x2dpre ()
   from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.9-pre.so
#17120 0x00007ffff6465c79 in main_args::anon::expr_fn::aw ()
   from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.9-pre.so
#17121 0x00007ffff646429d in monitor::anon::expr_fn::aO ()
   from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.9-pre.so
#17122 0x00007ffff6461bfe in task::TaskBuilder::try::anon::expr_fn::ova2a5 ()
   from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.9-pre.so
#17123 0x00007ffff770c6e5 in task::spawn::spawn_raw::anon::expr_fn::am ()
   from /usr/local/bin/../lib/libstd-6c65cf4b443341b1-0.9-pre.so
#17124 0x00007ffff775456e in rt::task::__extensions__::build_start_wrapper::anon::anon::expr_fn::aH () from /usr/local/bin/../lib/libstd-6c65cf4b443341b1-0.9-pre.so
#17125 0x00007ffff7752e44 in rt::task::__extensions__::run::anon::expr_fn::aS ()
   from /usr/local/bin/../lib/libstd-6c65cf4b443341b1-0.9-pre.so
#17126 0x00007ffff5a1cbe3 in rust_try () from /usr/local/bin/../lib/librustrt.so
#17127 0x00007ffff7752be3 in rt::task::Task::run::h199ab8d6eb226980fIaP::v0.9$x2dpre
    () from /usr/local/bin/../lib/libstd-6c65cf4b443341b1-0.9-pre.so
#17128 0x00007ffff775423a in rt::task::__extensions__::build_start_wrapper::anon::expr_fn::ay () from /usr/local/bin/../lib/libstd-6c65cf4b443341b1-0.9-pre.so
#17129 0x0000000000000000 in ?? ()

The compiler was built from 0.8-416-gc147ec6

@pnkfelix
Copy link
Member

duplicate of #8762.

flip1995 pushed a commit to flip1995/rust that referenced this issue Nov 21, 2022
Update lint example for `collapsible_str_replace`

To fix this warning:
```
warning: the borrowed expression implements the required traits
  --> src/fixes/quote_character.rs:16:43
   |
16 |         let hello = "hesuo worpd".replace(&['s', 'u', 'p'], "l");
   |                                           ^^^^^^^^^^^^^^^^ help: change this to: `['s', 'u', 'p']`
   |
   = note: `#[warn(clippy::needless_borrow)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
```

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants