Skip to content

ICE path with 'Res::Err' but no error emitted / broken mir : --edition=2018 #109147

Closed
@matthiaskrgr

Description

@matthiaskrgr

Code

rustc --edition=2018 file.rs

use rustfmt::skip::Cell;

fn f(f: (Cell<>)) -> i32 { f }

fn main() {}

Meta

rustc --version --verbose:

rustc 1.70.0-nightly (22f247c6f 2023-03-13)
binary: rustc
commit-hash: 22f247c6f3ed388cb702d01c2ff27da658a8b353
commit-date: 2023-03-13
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7

Error output

<output>
Backtrace

warning: unnecessary parentheses around type
 --> treereduce.out:3:9
  |
3 | fn f(f: (Cell<>)) -> i32 { f }
  |         ^      ^
  |
  = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
  |
3 - fn f(f: (Cell<>)) -> i32 { f }
3 + fn f(f: Cell<>) -> i32 { f }
  |

warning: function `f` is never used
 --> treereduce.out:3:4
  |
3 | fn f(f: (Cell<>)) -> i32 { f }
  |    ^
  |
  = note: `#[warn(dead_code)]` on by default

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: path with `Res::Err` but no error emitted
 --> treereduce.out:3:10
  |
3 | fn f(f: (Cell<>)) -> i32 { f }
  |          ^^^^^^
  |
  = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
             1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &str>
             2: <dyn rustc_hir_analysis::astconv::AstConv>::res_to_ty
             3: <dyn rustc_hir_analysis::astconv::AstConv>::ast_ty_to_ty_inner::{closure#0}
             4: <dyn rustc_hir_analysis::astconv::AstConv>::ty_of_fn::{closure#0}
             5: rustc_hir_analysis::collect::infer_return_ty_for_fn_sig
             6: rustc_hir_analysis::collect::fn_sig
             7: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::fn_sig, rustc_query_impl::plumbing::QueryCtxt>
             8: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::fn_sig
             9: <rustc_hir_analysis::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_item
            10: <rustc_middle::hir::map::Map>::visit_item_likes_in_module::<rustc_hir_analysis::collect::CollectItemTypesVisitor>
            11: rustc_hir_analysis::collect::collect_mod_item_types
            12: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::collect_mod_item_types, rustc_query_impl::plumbing::QueryCtxt>
            13: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::collect_mod_item_types
            14: <rustc_session::session::Session>::track_errors::<rustc_hir_analysis::check_crate::{closure#0}, ()>
            15: rustc_hir_analysis::check_crate
            16: rustc_interface::passes::analysis
            17: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
            18: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
            19: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            20: rustc_span::with_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
            21: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            22: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            23: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/22f247c6f3ed388cb702d01c2ff27da658a8b353/library/alloc/src/boxed.rs:1988:9
            24: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/22f247c6f3ed388cb702d01c2ff27da658a8b353/library/alloc/src/boxed.rs:1988:9
            25: std::sys::unix::thread::Thread::new::thread_start
                       at /rustc/22f247c6f3ed388cb702d01c2ff27da658a8b353/library/std/src/sys/unix/thread.rs:108:17
            26: <unknown>
            27: <unknown>


error: internal compiler error: broken MIR in DefId(0:4 ~ treereduce[f677]::f) ("return type"): bad type [type error]
 --> treereduce.out:3:1
  |
3 | fn f(f: (Cell<>)) -> i32 { f }
  | ^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
             1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &str>
             2: <rustc_borrowck::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_body
             3: rustc_borrowck::nll::compute_regions
             4: rustc_borrowck::do_mir_borrowck
             5: rustc_borrowck::mir_borrowck
             6: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::mir_borrowck, rustc_query_impl::plumbing::QueryCtxt>
             7: rustc_data_structures::sync::par_for_each_in::<&[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_interface::passes::analysis::{closure#2}::{closure#0}>::{closure#0}>
             8: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#2}>
             9: rustc_interface::passes::analysis
            10: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
            11: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
            12: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            13: rustc_span::with_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
            14: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            15: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            16: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/22f247c6f3ed388cb702d01c2ff27da658a8b353/library/alloc/src/boxed.rs:1988:9
            17: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/22f247c6f3ed388cb702d01c2ff27da658a8b353/library/alloc/src/boxed.rs:1988:9
            18: std::sys::unix::thread::Thread::new::thread_start
                       at /rustc/22f247c6f3ed388cb702d01c2ff27da658a8b353/library/std/src/sys/unix/thread.rs:108:17
            19: <unknown>
            20: <unknown>


error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
             1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &str>
             2: <rustc_middle::ty::context::TyCtxt>::ty_error_misc
             3: <rustc_borrowck::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_body
             4: rustc_borrowck::nll::compute_regions
             5: rustc_borrowck::do_mir_borrowck
             6: rustc_borrowck::mir_borrowck
             7: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::mir_borrowck, rustc_query_impl::plumbing::QueryCtxt>
             8: rustc_data_structures::sync::par_for_each_in::<&[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_interface::passes::analysis::{closure#2}::{closure#0}>::{closure#0}>
             9: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#2}>
            10: rustc_interface::passes::analysis
            11: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
            12: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
            13: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            14: rustc_span::with_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
            15: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            16: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            17: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/22f247c6f3ed388cb702d01c2ff27da658a8b353/library/alloc/src/boxed.rs:1988:9
            18: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/22f247c6f3ed388cb702d01c2ff27da658a8b353/library/alloc/src/boxed.rs:1988:9
            19: std::sys::unix::thread::Thread::new::thread_start
                       at /rustc/22f247c6f3ed388cb702d01c2ff27da658a8b353/library/std/src/sys/unix/thread.rs:108:17
            20: <unknown>
            21: <unknown>


error: internal compiler error: broken MIR in DefId(0:4 ~ treereduce[f677]::f) (LocalDecl { mutability: Mut, local_info: None, internal: false, is_block_tail: None, ty: [type error], user_ty: None, source_info: SourceInfo { span: treereduce.out:3:1: 3:25 (#0), scope: scope[0] } }): bad type [type error]
 --> treereduce.out:3:1
  |
3 | fn f(f: (Cell<>)) -> i32 { f }
  | ^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
             1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &str>
             2: <rustc_borrowck::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_body
             3: rustc_borrowck::nll::compute_regions
             4: rustc_borrowck::do_mir_borrowck
             5: rustc_borrowck::mir_borrowck
             6: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::mir_borrowck, rustc_query_impl::plumbing::QueryCtxt>
             7: rustc_data_structures::sync::par_for_each_in::<&[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_interface::passes::analysis::{closure#2}::{closure#0}>::{closure#0}>
             8: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#2}>
             9: rustc_interface::passes::analysis
            10: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
            11: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
            12: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            13: rustc_span::with_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
            14: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            15: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            16: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/22f247c6f3ed388cb702d01c2ff27da658a8b353/library/alloc/src/boxed.rs:1988:9
            17: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/22f247c6f3ed388cb702d01c2ff27da658a8b353/library/alloc/src/boxed.rs:1988:9
            18: std::sys::unix::thread::Thread::new::thread_start
                       at /rustc/22f247c6f3ed388cb702d01c2ff27da658a8b353/library/std/src/sys/unix/thread.rs:108:17
            19: <unknown>
            20: <unknown>


error: internal compiler error: path with `Res::Err` but no error emitted
 --> treereduce.out:3:10
  |
3 | fn f(f: (Cell<>)) -> i32 { f }
  |          ^^^^^^
  |
  = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
             1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &str>
             2: <dyn rustc_hir_analysis::astconv::AstConv>::res_to_ty
             3: <dyn rustc_hir_analysis::astconv::AstConv>::ast_ty_to_ty_inner::{closure#0}
             4: rustc_hir_analysis::hir_ty_to_ty
             5: <rustc_privacy::TypePrivacyVisitor as rustc_hir::intravisit::Visitor>::visit_ty
             6: rustc_hir::intravisit::walk_item::<rustc_privacy::TypePrivacyVisitor>
             7: rustc_privacy::check_mod_privacy
             8: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::check_mod_privacy, rustc_query_impl::plumbing::QueryCtxt>
             9: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_privacy
            10: rustc_data_structures::sync::par_for_each_in::<&[rustc_hir::hir_id::OwnerId], <rustc_middle::hir::map::Map>::par_for_each_module<rustc_interface::passes::analysis::{closure#6}::{closure#2}::{closure#0}::{closure#0}>::{closure#0}>
            11: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#6}::{closure#2}::{closure#0}>
            12: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#6}>
            13: rustc_interface::passes::analysis
            14: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
            15: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
            16: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            17: rustc_span::with_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
            18: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            19: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            20: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/22f247c6f3ed388cb702d01c2ff27da658a8b353/library/alloc/src/boxed.rs:1988:9
            21: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/22f247c6f3ed388cb702d01c2ff27da658a8b353/library/alloc/src/boxed.rs:1988:9
            22: std::sys::unix::thread::Thread::new::thread_start
                       at /rustc/22f247c6f3ed388cb702d01c2ff27da658a8b353/library/std/src/sys/unix/thread.rs:108:17
            23: <unknown>
            24: <unknown>


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.70.0-nightly (22f247c6f 2023-03-13) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to 6 previous errors; 2 warnings emitted

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions