rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.4k stars 12.73k forks source link

src\librustc_mir\transform\generator.rs:739:13: Broken MIR: generator contains type &rocket::http::Cookie in MIR, but typeck only knows about for... #74961

Closed Weasy666 closed 4 years ago

Weasy666 commented 4 years ago

Code

Minimal verifiable example can be found here: https://github.com/Weasy666/rustc-bug Just clone and cargo run.

Meta

rustc --version --verbose:

rustc 1.47.0-nightly (6c8927b0c 2020-07-26)
binary: rustc
commit-hash: 6c8927b0cf80ceee19386026cf9d7fd4fd9d486f
commit-date: 2020-07-26
host: x86_64-pc-windows-msvc
release: 1.47.0-nightly
LLVM version: 10.0

Error output

error: internal compiler error: src\librustc_mir\transform\generator.rs:739:13: Broken MIR: generator contains type &rocket::http::Cookie in MIR, but typeck only knows about for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5, 't6> {std::future::ResumeTy, &'r rocket::Request<'s>, rocket::http::Cookies<'t0>, &'t1 mut rocket::http::Cookies<'t2>, &'t3 str, std::option::Option<rocket::http::Cookie<'t4>>, rocket::http::Cookie<'t5>, std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = rocket::outcome::Outcome<rocket_airlock::Airlock<hatch::SimpleHatch>, (rocket::http::Status, ()), ()>> + std::marker::Send + 't6)>>, ()}
  --> src\user.rs:16:83
   |
16 |       async fn from_request(request: &'a Request<'r>) -> Outcome<Self, Self::Error> {
   |  ___________________________________________________________________________________^
17 | |         let mut cookies = request.cookies();
18 | |         match cookies.get_private("logged_in") {
19 | |             Some(logged_in) if request.guard::<Airlock<hatch::SimpleHatch>>().await.expect("Hatch 'SimpleHatch' was not installed into th...
...  |
25 | |         }
26 | |     }
   | |_____^

thread 'rustc' panicked at 'Box<Any>', /rustc/6c8927b0cf80ceee19386026cf9d7fd4fd9d486f\src\libstd\macros.rs:13:23
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden
Backtrace

``` stack backtrace: 0: ::fmt 1: core::fmt::write 2: ::fmt 3: std::panicking::take_hook 4: std::panicking::take_hook 5: rustc_driver::report_ice 6: std::panicking::rust_panic_with_hook 7: rustc_mir_build::provide 8: ::fmt 9: ::fmt 10: ::fmt 11: ::fmt 12: ::fmt 13: ::fmt 14: ::fmt 15: ::run_pass 16: rustc_mir::transform::run_passes 17: rustc_mir::transform::run_passes 18: rustc_mir::transform::run_passes 19: rustc_mir::transform::run_passes 20: rustc_middle::dep_graph::::debug_node 21: ::fmt 22: ::fmt 23: rustc_middle::ty::structural_impls::::lift_to_tcx 24: rustc_middle::ty::layout::provide 25: ::fmt 26: >::hash_stable 27: rustc_middle::dep_graph::::debug_node 28: ::fmt 29: ::fmt 30: rustc_middle::ty::structural_impls::::lift_to_tcx 31: as rustc_target::abi::LayoutOf>::layout_of 32: ::fmt 33: ZN238_$LT$rustc_infer..infer..undo_log..UndoLog$u20$as$u20$core..convert..From$LT$rustc_data_structures..snapshot_map..UndoLog$LT$rustc_infer..traits..project..ProjectionCacheKey$C$rustc_infer..traits..project..ProjectionCacheEntry$GT$$GT$$GT$4from17h3714 34: ::fmt 35: ZN238_$LT$rustc_infer..infer..undo_log..UndoLog$u20$as$u20$core..convert..From$LT$rustc_data_structures..snapshot_map..UndoLog$LT$rustc_infer..traits..project..ProjectionCacheKey$C$rustc_infer..traits..project..ProjectionCacheEntry$GT$$GT$$GT$4from17h3714 36: rustc_middle::ty::layout::provide 37: ::fmt 38: >::hash_stable 39: rustc_middle::dep_graph::::debug_node 40: ::fmt 41: ::fmt 42: rustc_middle::ty::structural_impls::::lift_to_tcx 43: as rustc_target::abi::LayoutOf>::layout_of 44: ::run_pass 45: rustc_mir::transform::run_passes 46: rustc_mir::transform::run_passes 47: rustc_mir::transform::run_passes 48: rustc_mir::transform::run_passes 49: rustc_middle::dep_graph::::debug_node 50: ::fmt 51: ::fmt 52: rustc_middle::ty::structural_impls::::lift_to_tcx 53: rustc_middle::ty::::instance_mir 54: ::visit_impl_item 55: rustc_mir::monomorphize::collector::collect_crate_mono_items 56: rustc_mir::monomorphize::collector::collect_crate_mono_items 57: rustc_mir::monomorphize::collector::collect_crate_mono_items 58: rustc_mir::monomorphize::collector::collect_crate_mono_items 59: rustc_mir::monomorphize::collector::collect_crate_mono_items 60: rustc_mir::monomorphize::collector::collect_crate_mono_items 61: ::fmt 62: rustc_mir::monomorphize::collector::collect_crate_mono_items 63: rustc_mir::monomorphize::partitioning::compute_codegen_unit_name 64: as rustc_codegen_llvm::type_of::LayoutLlvmExt>::pointee_info_at 65: rustc_codegen_llvm::llvm_::archive_ro::Child::data 66: ::fmt 67: ::fmt 68: ::fmt 69: as rustc_codegen_llvm::type_of::LayoutLlvmExt>::pointee_info_at 70: ::codegen_crate 71: rustc_interface::passes::QueryContext::print_stats 72: rustc_interface::passes::BoxedResolver::complete 73: rustc_interface::queries::Queries::ongoing_codegen 74: ::check_trait_item_post 75: ::fmt 76: ::deref 77: ::deref 78: ::array_subpath 79: std::sys::windows::thread::Thread::new 80: BaseThreadInitThunk 81: RtlUserThreadStart note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md note: rustc 1.47.0-nightly (6c8927b0c 2020-07-26) running on x86_64-pc-windows-msvc note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [optimized_mir] optimizing MIR for `>::from_request::__from_request::{{closure}}#0` #1 [layout_raw] computing layout of `[static generator@src\user.rs:16:83: 26:6 request:&rocket::Request for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5, 't6> {std::future::ResumeTy, &'r rocket::Request<'s>, rocket::http::Cookies<'t0>, &'t1 mut rocket::http::Cookies<'t2>, &'t3 str, std::option::Option>, rocket::http::Cookie<'t5>, std::pin::Pin, (rocket::http::Status, ()), ()>> + std::marker::Send + 't6)>>, ()}]` #2 [layout_raw] computing layout of `std::future::from_generator::GenFuture<[static generator@src\user.rs:16:83: 26:6 request:&rocket::Request for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5, 't6> {std::future::ResumeTy, &'r rocket::Request<'s>, rocket::http::Cookies<'t0>, &'t1 mut rocket::http::Cookies<'t2>, &'t3 str, std::option::Option>, rocket::http::Cookie<'t5>, std::pin::Pin, (rocket::http::Status, ()), ()>> + std::marker::Send + 't6)>>, ()}]>` #3 [optimized_mir] optimizing MIR for `>::from_request::__from_request` #4 [collect_and_partition_mono_items] collect_and_partition_mono_items end of query stack ```

SNCPlay42 commented 4 years ago

MCVE:

async fn some_future() -> u8 { 1 }

pub async fn bad_mir(x: u8) {
    match x {
        y if some_future().await == y => (),
        _ => (),
    }
}
SNCPlay42 commented 4 years ago

Looks like this is a duplicate of #72651.

tmandry commented 4 years ago

Thanks @SNCPlay42! Going to close this as a duplicate, I've added the MVCE here to #72651.