rust/library/core/tests
Yuki Okushi c46f948a80
Rollup merge of #79208 - LeSeulArtichaut:stable-unsafe_op_in_unsafe_fn, r=nikomatsakis
Stabilize `unsafe_op_in_unsafe_fn` lint

This makes it possible to override the level of the `unsafe_op_in_unsafe_fn`, as proposed in https://github.com/rust-lang/rust/issues/71668#issuecomment-729770896.

Tracking issue: #71668
r? ```@nikomatsakis``` cc ```@SimonSapin``` ```@RalfJung```

# Stabilization report

This is a stabilization report for `#![feature(unsafe_block_in_unsafe_fn)]`.

## Summary

Currently, the body of unsafe functions is an unsafe block, i.e. you can perform unsafe operations inside.

The `unsafe_op_in_unsafe_fn` lint, stabilized here, can be used to change this behavior, so performing unsafe operations in unsafe functions requires an unsafe block.

For now, the lint is allow-by-default, which means that this PR does not change anything without overriding the lint level.

For more information, see [RFC 2585](https://github.com/rust-lang/rfcs/blob/master/text/2585-unsafe-block-in-unsafe-fn.md)

### Example

```rust
// An `unsafe fn` for demonstration purposes.
// Calling this is an unsafe operation.
unsafe fn unsf() {}

// #[allow(unsafe_op_in_unsafe_fn)] by default,
// the behavior of `unsafe fn` is unchanged
unsafe fn allowed() {
    // Here, no `unsafe` block is needed to
    // perform unsafe operations...
    unsf();

    // ...and any `unsafe` block is considered
    // unused and is warned on by the compiler.
    unsafe {
        unsf();
    }
}

#[warn(unsafe_op_in_unsafe_fn)]
unsafe fn warned() {
    // Removing this `unsafe` block will
    // cause the compiler to emit a warning.
    // (Also, no "unused unsafe" warning will be emitted here.)
    unsafe {
        unsf();
    }
}

#[deny(unsafe_op_in_unsafe_fn)]
unsafe fn denied() {
    // Removing this `unsafe` block will
    // cause a compilation error.
    // (Also, no "unused unsafe" warning will be emitted here.)
    unsafe {
        unsf();
    }
}
```
2021-03-10 08:01:25 +09:00
..
fmt
hash
iter Add relevant test 2021-03-05 19:09:23 +01:00
num Re-enable all num tests on WASM 2021-01-15 16:58:44 -05:00
ops Expand the docs for ops::ControlFlow a bit 2021-02-06 22:36:05 -08:00
alloc.rs
any.rs
array.rs Rollup merge of #76454 - poliorcetics:ui-to-unit-test-1, r=matklad 2020-09-28 18:39:39 +02:00
ascii.rs Make ui test that are run-pass and do not test the compiler itself library tests 2020-11-30 02:47:32 +01:00
atomic.rs enable atomic_min/max tests in Miri 2021-03-02 19:58:55 +01:00
bool.rs Make ui test that are run-pass and do not test the compiler itself library tests 2020-11-30 02:47:32 +01:00
cell.rs Constantify UnsafeCell::into_inner and related 2020-11-04 11:41:57 +01:00
char.rs
clone.rs Fix borrow and deref 2021-03-03 11:23:29 +01:00
cmp.rs Make ui test that are run-pass and do not test the compiler itself library tests 2020-11-30 02:47:32 +01:00
const_ptr.rs Constify ptr::write and the write[_unaligned] methods on *mut T 2021-02-23 18:00:01 +01:00
intrinsics.rs move test to intergrated test in library/core 2020-09-24 14:46:57 +00:00
lazy.rs Make OnceCell<T> transparent to dropck 2020-08-18 00:34:54 +02:00
lib.rs Rollup merge of #79208 - LeSeulArtichaut:stable-unsafe_op_in_unsafe_fn, r=nikomatsakis 2021-03-10 08:01:25 +09:00
macros.rs Make ui test that are run-pass and do not test the compiler itself library tests 2020-11-30 02:47:32 +01:00
manually_drop.rs
mem.rs Update the bootstrap compiler 2021-02-20 17:19:30 -05:00
nonzero.rs Added impl Rem<NonZeroU{0}> for u{0} which cannot panic 2020-12-17 18:42:19 +02:00
ops.rs Expand the docs for ops::ControlFlow a bit 2021-02-06 22:36:05 -08:00
option.rs Add unwrap_unchecked() methods for Option and Result 2021-01-10 15:14:38 +01:00
pattern.rs
pin.rs Make some methods of Pin<&mut T> unstable const 2020-09-18 19:23:50 +02:00
ptr.rs Add a ThinBox library as a libcore test for pointer metadata APIs 2021-02-15 14:27:51 +01:00
result.rs Rename Result::ok_or_err to Result::into_ok_or_err 2021-02-17 08:54:52 -08:00
slice.rs Fix binary_search_by() overflow issue in ZST case 2021-02-27 22:11:44 +08:00
str.rs
str_lossy.rs
task.rs Move const tests for Poll to library\core 2020-09-04 01:04:34 +02:00
time.rs Fixup tests: Duration::MIN -> ::ZERO 2020-10-27 13:57:51 -07:00
tuple.rs
unicode.rs Make ui test that are run-pass and do not test the compiler itself library tests 2020-11-30 02:47:32 +01:00