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

assertion failed: !projection_ty.has_escaping_regions() from astconv #27901

Closed
arielb1 opened this issue Aug 19, 2015 · 8 comments
Closed

assertion failed: !projection_ty.has_escaping_regions() from astconv #27901

arielb1 opened this issue Aug 19, 2015 · 8 comments
Assignees
Labels
A-trait-system Area: Trait system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@arielb1
Copy link
Contributor

arielb1 commented Aug 19, 2015

STR

trait Stream { type Item; }
impl<'a> Stream for &'a str { type Item = char; }
fn f<'s>(_: &'s str) -> (&'s str, <&'s str as Stream>::Item) { loop {}}
fn main() {
    f as for<'t> fn(&'t str) -> (&'t str, <&'t str as Stream>::Item);
}

ICE

thread 'rustc' panicked at 'assertion failed: !projection_ty.has_escaping_regions()', ../src/librustc/middle/traits/fulfill.rs:142

stack backtrace:
   1:     0x7fb374005821 - sys::backtrace::write::h1f94a55df3f5c060tAs
                        at ../src/libstd/sys/unix/backtrace.rs:157
   2:     0x7fb374036dc2 - panicking::on_panic::h7395b54848e3e9ccyEx
                        at ../src/libstd/panicking.rs:45
   3:     0x7fb373f65456 - rt::unwind::begin_unwind_inner::hcaa18d84671dc6f1P5w
                        at ../src/libstd/rt/unwind/mod.rs:283
   4:     0x7fb370893b6c - rt::unwind::begin_unwind::h6172101820686538617
                        at ../src/libstd/rt/unwind/mod.rs:236
   5:     0x7fb3710fe472 - middle::traits::fulfill::FulfillmentContext<'tcx>::normalize_projection_type::hcf70e505dec3d2592IR
                        at /home/ariel/Rust/source.arielb1/build/<std macros>:3
   6:     0x7fb37350c4d0 - check::FnCtxt<'a, 'tcx>::normalize_associated_type::h1b069930cbf0a459JOo
                        at ../src/librustc_typeck/check/mod.rs:1370
   7:     0x7fb3734b4be9 - check::FnCtxt<'a, 'tcx>.AstConv<'tcx>::projected_ty::h36429f32ac9a3fffjuo
                        at ../src/librustc_typeck/check/mod.rs:1186
   8:     0x7fb373624429 - astconv::qpath_to_ty::h71e2ea7f4506a5a6DCv
                        at ../src/librustc_typeck/astconv.rs:1337
   9:     0x7fb373625635 - astconv::base_def_to_ty::h2f321ee71a45c0e11Hv
                        at ../src/librustc_typeck/astconv.rs:1441
  10:     0x7fb3735c9a3e - astconv::finish_resolving_def_to_ty::h34ff71956713a7572Nv
                        at ../src/librustc_typeck/astconv.rs:1494
  11:     0x7fb37351caaa - astconv::ast_ty_to_ty::h59f5403e5b7d66bdQPv
                        at ../src/librustc_typeck/astconv.rs:1603
  12:     0x7fb3736262cc - astconv::ast_ty_to_ty::closure.39826
                        at ../src/librustc_typeck/astconv.rs:1572
  13:     0x7fb3736261f4 - iter::Map<I, F>.Iterator::next::closure.39823
                        at ../src/libcore/iter.rs:1722
  14:     0x7fb373626167 - option::Option<T>::map::h14013055041868616625
                        at ../src/libcore/option.rs:423
  15:     0x7fb373626105 - iter::Map<I, F>.Iterator::next::h5773863637391150978
                        at ../src/libcore/iter.rs:1722
  16:     0x7fb373626396 - vec::Vec<T>::extend_desugared::h11629801303543280143
                        at ../src/libcollections/vec.rs:1470
  17:     0x7fb373625fb2 - vec::Vec<T>.FromIterator<T>::from_iter::h13404738094255389204
                        at ../src/libcollections/vec.rs:1394
  18:     0x7fb373625d1e - iter::Iterator::collect::h6317935585935112489
                        at ../src/libcore/iter.rs:565
  19:     0x7fb37351b565 - astconv::ast_ty_to_ty::h59f5403e5b7d66bdQPv
                        at ../src/librustc_typeck/astconv.rs:1571
  20:     0x7fb37360c760 - astconv::convert_ty_with_lifetime_elision::h6f460f7dd8faf27aFNu
                        at ../src/librustc_typeck/astconv.rs:570
  21:     0x7fb37362b512 - astconv::ty_of_method_or_bare_fn::hce05a437eae5328ff5v
                        at ../src/librustc_typeck/astconv.rs:1803
  22:     0x7fb37362664d - astconv::ty_of_bare_fn::h607ee3ec664c27fdH4v
                        at ../src/librustc_typeck/astconv.rs:1711
  23:     0x7fb37351b7f0 - astconv::ast_ty_to_ty::h59f5403e5b7d66bdQPv
                        at ../src/librustc_typeck/astconv.rs:1579
  24:     0x7fb37333a1d3 - check::FnCtxt<'a, 'tcx>::to_ty::h73fafe684209fa0dDVo
                        at ../src/librustc_typeck/check/mod.rs:1509
  25:     0x7fb3735a5de0 - check::check_expr_with_unifier::h6057465928997568522
                        at ../src/librustc_typeck/check/mod.rs:3497
  26:     0x7fb37331b230 - check::check_expr::h67cfff21408ddc9dxjq
                        at ../src/librustc_typeck/check/mod.rs:2636
  27:     0x7fb3735ce9b3 - check::check_stmt::haa8f485ee8788d35v0r
                        at ../src/librustc_typeck/check/mod.rs:4060
  28:     0x7fb3734f202f - check::check_block_with_expected::h92e2dfdb42860c63z4r
                        at ../src/librustc_typeck/check/mod.rs:4102
  29:     0x7fb3734b591e - check::check_fn::hfab5918ab6495513Szn
                        at ../src/librustc_typeck/check/mod.rs:625
  30:     0x7fb3734e3b42 - check::check_bare_fn::h69149d526417eee8xpn
                        at ../src/librustc_typeck/check/mod.rs:443
  31:     0x7fb3734dbb7d - check::check_item_body::hde42a3e9eb7fca98xPn
                        at ../src/librustc_typeck/check/mod.rs:718
  32:     0x7fb3734db584 - check::CheckItemBodiesVisitor<'a, 'tcx>.Visitor<'tcx>::visit_item::h19b7e1a3ef4d47d8Amn
                        at ../src/librustc_typeck/check/mod.rs:380
  33:     0x7fb3734e1914 - visit::walk_mod::h4457057824098729211
                        at ../src/libsyntax/visit.rs:165
  34:     0x7fb3734e1861 - visit::Visitor::visit_mod::h5000110883616035837
                        at ../src/libsyntax/visit.rs:64
  35:     0x7fb3734e2fdb - visit::walk_crate::h7371658545850931832
                        at ../src/libsyntax/visit.rs:157
  36:     0x7fb3734e2ab2 - check::check_item_types::hf8f1cb484009402b4mn
                        at ../src/librustc_typeck/check/mod.rs:400
  37:     0x7fb373756a00 - check_crate::closure.42607
                        at ../src/librustc_typeck/lib.rs:349
  38:     0x7fb3737563df - util::common::time::h5154388386627276761
                        at ../src/librustc/util/common.rs:39
  39:     0x7fb373752ec8 - check_crate::h1096b8cc64f43ddds5C
                        at ../src/librustc_typeck/lib.rs:348
  40:     0x7fb374718044 - driver::phase_3_run_analysis_passes::closure.16867
                        at ../src/librustc_driver/driver.rs:663
  41:     0x7fb374717de3 - middle::ty::tls::enter::closure.16858
                        at ../src/librustc/middle/ty.rs:1151
  42:     0x7fb374717b34 - thread::scoped_tls::ScopedKey<T>::set::h5740698089117313085
                        at ../src/libstd/thread/scoped_tls.rs:180
  43:     0x7fb374717594 - middle::ty::tls::enter::closure.16818
                        at ../src/librustc/middle/ty.rs:1151
  44:     0x7fb374717068 - thread::local::LocalKey<T>::with::h1047998320376595356
                        at ../src/libstd/thread/local.rs:217
  45:     0x7fb374716c83 - middle::ty::tls::enter::closure.16811
                        at ../src/librustc/middle/ty.rs:1145
  46:     0x7fb374716818 - thread::local::LocalKey<T>::with::h8975214402943655292
                        at ../src/libstd/thread/local.rs:217
  47:     0x7fb3747164a8 - middle::ty::tls::enter::h15244471624338917019
                        at ../src/librustc/middle/ty.rs:1144
  48:     0x7fb374713730 - middle::ty::ctxt<'tcx>::create_and_enter::h5448069206079026180
                        at ../src/librustc/middle/ty.rs:3746
  49:     0x7fb3746fa720 - driver::phase_3_run_analysis_passes::h17171246126576738064
                        at ../src/librustc_driver/driver.rs:651
  50:     0x7fb3746b28eb - driver::compile_input::h7936237b5328f2c1Tba
                        at ../src/librustc_driver/driver.rs:122
  51:     0x7fb3749b5ea3 - run_compiler::he5596ff537c688ddC7b
                        at ../src/librustc_driver/lib.rs:156
  52:     0x7fb3749b2688 - run::closure.29243
                        at ../src/librustc_driver/lib.rs:99
  53:     0x7fb3749b175d - monitor::closure.29214
                        at ../src/librustc_driver/lib.rs:809
  54:     0x7fb3749b1611 - boxed::F.FnBox<A>::call_box::h13102866563604429246
                        at ../src/liballoc/boxed.rs:515
  55:     0x7fb3749b11e0 - boxed::Box<FnBox<A, Output $u3d$$u20$R$GT$$u2b$$u20$Send$u20$$u2b$$u20$$u27$a$GT$.FnOnce$LT$A$GT$::call_once::h15928366404761575081
                        at ../src/liballoc/boxed.rs:531
  56:     0x7fb3749b0c92 - thread::Builder::spawn_inner::closure.29187
                        at ../src/libstd/thread/mod.rs:322
  57:     0x7fb3749b0c0e - rt::unwind::try::try_fn::h2096641183789202929
                        at ../src/libstd/rt/unwind/mod.rs:168
  58:     0x7fb374035f57 - __rust_try_inner
  59:     0x7fb374035fad - __rust_try
  60:     0x7fb373fdacef - rt::unwind::try::inner_try::h8401f0adc136f5f2I1w
                        at ../src/libstd/rt/unwind/mod.rs:157
  61:     0x7fb3749b0b58 - rt::unwind::try::h2869518614589579972
                        at ../src/libstd/rt/unwind/mod.rs:140
  62:     0x7fb3749b09be - thread::Builder::spawn_inner::closure.29139
                        at ../src/libstd/thread/mod.rs:322
  63:     0x7fb3749b144d - boxed::F.FnBox<A>::call_box::h5650395233266235292
                        at ../src/liballoc/boxed.rs:515
  64:     0x7fb373ffc360 - boxed::Box<FnBox<A, Output $u3d$$u20$R$GT$$u2b$$u20$$u27$a$GT$.FnOnce$LT$A$GT$::call_once::h17370688546240473290
                        at ../src/liballoc/boxed.rs:523
  65:     0x7fb373ffc25c - sys_common::thread::start_thread::hcfc7a4e253eecb1deCr
                        at ../src/libstd/sys/common/thread.rs:30
  66:     0x7fb374031514 - sys::thread::Thread::new::thread_start::__rust_abi
                        at ../src/libstd/sys/unix/thread.rs:77
  67:     0x7fb374031494 - sys::thread::Thread::new::thread_start::hfb441bc8d197c3d5gbw
  68:     0x7fb36c1c10a3 - start_thread
  69:     0x7fb373bcb07c - clone
  70:                0x0 - <unknown>
@arielb1 arielb1 added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Aug 19, 2015
@arielb1
Copy link
Contributor Author

arielb1 commented Aug 20, 2015

We should just not normalize in that case as we usually do.

Relavant code: projected_ty

We should use ctxt.mk_projection, followed by normalize. Remove the normalize_associated_type() methods everywhere too (and any dead code that arises from that)

@apasel422
Copy link
Contributor

What needs to be done to fix this?

@Manishearth
Copy link
Member

Is this really an easy bug? If so, could you leave some pointers on where to start looking to fix this?

@arielb1
Copy link
Contributor Author

arielb1 commented Oct 5, 2015

@Manishearth

Add a check to projected_ty to not normalize if there are escaping regions.

@Manishearth
Copy link
Member

And what should they return instead of the normalized type? self_ty()? That doesn't sound right. Is there some other function to run?

@arielb1
Copy link
Contributor Author

arielb1 commented Oct 5, 2015

@Manishearth

the unnormalized type, as we do in all other cases involving escaping regions.

@Manishearth
Copy link
Member

Updated the fixing instructions above to reflect this

@maurer
Copy link
Contributor

maurer commented Oct 26, 2015

I'm experiencing this error in rustc 1.3.0 on real code. I haven't minimized it, but it's rather large so I'm going to assume it's the same source. If it would be helpful to have a dump of a huge project generating this area I can provide it though.

In the meantime, is there a set of rules I can follow to prevent the compiler from ICEing?

@nikomatsakis nikomatsakis added the A-trait-system Area: Trait system label Jun 7, 2016
@brson brson removed the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Jun 28, 2016
@arielb1 arielb1 self-assigned this Feb 28, 2017
arielb1 added a commit to arielb1/rust that referenced this issue Mar 1, 2017
bors added a commit that referenced this issue Mar 4, 2017
More through normalization, Feb/Mar 2017 edition

Fix a few normalization bugs.

Fixes #27901.
Fixes #28828.
Fixes #38135.
Fixes #39363.
Fixes #39367.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

6 participants