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: Intrinsics cannot be used as bare functions #15694

Closed
alexcrichton opened this issue Jul 15, 2014 · 12 comments · Fixed by #64104
Closed

ICE: Intrinsics cannot be used as bare functions #15694

alexcrichton opened this issue Jul 15, 2014 · 12 comments · Fixed by #64104
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-intrinsics Area: Intrinsics C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority

Comments

@alexcrichton
Copy link
Member

use std::mem;
fn main() {
    let foo: unsafe extern "rust-intrinsic" fn(int) -> uint = mem::transmute;
}
error: internal compiler error: type_of_fn_from_ty given intrinsic
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libsyntax/diagnostic.rs:168

stack backtrace:
   1:     0x7fef4d200700 - rt::backtrace::imp::write::hb13fea49bb048a16t7p
   2:     0x7fef4d203f60 - failure::on_fail::h9d7e4a53278c9fd4Isq
   3:     0x7fef4f3c5380 - unwind::begin_unwind_inner::h9b55d31cfec63a9e40d
   4:     0x7fef4e817f60 - unwind::begin_unwind::h6688588397384763373
   5:     0x7fef4e8189e0 - diagnostic::Handler::bug::hf9282ddbf40f02cdD7x
   6:     0x7fef4fcb48c0 - driver::session::Session::bug::h413fd6790eb808dezKt
   7:     0x7fef4fd17f40 - middle::trans::type_of::type_of_fn_from_ty::ha93e3da19746d402D1l
   8:     0x7fef4fced6d0 - middle::trans::type_of::type_of::hccb705ddd25f92a9m8l
   9:     0x7fef4fced6d0 - middle::trans::type_of::type_of::hccb705ddd25f92a9m8l
  10:     0x7fef4fd204d0 - middle::trans::base::alloc_ty::hcc73611ba42cbda6evq
  11:     0x7fef4fde4fd0 - middle::trans::_match::mk_binding_alloca::h6351421435439841194
  12:     0x7fef4fda3330 - middle::trans::_match::store_local::h389ac59cc1432597Xgu
  13:     0x7fef4fcde640 - middle::trans::base::init_local::hae246c057ffae08bokq
  14:     0x7fef4fcddbb0 - middle::trans::controlflow::trans_stmt::h5881ee2c68ca05adujc
  15:     0x7fef4fcdf7b0 - middle::trans::controlflow::trans_block::hf4a9df4bed2f4062Koc
  16:     0x7fef4fda8d40 - middle::trans::base::trans_closure::h99b852c61fb600405Oq
  17:     0x7fef4fcb5de0 - middle::trans::base::trans_fn::hff994e23508bf238WWq
  18:     0x7fef4fcae040 - middle::trans::base::trans_item::hddfe13c076996e13idr
  19:     0x7fef4fdba280 - middle::trans::base::trans_crate::h30e1597c28fe078eW6r
  20:     0x7fef504f4390 - driver::driver::phase_4_translate_to_llvm::hb78a58fecc8fdc0fYRs
  21:     0x7fef504eb460 - driver::driver::compile_input::h654602b6e7bf955aqus
  22:     0x7fef505a24a0 - driver::run_compiler::ha6a951e558622772tsv
  23:     0x7fef505a23b0 - driver::main_args::closure.$x22closure$x22$LP$134259$RP$
  24:     0x7fef505b6200 - task::TaskBuilder<S>::try_future::closure.$x22closure$x22$LP$135408$RP$
  25:     0x7fef505b5f90 - task::TaskBuilder<S>::spawn_internal::closure.$x22closure$x22$LP$135385$RP$
  26:     0x7fef4f723d80 - task::spawn_opts::closure.$x22closure$x22$LP$8156$RP$
  27:     0x7fef4f41b5c0 - rust_try
  28:     0x7fef4f3c2410 - unwind::try::hc59e8203d98cfea8tPd
  29:     0x7fef4f3c2170 - task::Task::run::hc5aad491de06c5bcP0c
  30:     0x7fef4f723b70 - task::spawn_opts::closure.$x22closure$x22$LP$8102$RP$
  31:     0x7fef4f3c43f0 - thread::thread_start::h597549996b7dcb76nnd
  32:     0x7fef4cc810c0 - start_thread
  33:     0x7fef4f0872d9 - __clone
  34:                0x0 - <unknown>
@brson
Copy link
Contributor

brson commented Jul 16, 2014

This is the one thing preventing removal of the transmute library wrapper, and was my primary motivation for RFC 5.

I recently started implementing RFC 5 and realized that the substance of it isn't very important, and I'm not sure I even like the resulting design because it ends up with more special cases.

All we really need is to fix this issue. I'm poking at it casually but if somebody else wants to tackle it, great.

@brson
Copy link
Contributor

brson commented Jul 16, 2014

Oh, actually, just fixing this isn't quite enough to remove the transmute wrapper. We also need extern "rust-intrinsic" fn() to coerce to fn().

@luqmana
Copy link
Member

luqmana commented Jul 16, 2014

@brson There is no transmute wrapper that I'm aware of. std::mem is just a reexport of core::mem and core::mem::transmute is just an alias to core::intrinsics::transmute.

@Twisol
Copy link

Twisol commented Jan 4, 2015

ICEs on the current nightly with a much longer error message ("can't monomorphize a ...."):

$ rustc --verbose --version
rustc 0.13.0-nightly (c6c786671 2015-01-04 00:50:59 +0000)
binary: rustc
commit-hash: c6c786671d692d7b13c2e5c68a53001327b4b125
commit-date: 2015-01-04 00:50:59 +0000
host: x86_64-apple-darwin
release: 0.13.0-nightly
$ env RUST_BACKTRACE=1 rustc foo.rs
foo.rs:3:9: 3:12 warning: unused variable: `foo`, #[warn(unused_variables)] on by default
foo.rs:3     let foo: unsafe extern "rust-intrinsic" fn(int) -> uint = mem::transmute;
                 ^~~
error: internal compiler error: can't monomorphize a NodeForeignItem(ForeignItem { ident: "transmute"(66)#0, attrs: [Spanned { node: Attribute_ { id: AttrId(1031), style: AttrOuter, value: Spanned { node: MetaNameValue(doc, Spanned { node: LitStr(/// Unsafely transforms a value of one type into a value of another type., CookedStr), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, is_sugared_doc: true }, span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, Spanned { node: Attribute_ { id: AttrId(1032), style: AttrOuter, value: Spanned { node: MetaNameValue(doc, Spanned { node: LitStr(///, CookedStr), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, is_sugared_doc: true }, span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, Spanned { node: Attribute_ { id: AttrId(1033), style: AttrOuter, value: Spanned { node: MetaNameValue(doc, Spanned { node: LitStr(/// Both types must have the same size and alignment, and this guarantee, CookedStr), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, is_sugared_doc: true }, span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, Spanned { node: Attribute_ { id: AttrId(1034), style: AttrOuter, value: Spanned { node: MetaNameValue(doc, Spanned { node: LitStr(/// is enforced at compile-time., CookedStr), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, is_sugared_doc: true }, span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, Spanned { node: Attribute_ { id: AttrId(1035), style: AttrOuter, value: Spanned { node: MetaNameValue(doc, Spanned { node: LitStr(///, CookedStr), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, is_sugared_doc: true }, span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, Spanned { node: Attribute_ { id: AttrId(1036), style: AttrOuter, value: Spanned { node: MetaNameValue(doc, Spanned { node: LitStr(/// # Examples, CookedStr), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, is_sugared_doc: true }, span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, Spanned { node: Attribute_ { id: AttrId(1037), style: AttrOuter, value: Spanned { node: MetaNameValue(doc, Spanned { node: LitStr(///, CookedStr), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, is_sugared_doc: true }, span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, Spanned { node: Attribute_ { id: AttrId(1038), style: AttrOuter, value: Spanned { node: MetaNameValue(doc, Spanned { node: LitStr(/// ```rust, CookedStr), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, is_sugared_doc: true }, span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, Spanned { node: Attribute_ { id: AttrId(1039), style: AttrOuter, value: Spanned { node: MetaNameValue(doc, Spanned { node: LitStr(/// use std::mem;, CookedStr), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, is_sugared_doc: true }, span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, Spanned { node: Attribute_ { id: AttrId(1040), style: AttrOuter, value: Spanned { node: MetaNameValue(doc, Spanned { node: LitStr(///, CookedStr), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, is_sugared_doc: true }, span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, Spanned { node: Attribute_ { id: AttrId(1041), style: AttrOuter, value: Spanned { node: MetaNameValue(doc, Spanned { node: LitStr(/// let v: &[u8] = unsafe { mem::transmute("L") };, CookedStr), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, is_sugared_doc: true }, span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, Spanned { node: Attribute_ { id: AttrId(1042), style: AttrOuter, value: Spanned { node: MetaNameValue(doc, Spanned { node: LitStr(/// assert!(v == [76u8]);, CookedStr), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, is_sugared_doc: true }, span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, Spanned { node: Attribute_ { id: AttrId(1043), style: AttrOuter, value: Spanned { node: MetaNameValue(doc, Spanned { node: LitStr(/// ```, CookedStr), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, is_sugared_doc: true }, span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, Spanned { node: Attribute_ { id: AttrId(1044), style: AttrOuter, value: Spanned { node: MetaWord(stable), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, is_sugared_doc: false }, span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }], node: ForeignItemFn(FnDecl { inputs: [Arg { ty: Ty { id: 23, node: TyPath(Path { span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) }, global: false, segments: [PathSegment { identifier: "T"(215)#0, parameters: AngleBracketedParameters(AngleBracketedParameterData { lifetimes: [], types: [], bindings: [] }) }] }, 24), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, pat: Pat { id: 22, node: PatIdent(BindByValue(MutImmutable), Spanned { node: "e"(827)#0, span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, None), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, id: 21 }], output: Return(Ty { id: 25, node: TyPath(Path { span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) }, global: false, segments: [PathSegment { identifier: "U"(785)#0, parameters: AngleBracketedParameters(AngleBracketedParameterData { lifetimes: [], types: [], bindings: [] }) }] }, 26), span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }), variadic: false }, Generics { lifetimes: [], ty_params: [TyParam { ident: "T"(215)#0, id: 27, bounds: [], default: None, span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }, TyParam { ident: "U"(785)#0, id: 28, bounds: [], default: None, span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) } }], where_clause: WhereClause { id: 29, predicates: [] } }), id: 20, span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) }, vis: Public })
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libsyntax/diagnostic.rs:182

stack backtrace:
   1:        0x10cec1a85 - sys::backtrace::write::h99bbbbef588b9184Klt
   2:        0x10cee6f1f - failure::on_fail::h8b1c6fd57e4213d95nz
   3:        0x10ce4b95a - rt::unwind::begin_unwind_inner::hfd8d974c1cdeb74f35y
   4:        0x10ab49b17 - rt::unwind::begin_unwind::h5235829026449479069
   5:        0x10ab4a488 - diagnostic::Handler::bug::h72cca12a0dd401ceDLF
   6:        0x10a160778 - session::Session::bug::h97e7302b0910d3e2lrq
   7:        0x1096fd619 - trans::monomorphize::monomorphic_fn::h38e56ba386e94ac9Snd
   8:        0x109748977 - trans::callee::trans_fn_ref_with_substs::h6a01a4be71e1beb1ewg
   9:        0x109745577 - trans::callee::trans_fn_ref::hf307be0be67e1605Ykg
  10:        0x10976b91a - trans::expr::trans_def::h1d52728ad739099eWKi
  11:        0x109754c83 - trans::expr::trans_unadjusted::hb2acbb87da4fa8eb7ii
  12:        0x10970f440 - trans::expr::trans_into::h0995e46f3b8447c0Owh
  13:        0x10981364f - trans::_match::mk_binding_alloca::h14553518544565681418
  14:        0x10970e7d2 - trans::base::init_local::hba63ae135471a61cB1s
  15:        0x10970fc90 - trans::controlflow::trans_block::h7b1e02bd6913eed7Q1d
  16:        0x1097d9914 - trans::base::trans_closure::h602c945d09839558sSt
  17:        0x1096fb4cb - trans::base::trans_fn::h122108ebc597d915Z2t
  18:        0x1096f6b26 - trans::base::trans_item::h542c93e65da12cf3Qpu
  19:        0x1097e1118 - trans::base::trans_crate::hd65661651c173516blv
  20:        0x109598a0e - driver::phase_4_translate_to_llvm::hc36550ced8732ffcvFa
  21:        0x10957a8c1 - driver::compile_input::h3940b6305f304e80wba
  22:        0x109641853 - thunk::F.Invoke<A, R>::invoke::h10598202800189765697
  23:        0x10963e9b0 - rt::unwind::try::try_fn::h2354011666368721707
  24:        0x10cf4f409 - rust_try_inner
  25:        0x10cf4f3f6 - rust_try
  26:        0x10963f0f6 - thunk::F.Invoke<A, R>::invoke::h10531483554991743553
  27:        0x10ced2ed4 - sys::thread::thread_start::h156b750c645e6d54M8v
  28:     0x7fff8f8de2fc - _pthread_body
  29:     0x7fff8f8de279 - _pthread_body

@tamird
Copy link
Contributor

tamird commented Apr 21, 2015

triage: still reproduces with slightly updated code:

use std::mem;
fn main() {
    let _: unsafe extern "rust-intrinsic" fn(isize) -> usize = mem::transmute;
}

@Aatch
Copy link
Contributor

Aatch commented Jun 26, 2015

Is it worth allowing intrinsics to be used as bare functions at all? I mean, they aren't actually functions in reality, they expand to some specific code inline. I don't think it's worth the implementation complexity to handle it.

I'd much rather make it a hard error during type checking than support the use case. I've not heard of anybody encountering this ICE in real code, which makes it seem unlikely that this is feature people expect to have. At the very least we can relax the restriction if I turn out to be wrong and this is something people do want.

@nagisa
Copy link
Member

nagisa commented Jan 22, 2016

The error is now different:

error: internal compiler error: can't monomorphize a NodeForeignItem(ForeignItem { name: transmute(66), attrs: [Spanned { node: Attribute_ { id: AttrId(1487), style: Outer, value: Spanned { node: MetaNameValue("doc", Spanned { node: LitStr("/// Unsafely transforms a value of one type into a value of another type.", CookedStr), span: ../src/libcore/intrinsics.rs:146:29: 148:54 }), span: ../src/libcore/intrinsics.rs:260:5: 260:78 }, is_sugared_doc: true }, span: ../src/libcore/intrinsics.rs:260:5: 260:78 }, Spanned { node: Attribute_ { id: AttrId(1488), style: Outer, value: Spanned { node: MetaNameValue("doc", Spanned { node: LitStr("///", CookedStr), span: ../src/libcore/intrinsics.rs:148:59: 148:62 }), span: ../src/libcore/intrinsics.rs:261:5: 261:8 }, is_sugared_doc: true }, span: ../src/libcore/intrinsics.rs:261:5: 261:8 }, Spanned { node: Attribute_ { id: AttrId(1489), style: Outer, value: Spanned { node: MetaNameValue("doc", Spanned { node: LitStr("/// Both types must have the same size.", CookedStr), span: ../src/libcore/intrinsics.rs:148:67: 149:31 }), span: ../src/libcore/intrinsics.rs:262:5: 262:44 }, is_sugared_doc: true }, span: ../src/libcore/intrinsics.rs:262:5: 262:44 }, Spanned { node: Attribute_ { id: AttrId(1490), style: Outer, value: Spanned { node: MetaNameValue("doc", Spanned { node: LitStr("///", CookedStr), span: ../src/libcore/intrinsics.rs:149:36: 149:39 }), span: ../src/libcore/intrinsics.rs:263:5: 263:8 }, is_sugared_doc: true }, span: ../src/libcore/intrinsics.rs:263:5: 263:8 }, Spanned { node: Attribute_ { id: AttrId(1491), style: Outer, value: Spanned { node: MetaNameValue("doc", Spanned { node: LitStr("/// # Examples", CookedStr), span: ../src/libcore/intrinsics.rs:149:44: 149:58 }), span: ../src/libcore/intrinsics.rs:264:5: 264:19 }, is_sugared_doc: true }, span: ../src/libcore/intrinsics.rs:264:5: 264:19 }, Spanned { node: Attribute_ { id: AttrId(1492), style: Outer, value: Spanned { node: MetaNameValue("doc", Spanned { node: LitStr("///", CookedStr), span: ../src/libcore/intrinsics.rs:149:63: 149:66 }), span: ../src/libcore/intrinsics.rs:265:5: 265:8 }, is_sugared_doc: true }, span: ../src/libcore/intrinsics.rs:265:5: 265:8 }, Spanned { node: Attribute_ { id: AttrId(1493), style: Outer, value: Spanned { node: MetaNameValue("doc", Spanned { node: LitStr("/// ```", CookedStr), span: ../src/libcore/intrinsics.rs:150:1: 150:8 }), span: ../src/libcore/intrinsics.rs:266:5: 266:12 }, is_sugared_doc: true }, span: ../src/libcore/intrinsics.rs:266:5: 266:12 }, Spanned { node: Attribute_ { id: AttrId(1494), style: Outer, value: Spanned { node: MetaNameValue("doc", Spanned { node: LitStr("/// use std::mem;", CookedStr), span: ../src/libcore/intrinsics.rs:150:13: 150:30 }), span: ../src/libcore/intrinsics.rs:267:5: 267:22 }, is_sugared_doc: true }, span: ../src/libcore/intrinsics.rs:267:5: 267:22 }, Spanned { node: Attribute_ { id: AttrId(1495), style: Outer, value: Spanned { node: MetaNameValue("doc", Spanned { node: LitStr("///", CookedStr), span: ../src/libcore/intrinsics.rs:150:35: 150:38 }), span: ../src/libcore/intrinsics.rs:268:5: 268:8 }, is_sugared_doc: true }, span: ../src/libcore/intrinsics.rs:268:5: 268:8 }, Spanned { node: Attribute_ { id: AttrId(1496), style: Outer, value: Spanned { node: MetaNameValue("doc", Spanned { node: LitStr("/// let array: &[u8] = unsafe { mem::transmute(\"Rust\") };", CookedStr), span: ../src/libcore/intrinsics.rs:150:43: 151:23 }), span: ../src/libcore/intrinsics.rs:269:5: 269:62 }, is_sugared_doc: true }, span: ../src/libcore/intrinsics.rs:269:5: 269:62 }, Spanned { node: Attribute_ { id: AttrId(1497), style: Outer, value: Spanned { node: MetaNameValue("doc", Spanned { node: LitStr("/// assert_eq!(array, [82, 117, 115, 116]);", CookedStr), span: ../src/libcore/intrinsics.rs:151:28: 152:16 }), span: ../src/libcore/intrinsics.rs:270:5: 270:48 }, is_sugared_doc: true }, span: ../src/libcore/intrinsics.rs:270:5: 270:48 }, Spanned { node: Attribute_ { id: AttrId(1498), style: Outer, value: Spanned { node: MetaNameValue("doc", Spanned { node: LitStr("/// ```", CookedStr), span: ../src/libcore/intrinsics.rs:152:21: 152:28 }), span: ../src/libcore/intrinsics.rs:271:5: 271:12 }, is_sugared_doc: true }, span: ../src/libcore/intrinsics.rs:271:5: 271:12 }, Spanned { node: Attribute_ { id: AttrId(1499), style: Outer, value: Spanned { node: MetaList("stable", [Spanned { node: MetaNameValue("feature", Spanned { node: LitStr("rust1", CookedStr), span: ../src/libcore/intrinsics.rs:153:13: 153:20 }), span: ../src/libcore/intrinsics.rs:272:14: 272:32 }, Spanned { node: MetaNameValue("since", Spanned { node: LitStr("1.0.0", CookedStr), span: ../src/libcore/intrinsics.rs:153:30: 153:37 }), span: ../src/libcore/intrinsics.rs:272:33: 272:49 }]), span: ../src/libcore/intrinsics.rs:272:7: 272:50 }, is_sugared_doc: false }, span: ../src/libcore/intrinsics.rs:272:5: 272:50 }], node: ForeignItemFn(FnDecl { inputs: [Arg { ty: type(T), pat: pat(18: e), id: 17 }], output: Return(type(U)), variadic: false }, Generics { lifetimes: [], ty_params: [TyParam { name: T(1016), id: 21, bounds: [], default: None, span: ../src/libcore/intrinsics.rs:154:18: 154:19 }, TyParam { name: U(2682), id: 22, bounds: [], default: None, span: ../src/libcore/intrinsics.rs:154:21: 154:22 }], where_clause: WhereClause { id: 23, predicates: [] } }), id: 16, span: ../src/libcore/intrinsics.rs:273:5: 273:39, vis: Public })

@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 21, 2017
@topecongiro
Copy link
Contributor

Triage:

#![feature(intrinsics)]
use std::mem;
fn main() {
    let _: unsafe extern "rust-intrinsic" fn(isize) -> usize = mem::transmute;
}

gets the following error

error: internal compiler error: /checkout/src/librustc_trans/collector.rs:687: intrinsic DefId { krate: CrateNum(2), node: DefIndex(2147484755) => core/1c47e0c::intrinsics[0]::[1]::transmute[0] } being reified

with rustc 1.21.0-nightly (37c7d0ebb 2017-07-31).

@cyplo
Copy link
Contributor

cyplo commented Dec 23, 2018

Still reproduces with rustc 1.33.0-nightly (2d3e909e4 2018-12-22) running on x86_64-unknown-linux-gnu

@varkor varkor added the A-intrinsics Area: Intrinsics label May 8, 2019
@oli-obk oli-obk added the A-diagnostics Area: Messages for errors, warnings, and lints label Jun 3, 2019
@pnkfelix
Copy link
Member

pnkfelix commented Jun 3, 2019

Triage. AFAICT this ICE depends on the unstable feature(intrinsics), which is not on the 2019 roadmap. (I could not find a tracking issue for feature(intrinsics); I'm not sure if its something that will ever make sense to stabilize, given how intertwined it must be with the compiler itself.

Triaging as P-medium until either 1. someone provides argument that the feature(intrinsics) is on a path to stabilization or 2. someone shows that the ICE is not dependent on feature(intrinsics).

@pnkfelix pnkfelix added the P-medium Medium priority label Jun 3, 2019
@pnkfelix
Copy link
Member

pnkfelix commented Jun 3, 2019

(also, I agree with @Aatch that we should make this a proper error. I do not see much motivation for trying to support this via e.g. generated shim code.)

@oli-obk
Copy link
Contributor

oli-obk commented Jun 3, 2019

cc @rust-lang/wg-diagnostics if anyone wants to grab an ICE -> error conversion

Centril added a commit to Centril/rust that referenced this issue Sep 3, 2019
…e, r=estebank

Emit error on intrinsic to fn ptr casts

I'm not sure if a type error is the best way of doing this but it seemed like a relatively correct place to do it, and I expect this is a pretty rare case to hit anyway.

Fixes rust-lang#15694
Centril added a commit to Centril/rust that referenced this issue Sep 3, 2019
…e, r=estebank

Emit error on intrinsic to fn ptr casts

I'm not sure if a type error is the best way of doing this but it seemed like a relatively correct place to do it, and I expect this is a pretty rare case to hit anyway.

Fixes rust-lang#15694
@bors bors closed this as completed in 24e3b1d Sep 3, 2019
This was referenced Nov 8, 2020
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 13, 2023
…eykril

feat: add assist for applying De Morgan's law to `Iterator::all` and `Iterator::any`

This PR adds an assist for transforming expressions of the form `!iter.any(|x| predicate(x))` into `iter.all(|x| !predicate(x))` and vice versa.

[IteratorDeMorgans.webm](https://github.com/rust-lang/rust-analyzer/assets/52933714/aad1a299-6620-432b-9106-aafd2a7fa9f5)

Closes rust-lang#15694
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-intrinsics Area: Intrinsics C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.