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 in boolean expression #78135

Closed
mbartlett21 opened this issue Oct 20, 2020 · 1 comment
Closed

ICE in boolean expression #78135

mbartlett21 opened this issue Oct 20, 2020 · 1 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.

Comments

@mbartlett21
Copy link
Contributor

mbartlett21 commented Oct 20, 2020

A typed expression with a comparison on the first branch and an assignment on the second causes an ICE.

E.g: let b: bool = 1 == 1 && a = 3; (see code below)

Code

fn main() {
    let a = 7;
    let b: bool = 1 == 1 && a = 3;
}

Meta

rustc --version --verbose:

rustc --version --verbose
rustc 1.49.0-nightly (91a79fb29 2020-10-07)
binary: rustc
commit-hash: 91a79fb29ac78d057d04dbe86be13d5dcc64309a
commit-date: 2020-10-07
host: x86_64-pc-windows-msvc
release: 1.49.0-nightly
LLVM version: 11.0

Error output

rustc --crate-type bin test.rs
error[E0308]: mismatched types
 --> test.rs:3:28
  |
3 |     let b: bool = 1 < 2 && a = 3;
  |                            ^ expected `bool`, found integer

error: internal compiler error: compiler\rustc_typeck\src\check\fn_ctxt.rs:459:25: while adjusting
Expr {
    hir_id: HirId {
        owner: DefId(0:3 ~ test[317d]::main),
        local_id: 8
    },
    kind: Lit(Spanned {
        node: Int(1, Unsuffixed),
        span: test.rs:3:19:3:20 (#0)
    }),
    attrs: ThinVec(None),
    span: test.rs:3:19:3:20 (#0)
}, can't compose [Borrow(Ref('_#0r, Not)) -> &{integer}]
             and [Borrow(Ref('_#2r, Not)) -> &{integer}]

thread 'rustc' panicked at 'Box<Any>', compiler\rustc_errors\src\lib.rs:945:9
stack backtrace:
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-compile
r&template=ice.md

note: rustc 1.49.0-nightly (91a79fb29 2020-10-07) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type bin

query stack during panic:
#0 [typeck] type-checking `main`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.

(above is edited to format the Expr nicely.)

Backtrace

thread 'rustc' panicked at 'Box<Any>', compiler\rustc_errors\src\lib.rs:945:9
stack backtrace:
   0:     0x7ff8c3229989 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc20a26e0
f7659afd
   1:     0x7ff8c32570bb - core::fmt::write::h435be716304d26a1
   2:     0x7ff8c321b1d8 - <std::io::IoSlice as core::fmt::Debug>::fmt::h997d94c78f1ba97b
   3:     0x7ff8c322ed74 - std::panicking::take_hook::hbf7e33d26fc3ca30
   4:     0x7ff8c322e958 - std::panicking::take_hook::hbf7e33d26fc3ca30
   5:     0x7ff8713df5a7 - rustc_driver::report_ice::h901ed469a4afd632
   6:     0x7ff8c322f7d0 - std::panicking::rust_panic_with_hook::h19068ccbe4b337a1
   7:     0x7ff875b47870 - <rustc_errors::snippet::Style as core::fmt::Debug>::fmt::h154d3f8b7cc27034
   8:     0x7ff875b47799 - <rustc_errors::snippet::Style as core::fmt::Debug>::fmt::h154d3f8b7cc27034
   9:     0x7ff875b477e1 - <rustc_errors::snippet::Style as core::fmt::Debug>::fmt::h154d3f8b7cc27034
  10:     0x7ff875b7a80f - rustc_errors::HandlerInner::err_count::hc7ff30e58befa0c0
  11:     0x7ff875b78ec2 - rustc_errors::Handler::bug::h9f679e586b05b709
  12:     0x7ff875653d4f - rustc_middle::util::bug::bug_fmt::h333e4a32fa9b0768
  13:     0x7ff87564fe70 - <rustc_middle::ty::consts::int::ConstInt as core::fmt::Debug>::fmt::he16df1c1cd9a0739
  14:     0x7ff87564fe13 - <rustc_middle::ty::consts::int::ConstInt as core::fmt::Debug>::fmt::he16df1c1cd9a0739
  15:     0x7ff875653c7c - rustc_middle::util::bug::bug_fmt::h333e4a32fa9b0768
  16:     0x7ff875653be0 - rustc_middle::util::bug::bug_fmt::h333e4a32fa9b0768
  17:     0x7ff873a7b276 - rustc_typeck::check::fn_ctxt::FnCtxt::apply_adjustments::hd48689c045bb2779
  18:     0x7ff873a9ccb6 - rustc_typeck::check::op::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_binop::h67eed476
27a4f5c1
  19:     0x7ff873a9c4f0 - rustc_typeck::check::op::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_binop::h67eed476
27a4f5c1
  20:     0x7ff873a6a470 - rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expe
ctation::h6fa46624a8ef21fd
  21:     0x7ff873a69666 - rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expe
ctation::h6fa46624a8ef21fd
  22:     0x7ff873a69491 - rustc_typeck::check::demand::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_for_cast::hb
aee3244de8f690d
  23:     0x7ff873a9c476 - rustc_typeck::check::op::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_binop::h67eed476
27a4f5c1
  24:     0x7ff873a6a470 - rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expe
ctation::h6fa46624a8ef21fd
  25:     0x7ff873a69666 - rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expe
ctation::h6fa46624a8ef21fd
  26:     0x7ff873a6c4b3 - rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expe
ctation::h6fa46624a8ef21fd
  27:     0x7ff873a69666 - rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expe
ctation::h6fa46624a8ef21fd
  28:     0x7ff873a69491 - rustc_typeck::check::demand::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_for_cast::hb
aee3244de8f690d
  29:     0x7ff873a844ef - rustc_typeck::check::fn_ctxt::FnCtxt::check_decl_local::h5c1c57395ff4dad3
  30:     0x7ff873a8499a - rustc_typeck::check::fn_ctxt::FnCtxt::check_stmt::h3ac9184b280389fd
  31:     0x7ff873a85456 - rustc_typeck::check::fn_ctxt::FnCtxt::check_block_no_value::h5fff96e685a19bb6
  32:     0x7ff873a69c2c - rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expe
ctation::h6fa46624a8ef21fd
  33:     0x7ff873a69666 - rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expe
ctation::h6fa46624a8ef21fd
  34:     0x7ff873a740b8 - rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expe
ctation::h6fa46624a8ef21fd
  35:     0x7ff873b82bb0 - rustc_typeck::check::check::check_wf_new::h44ae7595528a6fe9
  36:     0x7ff873cc8d09 - <rustc_typeck::variance::terms::InferredIndex as core::fmt::Debug>::fmt::h716ba16bc4b92d58
  37:     0x7ff873d21d5f - <rustc_typeck::check::fixup_opaque_types::FixupFolder as rustc_middle::ty::fold::TypeFolder>
::fold_ty::h873bd66c196887b9
  38:     0x7ff873c8f21e - <rustc_typeck::constrained_generic_params::Parameter as core::fmt::Debug>::fmt::h697f47275b1
d4ea6
  39:     0x7ff873c48e58 - <<rustc_typeck::collect::const_evaluatable_predicates_of::ConstCollector as rustc_hir::intra
visit::Visitor>::visit_ty::TyAliasVisitor as rustc_middle::ty::fold::TypeVisitor>::visit_const::h7488589258723033
  40:     0x7ff873bde23d - rustc_typeck::check::cast::CastCheck::do_check::h2e0c6c80235d0092
  41:     0x7ff873b5722b - rustc_typeck::check::writeback::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::resolve_type_va
rs_in_body::h32b348bc85041929
  42:     0x7ff873b6b0c2 - rustc_typeck::check::writeback::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::resolve_type_va
rs_in_body::h32b348bc85041929
  43:     0x7ff873d275e4 - <rustc_typeck::check::CheckItemTypesVisitor as rustc_hir::itemlikevisit::ItemLikeVisitor>::v
isit_item::hae0d161a33710820
  44:     0x7ff873c341ed - <<rustc_typeck::collect::const_evaluatable_predicates_of::ConstCollector as rustc_hir::intra
visit::Visitor>::visit_ty::TyAliasVisitor as rustc_middle::ty::fold::TypeVisitor>::visit_const::h7488589258723033
  45:     0x7ff873c4e9c7 - <<rustc_typeck::collect::const_evaluatable_predicates_of::ConstCollector as rustc_hir::intra
visit::Visitor>::visit_ty::TyAliasVisitor as rustc_middle::ty::fold::TypeVisitor>::visit_const::h7488589258723033
  46:     0x7ff873be0ab9 - rustc_typeck::check::cast::CastCheck::do_check::h2e0c6c80235d0092
  47:     0x7ff873af02cd - rustc_typeck::check::writeback::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::resolve_type_va
rs_in_body::h32b348bc85041929
  48:     0x7ff873c872de - rustc_typeck::check_crate::had5f65b17757aa4d
  49:     0x7ff871605cfa - rustc_interface::passes::QueryContext::print_stats::hd29879a8b3af7832
  50:     0x7ff87142957b - tracing_core::event::Event::metadata::h86572d73d587b6bd
  51:     0x7ff8713ede67 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::h234a3cece69c9eed
  52:     0x7ff871408ba6 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::h234a3cece69c9eed
  53:     0x7ff871391614 - rustc_errors::snippet::MultilineAnnotation::increase_depth::h93baa802966d31ca
  54:     0x7ff87142e53b - tracing_core::event::Event::metadata::h86572d73d587b6bd
  55:     0x7ff871404a34 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::h234a3cece69c9eed
  56:     0x7ff8713a074c - <rustc_driver::args::Error as core::fmt::Debug>::fmt::h500583d00d12c2d9
  57:     0x7ff871406b28 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::h234a3cece69c9eed
  58:     0x7ff8713e3a30 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::h234a3cece69c9eed
  59:     0x7ff87140a123 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::h234a3cece69c9eed
  60:     0x7ff871387523 - rustc_errors::snippet::MultilineAnnotation::increase_depth::h93baa802966d31ca
  61:     0x7ff8c323f6a7 - std::sys::windows::thread::Thread::new::h04914a10b014a9d7
  62:     0x7ff8dd03f5c4 - BaseThreadInitThunk
  63:     0x7ff8df06a67b - RtlUserThreadStart

@mbartlett21 mbartlett21 added 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. labels Oct 20, 2020
@jonas-schievink
Copy link
Contributor

Duplicate of #77218

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

2 participants