about summary refs log tree commit diff
path: root/src/libcore/intrinsics.rs
AgeCommit message (Collapse)AuthorLines
2020-04-29document stable counterparts of intrinsicsBastian Kauschke-12/+84
2020-04-25Bump bootstrap compilerMark Rousskov-33/+0
2020-04-18Add example in the alternative in std::mem::transmute docshuangjiahua-0/+18
It is safer to use `from_ne_bytes` to convert raw bytes to type like u32.
2020-04-03Replace max/min_value() with MAX/MIN assoc constsLinus Färnstrand-6/+6
2020-03-29Stabilize float::to_int_uncheckedMark Rousskov-0/+8
This renames and stabilizes unsafe floating point to integer casts, which are intended to be the substitute for the currently unsound `as` behavior, once that changes to safe-but-slower saturating casts.
2020-03-29Rollup merge of #70101 - tmiasko:intrinsics-copy, r=eddybMazdak Farrokhzad-112/+112
Add copy bound to atomic & numeric intrinsics
2020-03-22Auto merge of #69079 - CAD97:layout-of-ptr, r=RalfJungbors-0/+11
Allow calculating the layout behind a pointer There was some discussion around allowing this previously. This does make the requirement for raw pointers to have valid metadata exposed as part of the std API (as a safety invariant, not validity invariant), though I think this is not strictly necessarily required as of current. cc @rust-lang/wg-unsafe-code-guidelines Naming is hard; I picked the best "obvious" name I could come up with. If it's agreed that this is actually a desired API surface, I'll file a tracking issue and update the attributes.
2020-03-21Allow calculating the layout behind a pointerCAD97-0/+11
Let align/size_of_of_val intrinsics work on ptrs
2020-03-19Add copy bound to numeric intrinsicsTomasz Miąsko-31/+31
2020-03-19Add copy bound to atomic intrinsicsTomasz Miąsko-81/+81
2020-03-17Rollup merge of #69922 - RalfJung:less-intrinsic, r=oli-obkMazdak Farrokhzad-39/+1
implement zeroed and uninitialized with MaybeUninit This is the second attempt of doing such a change (first PR: https://github.com/rust-lang/rust/pull/62150). The last change [got reverted](https://github.com/rust-lang/rust/pull/63343) because it [caused](https://github.com/rust-lang/rust/issues/62825) some [issues](https://github.com/rust-lang/rust/issues/52898#issuecomment-512182438) in [code that incorrectly used these functions](https://github.com/erlepereira/x11-rs/issues/99). Since then, the [problematic code has been fixed](https://github.com/erlepereira/x11-rs/pull/101), and rustc [gained a lint](https://github.com/rust-lang/rust/pull/63346) that is able to detect many misuses of these functions statically and a [dynamic check that panics](https://github.com/rust-lang/rust/pull/66059) instead of causing UB for some incorrect uses. Fixes https://github.com/rust-lang/rust/issues/62825
2020-03-14adjust Miri interaction with panic runtimeRalf Jung-3/+5
2020-03-13Auto merge of #67502 - Mark-Simulacrum:opt-catch, r=Mark-Simulacrumbors-6/+8
Optimize catch_unwind to match C++ try/catch This refactors the implementation of catching unwinds to allow LLVM to inline the "try" closure directly into the happy path, avoiding indirection. This means that the catch_unwind implementation is (after this PR) zero-cost unless a panic is thrown. https://rust.godbolt.org/z/cZcUSB is an example of the current codegen in a simple case. Notably, the codegen is *exactly the same* if `-Cpanic=abort` is passed, which is clearly not great. This PR, on the other hand, generates the following assembly: ```asm # -Cpanic=unwind: push rbx mov ebx,0x2a call QWORD PTR [rip+0x1c53c] # <happy> mov eax,ebx pop rbx ret mov rdi,rax call QWORD PTR [rip+0x1c537] # cleanup function call call QWORD PTR [rip+0x1c539] # <unfortunate> mov ebx,0xd mov eax,ebx pop rbx ret # -Cpanic=abort: push rax call QWORD PTR [rip+0x20a1] # <happy> mov eax,0x2a pop rcx ret ``` Fixes #64224, and resolves #64222.
2020-03-12rename panic_if_ intrinsics to assert_Ralf Jung-2/+8
2020-03-11implement zeroed and uninitialized with MaybeUninitRalf Jung-39/+1
2020-03-11Rollup merge of #69825 - lcnr:discriminant, r=oli-obkMazdak Farrokhzad-0/+1
make `mem::discriminant` const implements #69821, which could be used as a tracking issue for `const_discriminant`. Should this be added to the meta tracking issue #57563? @Lokathor
2020-03-11Rollup merge of #66059 - RalfJung:panic-on-non-zero, r=eddybMazdak Farrokhzad-0/+10
mem::zeroed/uninit: panic on types that do not permit zero-initialization r? @eddyb @oli-obk Cc https://github.com/rust-lang/rust/issues/62825 Also see [this summary comment](https://github.com/rust-lang/rust/pull/66059#issuecomment-586734747)
2020-03-08constify `mem::discriminant`Bastian Kauschke-0/+1
2020-03-05Simplify the try intrinsic by using a callback in the catch blockAmanieu d'Antras-6/+8
2020-03-02Rollup merge of #68682 - LeSeulArtichaut:stable-intrinsics, r=steveklabnikDylan DPC-7/+471
Add documentation to compiler intrinsics This adds documentation to the compiler intrinsics having stable standard implementations. Relates to #34338 (cc @bstrie) r? @steveklabnik (for reassignment?)
2020-02-29Fix typoRalf Jung-1/+1
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2020-02-29transmute: improve Vec exampleRalf Jung-6/+10
2020-02-29mem::zeroed/uninit: panic on types that do not permit zero-initializationRalf Jung-0/+10
2020-02-29Auto merge of #69208 - RalfJung:debug-assert, r=Mark-Simulacrumbors-4/+6
debug_assert a few more raw pointer methods Makes progress for https://github.com/rust-lang/rust/issues/53871
2020-02-27avoid a negation in is_nonoverlappingRalf Jung-2/+3
2020-02-22Add rustdoc aliases to `ptr::copy` and `ptr::copy_nonoverlapping`memoryruins-0/+2
2020-02-16debug_assert a few more raw pointer methodsRalf Jung-4/+5
2020-02-11Document stabilized versions of atomic singlethreaded fencesLeSeulArtichaut-0/+24
2020-02-11Remove references to `wrapping` methodsLeSeulArtichaut-10/+10
2020-02-11Fix mistake in atomic comparaison docsLeSeulArtichaut-19/+19
2020-02-11Add newline between summary and stable version documentationLeSeulArtichaut-1/+144
2020-02-11Document stable versions of number-related intrinsicsLeSeulArtichaut-2/+32
2020-02-11Document stable versions of memory-related intrinsicsLeSeulArtichaut-0/+25
2020-02-11Document stable versions of `type_name` and `type_id`LeSeulArtichaut-0/+4
2020-02-11Document stable versions of `f32` and `f64` intrinsicsLeSeulArtichaut-0/+238
Fix links
2020-02-04Const-stabilize some arithmetic intrinsicsDylan MacKenzie-0/+5
2019-12-25Use issue = "none" instead of "0" in intrinsicsKonrad Borowski-6/+6
2019-12-23Rollup merge of #67466 - oli-obk:const_intrinsic, r=CentrilMazdak Farrokhzad-0/+43
Require const stability attributes on intrinsics to be able to use them in constant contexts r? @Centril finally fixes #61495 cc @RalfJung
2019-12-23Fix typoOliver Scherer-1/+1
2019-12-22Format the worldMark Rousskov-23/+23
2019-12-21Require issue = "none" over issue = "0" in unstable attributesRoss MacArthur-3/+3
2019-12-21Add a big notice about const intrinsicsOliver Scherer-0/+16
2019-12-20Require const stability attributes on intrinsics to be able to use them in ↵Oliver Scherer-1/+28
constant contexts
2019-12-18Propagate cfg bootstrapMark Rousskov-7/+1
2019-12-13Require stable/unstable annotations for the constness of all stable ↵Oliver Scherer-1/+5
functions with a `const` modifier
2019-12-06Add `{f32,f64}::approx_unchecked_to<Int>` unsafe methodsSimon Sapin-0/+5
As discussed in https://github.com/rust-lang/rust/issues/10184 Currently, casting a floating point number to an integer with `as` is Undefined Behavior if the value is out of range. `-Z saturating-float-casts` fixes this soundness hole by making `as` “saturate” to the maximum or minimum value of the integer type (or zero for `NaN`), but has measurable negative performance impact in some benchmarks. There is some consensus in that thread for enabling saturation by default anyway, but provide an `unsafe fn` alternative for users who know through some other mean that their values are in range.
2019-12-03Check intrinsics for callability in const fnsMahmut Bulut-0/+1
2019-11-30libunwind_panic: adjust miri panic hackRalf Jung-1/+3
2019-11-26Fix spelling typosBrian Wignall-1/+1
2019-11-13Auto merge of #66156 - Mark-Simulacrum:stage0-step, r=pietroalbinibors-2/+0
Stage0 step r? @pietroalbini