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

ICE: Adding explicit type to parameter in closure #46007

Closed
raphaelcohn opened this issue Nov 15, 2017 · 7 comments
Closed

ICE: Adding explicit type to parameter in closure #46007

raphaelcohn opened this issue Nov 15, 2017 · 7 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@raphaelcohn
Copy link

Changing this block of code, a private function within a private instance function:-

		fn x<'resources>(resourceRefCell: &'resources RefCell<Resource>) -> Option<Ref<'resources, ImageMetaData>>
		{
			// TODO: try_borrow()
			let resourceRef: Ref<'resources, Resource> = resourceRefCell.borrow();
			let deref: &'resources Resource = resourceRef.deref();
			let mayBeMissingImageMetaData: Option<&'resources ImageMetaData> = deref.imageMetaData();
			if mayBeMissingImageMetaData.is_none()
			{
				return None;
			}
			let imageMetaData: &'resources ImageMetaData = mayBeMissingImageMetaData.unwrap();
			
			let result: Ref<'resources, ImageMetaData> = Ref::map(resourceRef, |_resource: &'resources Resource| imageMetaData);
			
			Some(result)
		}

To this block of code (ie adding &'resources Resource in Ref::map(resourceRef, |_resource: &'resources Resource| imageMetaData);) causes an ICE. The previous block of code does not compile correctly (error[E0312]: lifetime of reference outlives lifetime of borrowed content...), but does not cause a compiler ICE.

		fn x<'resources>(resourceRefCell: &'resources RefCell<Resource>) -> Option<Ref<'resources, ImageMetaData>>
		{
			// TODO: try_borrow()
			let resourceRef: Ref<'resources, Resource> = resourceRefCell.borrow();
			let deref: &'resources Resource = resourceRef.deref();
			let mayBeMissingImageMetaData: Option<&'resources ImageMetaData> = deref.imageMetaData();
			if mayBeMissingImageMetaData.is_none()
			{
				return None;
			}
			let imageMetaData: &'resources ImageMetaData = mayBeMissingImageMetaData.unwrap();
			
			let result: Ref<'resources, ImageMetaData> = Ref::map(resourceRef, |_resource: &'resources Resource| imageMetaData);
			
			Some(result)
		}

Details:-

note: rustc 1.23.0-nightly (f0fe716db 2017-10-30) running on x86_64-apple-darwin

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'no representative region', src/libcore/option.rs:839:4
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::_print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::begin_panic
   6: std::panicking::begin_panic_fmt
   7: rust_begin_unwind
   8: core::panicking::panic_fmt
   9: core::option::expect_failed
  10: <std::collections::hash::map::HashMap<K, V, S> as core::iter::traits::FromIterator<(K, V)>>::from_iter
  11: rustc::infer::InferCtxt::commit_if_ok
  12: rustc::infer::InferCtxt::match_poly_projection_predicate
  13: _ZN5rustc6traits7project27confirm_param_env_candidate17habff882837a41ddaE.llvm.3E97BD9F
  14: _ZN5rustc6traits7project26confirm_callable_candidate17hf1fb33793fbc8eaeE.llvm.3E97BD9F
  15: _ZN5rustc6traits7project29opt_normalize_projection_type17h592c5467d0081e78E.llvm.3E97BD9F
  16: rustc::traits::project::project_and_unify_type
  17: rustc::infer::InferCtxt::commit_if_ok
  18: <rustc::traits::fulfill::FulfillProcessor<'a, 'b, 'gcx, 'tcx> as rustc_data_structures::obligation_forest::ObligationProcessor>::process_obligation
  19: <rustc_data_structures::obligation_forest::ObligationForest<O>>::process_obligations
  20: rustc::traits::fulfill::FulfillmentContext::select_where_possible
  21: rustc_typeck::check::FnCtxt::select_obligations_where_possible
  22: rustc_typeck::check::FnCtxt::structurally_resolved_type
  23: _ZN12rustc_typeck5check6FnCtxt15check_expr_kind17h279443985a1eb710E.llvm.CE0E39D0
  24: _ZN12rustc_typeck5check6FnCtxt43check_expr_with_expectation_and_lvalue_pref17hc47d2f6e9562afbaE.llvm.CE0E39D0
  25: _ZN12rustc_typeck5check6FnCtxt25check_block_with_expected28_$u7b$$u7b$closure$u7d$$u7d$17h05974efbcb174142E.llvm.CE0E39D0
  26: _ZN12rustc_typeck5check6FnCtxt25check_block_with_expected17h8f38ad8b757ba8bcE.llvm.CE0E39D0
  27: _ZN12rustc_typeck5check6FnCtxt15check_expr_kind17h279443985a1eb710E.llvm.CE0E39D0
  28: _ZN12rustc_typeck5check6FnCtxt43check_expr_with_expectation_and_lvalue_pref17hc47d2f6e9562afbaE.llvm.CE0E39D0
  29: _ZN12rustc_typeck5check6FnCtxt17check_return_expr17hc60b7352ad22906bE.llvm.CE0E39D0
  30: rustc_typeck::check::check_fn
  31: <std::thread::local::LocalKey<T>>::with
  32: rustc::ty::context::GlobalCtxt::enter_local
  33: _ZN12rustc_typeck5check16typeck_tables_of17h32dbee8488fe88cbE.llvm.CE0E39D0
  34: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::compute_result
  35: _ZN5rustc9dep_graph5graph8DepGraph14with_task_impl17h743e6aa6978901a1E.llvm.51A1F540
  36: rustc_errors::Handler::track_diagnostics
  37: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  38: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::force
  39: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get
  40: rustc::ty::maps::TyCtxtAt::typeck_tables_of
  41: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::ensure
  42: rustc::session::Session::track_errors
  43: _ZN12rustc_typeck5check18typeck_item_bodies17h0a705077b225ea80E.llvm.CE0E39D0
  44: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::compute_result
  45: _ZN5rustc9dep_graph5graph8DepGraph14with_task_impl17h72e781faf4300ed4E.llvm.51A1F540
  46: rustc_errors::Handler::track_diagnostics
  47: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  48: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::force
  49: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::try_get
  50: rustc::ty::maps::TyCtxtAt::typeck_item_bodies
  51: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_item_bodies
  52: rustc::util::common::time
  53: rustc_typeck::check_crate
  54: <std::thread::local::LocalKey<T>>::with
  55: <std::thread::local::LocalKey<T>>::with
  56: rustc_driver::driver::compile_input
  57: rustc_driver::run_compiler

error: Could not compile `cordial`.

Caused by:
  process didn't exit successfully: `/Users/raph/.cargo/bin/rustc --crate-name cordial src/main.rs --color always --crate-type bin --emit=dep-info,metadata -C debuginfo=2 -C metadata=bbf495af5a00aa84 -C extra-filename=-bbf495af5a00aa84 --out-dir /Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps -L dependency=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps --extern handlebars=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libhandlebars-53399e4880a57af4.rmeta --extern svgcleaner=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libsvgcleaner-6f5d579e090e8c3a.rmeta --extern sfnt2woff_zopfli_sys=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libsfnt2woff_zopfli_sys-007531599e06d919.rmeta --extern libc=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/liblibc-25e9c5de64aa0263.rmeta --extern url_serde=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/liburl_serde-a1f2003b599794e4.rmeta --extern chardet=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libchardet-323017b32fc83ed2.rmeta --extern num_cpus=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libnum_cpus-8ddc6e3bc8478554.rmeta --extern tokio_signal=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libtokio_signal-6f0af505b7ad62d3.rmeta --extern base64=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libbase64-e80b40bfc2ac66cb.rmeta --extern quick_error=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libquick_error-3179a56112c32160.rmeta --extern malloc_buf=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libmalloc_buf-da73364182f62c4f.rmeta --extern oxipng=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/liboxipng-0ca4b365445ddc5c.rmeta --extern typed_arena=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libtyped_arena-298184768a470f24.rmeta --extern stderr_logging=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libstderr_logging-163be02d6b3ff2c4.rmeta --extern unicase=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libunicase-71730efbd063f765.rmeta --extern tokio_rustls=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libtokio_rustls-2c3b4c8a069ffc5a.rmeta --extern url=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/liburl-8819f19028da6c1b.rmeta --extern ring=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libring-5cce7f4172f07ad3.rmeta --extern serde_hjson=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libserde_hjson-da1a563305f0c496.rmeta --extern guetzli_sys=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libguetzli_sys-26132f9bf72b072e.rmeta --extern svgdom=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libsvgdom-15865e5158971262.rmeta --extern sass_rs=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libsass_rs-f3e0be63a283a8bf.rmeta --extern brotli2=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libbrotli2-e5c6575986b29bdd.rmeta --extern css_autoprefix=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libcss_autoprefix-08b2000907926023.rmeta --extern hyper=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libhyper-6a8fab1a6a664222.rmeta --extern woff2_sys=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libwoff2_sys-28a84f8dfea21735.rmeta --extern mime_multipart=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libmime_multipart-0e5a9ba99f18bc9e.rmeta --extern hyper_rustls=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libhyper_rustls-80091cff2ab0efa5.rmeta --extern mktemp=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libmktemp-ef4cc1383b8c644c.rmeta --extern svgbob=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libsvgbob-8bf18da22afd11d6.rmeta --extern comrak=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libcomrak-54aca8527412491e.rmeta --extern zero85=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libzero85-0369a85f72afb711.rmeta --extern gif=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libgif-5e36853e7296f535.rmeta --extern net2=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libnet2-1ceed93dba893438.rmeta --extern phf_macros=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libphf_macros-554573a8efbf4e3a.dylib --extern serde_derive=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libserde_derive-fdf044139393cab8.dylib --extern serde=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libserde-3c9723f56251100b.rmeta --extern serde_json=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libserde_json-5b5fc4c98ead945d.rmeta --extern futures=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libfutures-09ce62f0e59f567f.rmeta --extern tokio_io=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libtokio_io-9436ba79e8cf7961.rmeta --extern css_purify=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libcss_purify-dfd4823fd832b7d3.rmeta --extern daemonize=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libdaemonize-e918177d4e95de46.rmeta --extern tokio_core=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libtokio_core-f06c7f92f9a806a3.rmeta --extern chrono=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libchrono-ee951b833d5498ec.rmeta --extern xml=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libxml-e4b293d70b830feb.rmeta --extern rustls=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/librustls-ade55f3344e74d10.rmeta --extern zopfli=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libzopfli-9926488716a6966c.rmeta --extern csv=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libcsv-3fd3842b7b24da9d.rmeta --extern nix=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libnix-40fe6023285d2100.rmeta --extern engiffen=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libengiffen-cee98d373b9b0c53.rmeta --extern clap=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libclap-8f321330462b03ea.rmeta --extern phf=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libphf-077745c7a16af661.rmeta --extern tendril=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libtendril-376f9684e81b9507.rmeta --extern radix_trie=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libradix_trie-ce6033e70bd2a8fd.rmeta --extern ordermap=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libordermap-ef896e133b0f38ab.rmeta --extern image=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libimage-81312678c71f3113.rmeta --extern log=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/liblog-965d005bbfd75d09.rmeta --extern mime_guess=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libmime_guess-555dc1171f44f43f.rmeta --extern maplit=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/deps/libmaplit-2e8cb2196eb4a1bb.rmeta -L native=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/build/brotli-sys-23af6ea94696e7f9/out -L native=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/build/guetzli-sys-7501d1416013cd22/out -L native=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/build/guetzli-sys-7501d1416013cd22/out -L native=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/build/ring-4e235939462ad094/out -L native=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/build/miniz-sys-2a8946a57b6f6215/out -L native=/Users/raph/.cargo/registry/src/github.com-1ecc6299db9ec823/sass-sys-0.4.1/libsass/lib -L native=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/build/sfnt2woff-zopfli-sys-49e7e38c1e0afe76/out -L native=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/build/woff2-sys-5ef23311f55393bd/out -L native=/Volumes/Source/GitHub/lemonrock/cordial/.cargo/target/debug/build/woff2-sys-5ef23311f55393bd/out` (exit code: 101)
@raphaelcohn
Copy link
Author

Specifically, it is adding the explicit lifetime 'resources in the closure it seems.

@frankmcsherry
Copy link
Contributor

This just bit me too, but didn't even involve an explicit lifetime. This ICEs:

                .iterate(|valid: &Collection<_, ((usize, String), isize)>| {

whereas this does not:

                .iterate(|valid| {

@frankmcsherry
Copy link
Contributor

@raphaelcohn It looks like your two example fragments are the same. Is it possible you meant to not have the : &'resources Resource in the first example?

@QuietMisdreavus QuietMisdreavus added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 12, 2017
@raphaelcohn
Copy link
Author

raphaelcohn commented Dec 13, 2017 via email

@arielb1
Copy link
Contributor

arielb1 commented Dec 13, 2017

Is this still a problem with the latest stable/nightly? Looks like a duplicate of #38714 (which was fixed in November 5)

@raphaelcohn
Copy link
Author

raphaelcohn commented Dec 21, 2017 via email

@XAMPPRocky XAMPPRocky added the C-bug Category: This is a bug. label Feb 19, 2018
@steveklabnik
Copy link
Member

With it looking like this was fixed, and no other comments since 2017, I'm going to close this. If you're still seeing this issue, please let me know and we can re-open!

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-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants