You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: posts/2024-07-25-Rust-1.80.0.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,9 +21,9 @@ If you'd like to help us out by testing future releases, you might consider upda
21
21
22
22
### `LazyCell` and `LazyLock`
23
23
24
-
These "lazy" types delay the initialization of their data until first access. They are similar to the `OnceCell` and `OnceLock` types [stabilized in 1.70](https://blog.rust-lang.org/2023/06/01/Rust-1.70.0.html#oncecell-and-oncelock), but with the initialization function included in the type.
24
+
These "lazy" types delay the initialization of their data until first access. They are similar to the `OnceCell` and `OnceLock` types [stabilized in 1.70](https://blog.rust-lang.org/2023/06/01/Rust-1.70.0.html#oncecell-and-oncelock), but with the initialization function included in the cell.
25
25
26
-
`LazyLock` is the thread-safe option, making it suitable for places like `static` values. For example, both the `spawn` thread and the main `scope` will see the exact same duration below, since `LAZY_TIME` will be initialized once, by whichever ends up accessing the static first. Neither use has to know *how* to initialize it though, like you would with `OnceLock::get_or_init`.
26
+
`LazyLock` is the thread-safe option, making it suitable for places like `static` values. For example, both the `spawn` thread and the main `scope` will see the exact same duration below, since `LAZY_TIME` will be initialized once, by whichever ends up accessing the static first. Neither use has to know *how* to initialize it, unlike they would with `OnceLock::get_or_init()`.
27
27
28
28
```rust
29
29
usestd::sync::LazyLock;
@@ -42,13 +42,13 @@ fn main() {
42
42
}
43
43
```
44
44
45
-
`LazyCell` does the same thing without thread synchronization, so it doesn't implement `Sync` needed for `static`, but it can still be used in `thread_local!` statics (with distinct initialization per thread). Either type can also be used in other data structures as well, depending on thread-safety needs, so lazy initialization is available everywhere!
45
+
`LazyCell` does the same thing without thread synchronization, so it doesn't implement `Sync`, which is needed for `static`, but it can still be used in `thread_local!` statics (with distinct initialization per thread). Either type can also be used in other data structures as well, depending on thread-safety needs, so lazy initialization is available everywhere!
46
46
47
47
### Checked `cfg` names and values
48
48
49
-
In 1.79, `rustc` stabilized a [`--check-cfg` flag](https://doc.rust-lang.org/rustc/check-cfg.html), and now Cargo 1.80 is enabling those checks for all `cfg` names that it knows (in addition to those built-in to`rustc`). This includes feature names from `Cargo.toml` as well as new `cargo::rustc-check-cfg` output from build scripts.
49
+
In 1.79, `rustc` stabilized a [`--check-cfg` flag](https://doc.rust-lang.org/rustc/check-cfg.html), and now Cargo 1.80 is enabling those checks for all `cfg` names and values that it knows (in addition to the [well known names and values](https://doc.rust-lang.org/rustc/check-cfg.html#well-known-names-and-values) from`rustc`). This includes feature names from `Cargo.toml` as well as new `cargo::rustc-check-cfg` output from build scripts.
50
50
51
-
Check failures are reported by the `unexpected_cfgs` lint, which is meant to catch typos or other misconfiguration. For example, in a project with an optional `rayon` dependency, this code is configured for the wrong name:
51
+
Unexpected cfgs are reported by the warn-by-default `unexpected_cfgs` lint, which is meant to catch typos or other misconfiguration. For example, in a project with an optional `rayon` dependency, this code is configured for the wrong `feature` value:
The same warning is reported regardless of whether the actual `rayon` feature is enabled or not.
81
81
82
-
The `[lints]` table in the manifest can also be used to extend the known values for custom `cfg` options.
82
+
The `[lints]` table in the `Cargo.toml`manifest can also be used to extend the list of known names and values for custom `cfg`. `rustc` automatically provides [the syntax](https://doc.rust-lang.org/rustc/check-cfg.html#specifying-expected-names-and-values) to use in the warning.
0 commit comments