Add simd_{round,trunc} intrinsics
LLVM supports many functions from math.h in its IR. Many of these
have SIMD instructions on various platforms. So, let's add round and
trunc so std::arch can use them.
Yes, exact comparison is intentional: rounding must always return a
valid integer-equal value, except for inf/NAN.
Update docs for unsafe_op_in_unsafe_fn stability.
The unsafe_op_in_unsafe_fn lint was stabilized in #79208, but the bottom of this documentation wasn't updated.
I'm just guessing at the reason here, hopefully it is close to correct. The only discussion I found is https://github.com/rust-lang/rust/issues/71668#issuecomment-730399862 which didn't really explain the thought process behind the decision.
Update books
## nomicon
1 commits in 6fe476943afd53a9a6e91f38a6ea7bb48811d8ff..8551afbb2ca6f5ea37fe58380318b209785e4e02
2021-03-10 07:28:57 +0900 to 2021-04-01 21:58:50 +0900
- Add example of thinking about Send/Sync's soundness (rust-lang-nursery/nomicon#259)
## reference
10 commits in fd97729e2d82f8b08d68a31c9bfdf0c37a7fd542..e1abb17cd94cd5a8a374b48e1bc8134a2208ed48
2021-03-28 14:29:19 -0700 to 2021-04-07 08:09:48 -0700
- Update introduction.md (rust-lang-nursery/reference#1004)
- clarify UB for raw ptr deref (rust-lang-nursery/reference#1000)
- Update lint level documentation. (rust-lang-nursery/reference#998)
- Add rustdoc to tool lints. (rust-lang-nursery/reference#997)
- Link to ptr::addr_of on raw pointer docs (rust-lang-nursery/reference#993)
- apply rust-lang-nursery/reference#950 to STYLE.md (rust-lang-nursery/reference#980)
- Tuple Passover rust-lang-nursery/reference#2 (rust-lang-nursery/reference#990)
- Fix typo in macros-by-example.md (rust-lang-nursery/reference#996)
- Clarify object safety rules for methods striked from the vtable (rust-lang-nursery/reference#965)
- Add const generic args to const contexts. (rust-lang-nursery/reference#995)
## rust-by-example
1 commits in 29d91f591c90dd18fdca6d23f1a9caf9c139d0d7..c80f0b09fc15b9251825343be910c08531938ab2
2021-03-23 09:03:39 -0300 to 2021-04-08 10:28:17 -0300
- fix compile bug with panic! (rust-lang/rust-by-example#1433)
## rustc-dev-guide
11 commits in 0687daac28939c476df51778f5a1d1aff1a3fddf..a9bd2bbf31e4f92b5d3d8e80b22839d0cc7a2022
2021-03-28 13:33:56 -0400 to 2021-04-09 18:12:21 -0400
- Improve formatting and update info in "method lookup" section
- Change wording a bit: `module` => `crate`
- fix typo (rust-lang/rustc-dev-guide#1107)
- fix typo
- Mention CI build of LLVM in build instruction
- Fix rustdocs test command typo (rust-lang/rustc-dev-guide#1103)
- Update the "LLVM updates" section
- Fix a link about Rustdoc internals
- Add quickstart for adding a new optimization (rust-lang/rustc-dev-guide#1094)
- Add back example of {{cwd}} (rust-lang/rustc-dev-guide#1099)
- Document test input normalization
## embedded-book
1 commits in d3f2ace94d51610cf3e3c265705bb8416d37f8e4..569c3391f5c0cc43433bc77831d17f8ff4d76602
2021-03-17 07:53:09 +0000 to 2021-04-07 08:32:11 +0000
- Make it easier to copy and paste example commands. (rust-embedded/book#289)
Fix join_paths error display.
On unix, the error from `join_paths` looked like this:
```
path segment contains separator `58`
```
This PR changes it to look like this:
```
path segment contains separator `:`
```
Move `std::sys_common::alloc` to new module `std::sys::common`
6b56603e35/library/std/src/sys_common/mod.rs (L7-L13)
It was my impression that the goal for `std::sys` has changed from extracting it into a separate crate to making std work with features. However the fact remains that there is a lot of interdependence between `sys` and `sys_common`, this is because `sys_common` contains two types of code:
- abstractions over the different platform implementations in `std::sys` (for example [`std::sys_common::mutex`](https://github.com/rust-lang/rust/blob/master/library/std/src/sys_common/mutex.rs))
- code shared between platforms (for example [`std::sys_common::alloc`](https://github.com/rust-lang/rust/blob/master/library/std/src/sys_common/alloc.rs))
This PR attempts to address this by adding a new module `common` to `std::sys` which will contain code shared between platforms, `alloc.rs` in this case but more can be moved over in the future.
LLVM supports many functions from math.h in its IR. Many of these have
single-instruction variants on various platforms. So, let's add them so
std::arch can use them.
Yes, exact comparison is intentional: rounding must always return a
valid integer-equal value, except for inf/NAN.
add lint deref_nullptr detecting when a null ptr is dereferenced
fixes#83856
changelog: add lint that detect code like
```rust
unsafe {
&*core::ptr::null::<i32>()
};
unsafe {
addr_of!(std::ptr::null::<i32>())
};
let x: i32 = unsafe {*core::ptr::null()};
let x: i32 = unsafe {*core::ptr::null_mut()};
unsafe {*(0 as *const i32)};
unsafe {*(core::ptr::null() as *const i32)};
```
```
warning: Dereferencing a null pointer causes undefined behavior
--> src\main.rs:5:26
|
5 | let x: i32 = unsafe {*core::ptr::null()};
| ^^^^^^^^^^^^^^^^^^
| |
| a null pointer is dereferenced
| this code causes undefined behavior when executed
|
= note: `#[warn(deref_nullptr)]` on by default
```
Limitation:
It does not detect code like
```rust
const ZERO: usize = 0;
unsafe {*(ZERO as *const i32)};
```
or code where `0` is not directly a literal
rustdoc: links from items in a trait impl are inconsistent
Depending on where the struct implementing a trait is coming from, or the current page, the items in a trait impl are not linking to the same thing:
|item| trait page, implementors| trait page, implementations on Foreign Types|struct page, trait implementations|
|-|-|-|-|
|function| link to current impl|link to first impl in the list|link to trait def
|default function | not present |not present |link to trait def
|default function with custom impl|link to current impl|link to trait def |link to trait def
|constant| link to current impl|link to trait def |link to trait def
|associated type| link to current impl|link to trait def |link to trait def
||*missing link to trait def*|*function link wrong + missing link to current impl*|*missing link to current impl*|
<details>
<summary>rust code with those cases</summary>
```rust
pub trait MyTrait {
type Assoc;
const VALUE: u32;
fn trait_function(&self);
fn defaulted(&self) {}
fn defaulted_override(&self) {}
}
impl MyTrait for String {
/// will link to trait def
type Assoc = ();
/// will link to trait def
const VALUE: u32 = 5;
/// will link to first foreign implementor
fn trait_function(&self) {}
/// will link to trait def
fn defaulted_override(&self) {}
}
impl MyTrait for Vec<u8> {
/// will link to trait def
type Assoc = ();
/// will link to trait def
const VALUE: u32 = 5;
/// will link to first foreign implementor
fn trait_function(&self) {}
/// will link to trait def
fn defaulted_override(&self) {}
}
impl MyTrait for MyStruct {
/// in trait page, will link to current impl
///
/// in struct page, will link to trait def
type Assoc = bool;
/// in trait page, will link to current impl
///
/// in struct page, will link to trait def
const VALUE: u32 = 20;
/// in trait page, will link to current impl
///
/// in struct page, will link to trait def
fn trait_function(&self) {}
/// in trait page, will link to current impl
///
/// in struct page, will link to trait def
fn defaulted_override(&self) {}
}
pub struct MyStruct;
```
</details>
In this PR, I fixed all links to target the trait definition, and added an anchor-link to the current implementation appearing on mouse hover.