rust/compiler/rustc_data_structures
Jonas Schievink ae1916b3b4
Rollup merge of #79058 - dtolnay:likelymacro, r=Mark-Simulacrum
Move likely/unlikely argument outside of invisible unsafe block

The previous `likely!`/`unlikely!` macros were unsound because it permits the caller's expr to contain arbitrary unsafe code.

```rust
pub fn huh() -> bool {
    likely!(std::ptr::read(&() as *const () as *const bool))
}
```

**Before:** compiles cleanly.
**After:**

```console
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
   |
70 |     likely!(std::ptr::read(&() as *const () as *const bool))
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
   |
   = note: consult the function's documentation for information on how to avoid undefined behavior
```
2020-11-15 13:40:03 +01:00
..
src Rollup merge of #79058 - dtolnay:likelymacro, r=Mark-Simulacrum 2020-11-15 13:40:03 +01:00
Cargo.toml Upgrade to measureme 9.0.0 2020-10-24 22:39:42 -04:00