Stabilize noop_waker
Tracking Issue: #98286
This is a handy feature that's been used widely in tests and example async code and it'd be nice to make it available to users.
cc `@rust-lang/wg-async`
Sync cg clif 2024 12 06
The main highlights this time are a Cranelift update disabling the clif ir verifier by default for better performance.
r? `@ghost`
`@rustbot` label +A-codegen +A-cranelift +T-compiler
rustbook: update to use new mdbook-trpl package from The Book
Updates to the latest merge from `rust-lang/book` and simplifies the dependency chain there. There are now three preprocessors, but only one package, so everything is a lot nicer to deal with from the consuming POV (i.e. here).
Extend Miri to correctly pass mutable pointers through FFI
Based off of https://github.com/rust-lang/rust/pull/129684, this PR further extends Miri to execute native calls that make use of pointers to *mutable* memory.
We adapt Miri's bookkeeping of internal state upon any FFI call that gives external code permission to mutate memory.
Native code may now possibly write and therefore initialize and change the pointer provenance of bytes it has access to: Such memory is assumed to be *initialized* afterwards and bytes are given *arbitrary (wildcard) provenance*. This enables programs that correctly use mutating FFI calls to run Miri without errors, at the cost of possibly missing Undefined Behaviour caused by incorrect usage of mutating FFI.
> <details>
>
> <summary> Simple example </summary>
>
> ```rust
> extern "C" {
> fn init_int(ptr: *mut i32);
> }
>
> fn main() {
> let mut x = std::mem::MaybeUninit::<i32>::uninit();
> let x = unsafe {
> init_int(x.as_mut_ptr());
> x.assume_init()
> };
>
> println!("C initialized my memory to: {x}");
> }
> ```
> ```c
> void init_int(int *ptr) {
> *ptr = 42;
> }
> ```
> should now show `C initialized my memory to: 42`.
>
> </details>
r? ``@RalfJung``
rust_for_linux: -Zreg-struct-return commandline flag for X86 (#116973)
Command line flag `-Zreg-struct-return` for X86 (32-bit) for rust-for-linux.
This flag enables the same behavior as the `abi_return_struct_as_int` target spec key.
- Tracking issue: https://github.com/rust-lang/rust/issues/116973
CI: rfl: move job forward to Linux v6.13-rc1
Linux v6.13-rc1 contains commit 28e848386b92 ("rust: block: fix formatting of `kernel::block::mq::request` module"), which in turn contains commit c95bbb59a9b2 ("rust: enable arbitrary_self_types and remove `Receiver`"), which is why we had a hash rather than a tag.
r? ```@Kobzol``` ```@lqd```
try-job: x86_64-rust-for-linux
```@rustbot``` label A-rust-for-linux
```@bors``` try
Replace black with ruff in `tidy`
`ruff` can both lint and format Python code (in fact, it should be a mostly drop-in replacement for `black` in terms of formatting), so it's not needed to use `black` anymore. This PR removes `black` and replaces it with `ruff`, to get rid of one Python dependency, and also to make Python formatting faster (although that's a small thing).
If we decide to merge this, we'll need to "reformat the world" - `ruff` is not perfectly compatible with `black`, and it also looks like `black` was actually ignoring some files before. I tried it locally (`./x test tidy --extra-checks=py:fmt --bless`) and it also reformatted some code in subtrees (e.g. `clippy` or `rustc_codegen_gcc`) - I'm not sure how to handle that.
skip `setup::Hook` on non-git sources
Running `setup::Hook` (with `x setup`) leads tarball sources to panic and this PR resolves that problem by skipping `Hook` step on non-git sources.
Improve bootstrap job objects
This attempts to fix a few comments on bootstrap job objects.
I also fixed an issue where if duplicating the job object handle into the python process failed, it would close the job object. This would then result in the job object closing all attached processes, which at that point includes the current process. The fix is to simply never close the job object handle at any point after the current process is assigned to it.
Fix "std" support status of some tier 3 targets
https://github.com/rust-lang/rust/pull/127265 marked targets with empty "std" support status as no-std targets in target-spec metadata:
> * Where a targets 'std' or 'host tools' support is listed as '?' in the rust docs, these are left as 'None' with this PR. The corresponding changes in cargo will only reject an attempt to build std if the 'std' field is 'Some(false)'. In the case it is 'None', cargo will continue trying to build
However, this is not accurate because "std" support status has a marker indicating that it is a no-std target. (empty status is just invalid.)
https://doc.rust-lang.org/nightly/rustc/platform-support.html#tier-3
> The `std` column in the table below has the following meanings:
>
> * ✓ indicates the full standard library is available.
> * \* indicates the target only supports [`no_std`] development.
> * ? indicates the standard library support is unknown or a work-in-progress.
>
> [`no_std`]: https://rust-embedded.github.io/book/intro/no-std.html
This PR fixes the status of targets whose "std" support status is currently set to empty and update target-spec metadata.
The new status is set based on the following criteria:
- Set to ✓ for targets that I regularly check in [rust-cross-toolchain](https://github.com/taiki-e/rust-cross-toolchain) that the `cargo test` works. (riscv32-unknown-linux-gnu,{riscv64,s390x}-unknown-linux-musl)
- Targets where `cargo run` works but `cargo test` does not work tend to have incomplete std support (e.g., riscv32 musl f3068b66e0), so I included them in the group below that means “work in progress” rather than in this group.
- Set powerpc64le FreeBSD to ✓ on both std and host_tools, because the [Rust package](https://www.freshports.org/lang/rust/) is available.
- Set to ? (which means "unknown" or “work in progress”) for all other affected targets because these are Linux, Android, FreeBSD, or Fuchsia, all of which are operating systems that support std if properly supported.
r? Noratrieb
cc ``@harmou01``
Revert #133817
This reverts commit 0585134e70, reversing changes made to 5530869e0f.
#133817 unfortunately only converted the `println!` instances to `eprintln!`, meaning that some test output (via compiletest/bootstrap) was messed up because stdout/stderr output interleaved improperly when some `println!` instances were converted to `eprintln!` instances, while some `print!` instances remain unchanged. This made reading test output annoying for contributors cc #133879.
Closes#133879 by reverting.
#133817 can be relanded in the future when `print!` instances are also matched with `println!` instances.
cc `@clubby789`
This is a clean revert so I'm going to self-approve this PR.
Rename `core_pattern_type` and `core_pattern_types` lib feature gates to `pattern_type_macro`
That's what the gates are actually gating, and the single char difference in naming was not helpful either
fixes#128987
Update books
## rust-lang/book
12 commits in e16dd73690a6cc3ecdc5f5d94bbc3ce158a42e16..614c19cb4025636eb2ba68ebb3d44e3bd3a5e6e4
2024-12-02 16:22:15 UTC to 2024-11-26 21:15:51 UTC
- Fix more inverted uses of “shadowed” (rust-lang/book#4122)
- Fix a couple inverted uses of “shadowed” (rust-lang/book#4121)
- Fix confusion between variable `hello` and string `"hello"` (rust-lang/book#4118)
- Ch. 17: fix some wording issues (rust-lang/book#4117)
- Rephrase for clarity (rust-lang/book#3809)
- Link to tests section of rustc book for `cargo test -- --help` docs (rust-lang/book#4116)
- Drop a pedantry-triggering sentence about IEEE-754 (rust-lang/book#4114)
- Very small clarification on if let (rust-lang/book#4113)
- Ch17-05: Typos (rust-lang/book#4099)
- Ch20-01: Fix typos (rust-lang/book#4105)
- Add a short paragraph on editors and IDEs in installation (rust-lang/book#4112)
- Rust 2024: update Ch. 20 for new `unsafe` rules (rust-lang/book#4111)
## rust-lang/reference
8 commits in 5c86c739ec71b8bc839310ff47fa94e94635bba9..ede56d1bbe132bac476b5029cd6d7508ca9572e9
2024-11-25 17:23:35 +0000 to 2024-12-03 22:26:55 +0000
- Claim to follow Unicode 16 for lexing identifiers. (rust-lang/reference#1688)
- Clarify rules for on_unimplemented warnings (rust-lang/reference#1680)
- Enable triagebot merge-conflict notifications (rust-lang/reference#1682)
- Update default edition to 2024 for code examples (rust-lang/reference#1684)
- Fix weak keywords (rust-lang/reference#1685)
- `const` expression can borrow static items (rust-lang/reference#1610)
- Update function-pointer.md for stabilization of `extended_varargs_abi_support` (rust-lang/reference#1687)
- fix inconsistent spacing in example (rust-lang/reference#1686)
## edition-guide
1 commits in f48b0e842a3911c63240e955d042089e9e0894c7..128669297c8a7fdf771042eaec18b8adfaeaf0cd
2024-11-25 16:20:27 +0000 to 2024-12-03 22:02:43 +0000
- Fix `if_let_rescope` applicability (rust-lang/edition-guide#339)
## rust-lang/rustc-dev-guide
6 commits in 787b4166ccc67bd8f72a6e3ef6685ce9ce82909a..b21d99b770f9aceb0810c843847c52f86f45d2ed
2024-12-02 04:45:30 UTC to 2024-11-27 10:31:58 UTC
- Spell out `git submodule deinit -f --all` (rust-lang/rustc-dev-guide#2153)
- Explain how to deal with exploded git submodules (rust-lang/rustc-dev-guide#2152)
- Update `//@ proc-macro` aux build directive docs (rust-lang/rustc-dev-guide#2149)
- Remove `pretty-expanded` as it no longer exists (rust-lang/rustc-dev-guide#2147)
- Fix trivial typo (rust-lang/rustc-dev-guide#2148)
- Remove -Zfuel. (rust-lang/rustc-dev-guide#2032)
Add context to "const in pattern" errors
*Each commit addresses specific diagnostics.*
- Add primary span labels
- Point at `const` item, and `const` generic param definition
- Reword messages and notes
- Point at generic param through which an associated `const` is being referenced
- Silence const in pattern with evaluation errors when they come from `const` items that already emit a diagnostic
- On non-structural type in const used as pattern, point at the type that should derive `PartialEq`
Add lint against function pointer comparisons
This is kind of a follow-up to https://github.com/rust-lang/rust/pull/117758 where we added a lint against wide pointer comparisons for being ambiguous and unreliable; well function pointer comparisons are also unreliable. We should IMO follow a similar logic and warn people about it.
-----
## `unpredictable_function_pointer_comparisons`
*warn-by-default*
The `unpredictable_function_pointer_comparisons` lint checks comparison of function pointer as the operands.
### Example
```rust
fn foo() {}
let a = foo as fn();
let _ = a == foo;
```
### Explanation
Function pointers comparisons do not produce meaningful result since they are never guaranteed to be unique and could vary between different code generation units. Furthermore different function could have the same address after being merged together.
----
This PR also uplift the very similar `clippy::fn_address_comparisons` lint, which only linted on if one of the operand was an `ty::FnDef` while this PR lints proposes to lint on all `ty::FnPtr` and `ty::FnDef`.
```@rustbot``` labels +I-lang-nominated
~~Edit: Blocked on https://github.com/rust-lang/libs-team/issues/323 being accepted and it's follow-up pr~~
This reverts commit 0585134e70, reversing
changes made to 5530869e0f.
The PR unfortunately only converted the `ln!` instances, meaning that
test output was messed up because stdout/stderr output interleaved when
some `println!` instances were converted to `eprintln!` instances, while
some `println!` instances remain unchanged.
Include LLDB and GDB visualizers in MSVC distribution
MSVC distributions currently don't include the lldb or GDB python files. MSVC and LLDB/GDB are not mutually exclusive (and end up being a common case with vscode + codelldb/lldb-dap), so they should probably be included.
the existing visualizers currently only partially work on MSVC due to the differences in how the debug info is generated, but they also only partially work on GNU anyway - both of which are actively being fixed.
Use `eprintln` instead of `println` in bootstrap/compiletest/tidy
A big unconditional CTRL-F replace to start with to check if there's anything that CI expects to be on stdout
r? `@jieyouxu`
Improve code for FileName retrieval in rustdoc
Some calls were performed twice (first in `is_real_and_local` and then in the function calling it). Also the `FileName` was matched on a few times too.
r? `@notriddle`
rustdoc: Rename `set_back_info` to `restore_module_data`.
Follow-up to #133345, r? `@GuillaumeGomez`
Most of the references to `info` got removed as it was clear that `module_data` makes more sense here. Makes it clearer that `save_module_data` and `restore_module_data` are a pair.
Linux v6.13-rc1 contains commit 28e848386b92 ("rust: block: fix formatting
of `kernel::block::mq::request` module"), which in turn contains commit
c95bbb59a9b2 ("rust: enable arbitrary_self_types and remove `Receiver`"),
which is why we had a hash rather than a tag.
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>