rust/library/std/src
Dylan DPC 0e528f062d
Rollup merge of #95597 - dtolnay:threadlocalu8, r=Dylan-DPC
Refer to u8 by absolute path in expansion of thread_local

The standard library's `thread_local!` macro previously referred to `u8` just as `u8`, resolving to whatever `u8` existed in the type namespace at the call site. This PR replaces those with `$crate::primitive::u8` which always refers to `std::primitive::u8` regardless of what's in scope at the call site. Unambiguously naming primitives inside macro-generated code is the reason that std::primitive was introduced in the first place.

<details>
<summary>Here is the error message prior to this PR ⬇️</summary>

```console
error[E0308]: mismatched types
 --> src/main.rs:6:1
  |
6 | / std::thread_local! {
7 | |     pub static A: i32 = f();
8 | |     pub static B: i32 = const { 0 };
9 | | }
  | |_^ expected struct `u8`, found integer
  |
  = note: this error originates in the macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
 --> src/main.rs:6:1
  |
6 | / std::thread_local! {
7 | |     pub static A: i32 = f();
8 | |     pub static B: i32 = const { 0 };
9 | | }
  | | ^
  | | |
  | |_expected struct `u8`, found integer
  |   this expression has type `u8`
  |
  = note: this error originates in the macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
 --> src/main.rs:6:1
  |
6 | / std::thread_local! {
7 | |     pub static A: i32 = f();
8 | |     pub static B: i32 = const { 0 };
9 | | }
  | |_^ expected `u8`, found struct `u8`
  |
  = note: expected raw pointer `*mut u8` (`u8`)
             found raw pointer `*mut u8` (struct `u8`)
  = note: this error originates in the macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
 --> src/main.rs:6:1
  |
6 | / std::thread_local! {
7 | |     pub static A: i32 = f();
8 | |     pub static B: i32 = const { 0 };
9 | | }
  | |_^ expected `u8`, found struct `u8`
  |
  = note: expected fn pointer `unsafe extern "C" fn(*mut u8)`
                found fn item `unsafe extern "C" fn(*mut u8) {destroy}`
  = note: this error originates in the macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
 --> src/main.rs:6:1
  |
6 | / std::thread_local! {
7 | |     pub static A: i32 = f();
8 | |     pub static B: i32 = const { 0 };
9 | | }
  | | ^
  | | |
  | |_expected struct `u8`, found integer
  |   expected due to this type
  |
  = note: this error originates in the macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0369]: binary operation `==` cannot be applied to type `u8`
 --> src/main.rs:6:1
  |
6 | / std::thread_local! {
7 | |     pub static A: i32 = f();
8 | |     pub static B: i32 = const { 0 };
9 | | }
  | | ^
  | | |
  | |_u8
  |   {integer}
  |
note: an implementation of `PartialEq<_>` might be missing for `u8`
 --> src/main.rs:4:1
  |
4 | struct u8;
  | ^^^^^^^^^^ must implement `PartialEq<_>`
  = note: this error originates in the macro `$crate::assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider annotating `u8` with `#[derive(PartialEq)]`
  |
4 | #[derive(PartialEq)]
  |

error[E0277]: `u8` doesn't implement `Debug`
 --> src/main.rs:6:1
  |
6 | / std::thread_local! {
7 | |     pub static A: i32 = f();
8 | |     pub static B: i32 = const { 0 };
9 | | }
  | |_^ `u8` cannot be formatted using `{:?}`
  |
  = help: the trait `Debug` is not implemented for `u8`
  = note: add `#[derive(Debug)]` to `u8` or manually `impl Debug for u8`
  = note: this error originates in the macro `$crate::assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
```
</details>
2022-04-02 22:38:22 +02:00
..
backtrace Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
collections Rollup merge of #94826 - allgoewer:fix-retain-documentation, r=yaahc 2022-03-11 03:32:06 +01:00
env std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
error Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
f32 Implement IEEE 754-2019 minimun and maximum functions for f32/f64 2021-11-20 10:14:03 +01:00
f64 Remove fNN::lerp - consensus unlikely 2021-10-25 22:44:41 -05:00
ffi add CStr::from_bytes_until_nul 2022-03-18 15:46:49 -07:00
fs Add a testcase. 2022-03-20 15:56:25 -07:00
io Auto merge of #95241 - Gankra:cleaned-provenance, r=workingjubilee 2022-03-30 10:09:10 +00:00
lazy Upgrade wasm32 image to Ubuntu 20.04 2021-02-06 13:05:56 +01:00
net Adjust feature names that disagree on const stabilization version 2022-03-31 12:34:48 -07:00
num rustc_expand: Mark inner #![test] attributes as soft-unstable 2020-11-20 19:35:03 +03:00
os fix unix typedef 2022-03-29 22:45:31 -04:00
panic review: fix nits and move panic safety tests to the correct place 2020-09-25 23:10:24 +02:00
path Rollup merge of #94650 - ChrisDenton:windows-absolute-fix, r=dtolnay 2022-03-19 14:50:24 +01:00
prelude update cfg(bootstrap)s 2022-01-28 15:01:07 +01:00
process Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
sync Make the stdlib largely conform to strict provenance. 2022-03-29 20:18:21 -04:00
sys Rollup merge of #95587 - m-ou-se:std-remove-associated-type-bounds, r=Dylan-DPC 2022-04-02 22:38:19 +02:00
sys_common Make the stdlib largely conform to strict provenance. 2022-03-29 20:18:21 -04:00
thread Refer to u8 by absolute path in expansion of thread_local 2022-04-02 11:38:11 -07:00
time Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
alloc.rs Auto merge of #88098 - Amanieu:oom_panic, r=nagisa 2022-03-18 03:01:46 +00:00
ascii.rs Convert many files to intra-doc links 2020-09-02 17:37:40 -04:00
backtrace.rs revert changes that cast functions to raw pointers, portability hazard 2022-03-29 20:18:27 -04:00
env.rs Link to std::io's platform-specific behavior disclaimer 2022-03-27 21:01:28 -07:00
error.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
f32.rs remove now unnecessary lang items 2022-03-30 11:23:58 +02:00
f64.rs remove now unnecessary lang items 2022-03-30 11:23:58 +02:00
fs.rs Warn that platform-specific behavior may change 2022-03-29 19:49:15 -07:00
keyword_docs.rs Rollup merge of #93692 - mfrw:mfrw/document-keyword-in, r=dtolnay 2022-03-19 02:02:02 +01:00
lazy.rs Add #[must_use] to core and std constructors 2021-10-10 02:44:26 -04:00
lib.rs Remove need for associated_type_bounds in std. 2022-04-01 10:38:39 +02:00
macros.rs Format core and std macro rules, removing needless surrounding blocks 2022-03-11 15:26:51 -08:00
num.rs Add Saturating type (based on Wrapping type) 2021-08-10 19:27:01 +02:00
panic.rs Configure panic hook backtrace behavior 2022-02-02 13:46:42 -05:00
panicking.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
path.rs Make the stdlib largely conform to strict provenance. 2022-03-29 20:18:21 -04:00
primitive_docs.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
process.rs fix since field version for termination stabilization 2022-03-29 17:10:49 -07:00
rt.rs Change Termination::report return type to ExitCode 2022-01-28 12:53:36 -08:00
time.rs Link to std::io's platform-specific behavior disclaimer 2022-03-27 21:01:28 -07:00