rust/src/test
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
..
assembly Support LLVM 12 in rustc 2021-02-28 10:19:44 +01:00
auxiliary
codegen Rollup merge of #82799 - bugadani:codegen-tests, r=nagisa 2021-03-09 09:05:23 +00:00
codegen-units
debuginfo Update tests for extern block linting 2021-01-13 07:49:16 -05:00
incremental Revert "Auto merge of #79637 - spastorino:revert-trait-inheritance-self, r=Mark-Simulacrum" 2021-02-05 18:56:56 -03:00
mir-opt Disable destination propagation on all mir-opt-levels 2021-03-06 00:00:00 +00:00
pretty Fix pretty printing of generic associated type constraints 2021-02-13 19:29:55 +00:00
run-make Remove storage markers if they won't be used during code generation 2021-02-28 20:10:44 +01:00
run-make-fulldeps Add an unstable option to print all unversioned files 2021-03-05 15:31:30 -05:00
run-pass-valgrind Update tests for extern block linting 2021-01-13 07:49:16 -05:00
rustdoc Rollup merge of #80763 - petrochenkov:pubusecrate, r=estebank 2021-03-05 10:57:15 +01:00
rustdoc-gui Add GUI tests 2021-02-28 23:01:29 +01:00
rustdoc-js Add test for primitive search 2021-02-01 15:56:51 +01:00
rustdoc-js-std Add search index test for primitive types 2021-01-27 10:05:06 +01:00
rustdoc-json Remove krate.version; fix crate_version in JSON 2021-03-01 00:30:40 -05:00
rustdoc-ui Rollup merge of #82651 - jyn514:rustdoc-warnings, r=GuillaumeGomez 2021-03-07 10:41:13 +09:00
rustfix
ui Rollup merge of #79208 - LeSeulArtichaut:stable-unsafe_op_in_unsafe_fn, r=nikomatsakis 2021-03-10 08:01:25 +09:00
ui-fulldeps Allow/fix non_fmt_panic in tests. 2021-02-03 23:15:45 +01:00
COMPILER_TESTS.md