rustdoc: render `<Self as X>::Y` type casts properly
Rustdoc didn't render any `<Self as X>` casts which causes invalid code inside the documentation. This is fixed by this PR by checking if the target type `X` is different from `Self`, and if so, it will render a typecast.
Resolves#85454
fix deallocation of immutable allocations
As part of https://github.com/rust-lang/miri/pull/1814, I realized that we currently allow deallocating immutable allocations. This PR fixes that, and also adds some new APIs that are required to still support the existing Miri backtrace support.
r? `@oli-obk`
Fix `vxworks`
Some PRs made the `vxworks` target not build anymore. This PR fixes that:
- #82973: copy `ExitStatusError` implementation from `unix`.
- #84716: no `libc::chroot` available on `vxworks`, so for now don't implement `os::unix::fs::chroot`.
Remove surplus prepend LinkedList fn
This nightly library feature provides a function on `LinkedList<T>` that is identical to `fn append` with a reversed order of arguments. Observe this diff against the `fn append` doctest:
```diff
+#![feature(linked_list_prepend)]
fn main() {
use std::collections::LinkedList;
let mut list1 = LinkedList::new();
list1.push_back('a');
let mut list2 = LinkedList::new();
list2.push_back('b');
list2.push_back('c');
- list1.append(&mut list2);
+ list2.prepend(&mut list1);
- let mut iter = list1.iter();
+ let mut iter = list2.iter();
assert_eq!(iter.next(), Some(&'a'));
assert_eq!(iter.next(), Some(&'b'));
assert_eq!(iter.next(), Some(&'c'));
assert!(iter.next().is_none());
- assert!(list2.is_empty());
+ assert!(list1.is_empty());
}
```
As this has received no obvious request to stabilize it, nor does it have a tracking issue, and was left on nightly and the consensus seems to have been to deprecate it in this pre-1.0 PR in 2014, https://github.com/rust-lang/rust/pull/20356, I propose simply removing it.
add an example to explain std::io::Read::read returning 0 in some cases
I have always found the explanation about `Read::read` returning 0 to indicate EOF but not indefinitely, so here's more info using Linux as example. I can also add example code if necessary
MSVC: Avoid using jmp stubs for dll function imports
Windows import libraries contain two symbols for every function: `__imp_FunctionName` and `FunctionName` (where `FunctionName` is the name of the function to be imported).
`__imp_FunctionName` contains the address of the imported function. This will be filled in by the Windows executable loader at runtime. `FunctionName` contains a jmp stub that simply jumps to the address given by `__imp_FunctionName`. E.g. it's a function that solely contains a single jmp instruction:
```asm
jmp __imp_FunctionName
```
When using an external DLL function in Rust, by default the linker will link to FunctionName, causing a bit of indirection at runtime. In Microsoft's C++ it's possible to instead tell it to insert calls to the address in `__imp_FunctionName` by using the `__declspec(dllimport)` attribute. In Rust it's possible to get effectively the same behaviour using the `#[link]` attribute on `extern` blocks.
----
The second commit also merges multiple `extern` blocks into one block. This is because otherwise Rust will currently create duplicate linker arguments for each block. In this case having duplicates shouldn't matter much other than the noise when displaying the linker command.
Move llvm submodule updates to rustbuild
This enables better caching, since LLVM is only updated when needed, not
whenever x.py is run. Before, bootstrap.py had to use heuristics to
guess if LLVM would be needed, and updated the module more often than
necessary as a result.
This syncs the LLVM submodule only just before building the compiler, so
people working on the standard library never have to worry about it.
Example output:
```
Copying stage0 std from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Updating submodule src/llvm-project
Submodule 'src/llvm-project' (https://github.com/rust-lang/llvm-project.git) registered for path 'src/llvm-project'
Submodule path 'src/llvm-project': checked out 'f9a8d70b6e0365ac2172ca6b7f1de0341297458d'
```
Implements https://github.com/rust-lang/rust/issues/76653#issuecomment-770265169. This could be easily extended to other submodules, like `rust-by-example` and `rustc-dev-guide`, which aren't needed for cargo's workspace resolution.
This enables better caching, since LLVM is only updated when needed, not
whenever x.py is run. Before, bootstrap.py had to use heuristics to
guess if LLVM would be needed, and updated the module more often than
necessary as a result.
This syncs the LLVM submodule only just before building the compiler, so
people working on the standard library never have to worry about it.
Example output:
```
Copying stage0 std from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Updating submodule src/llvm-project
Submodule 'src/llvm-project' (https://github.com/rust-lang/llvm-project.git) registered for path 'src/llvm-project'
Submodule path 'src/llvm-project': checked out 'f9a8d70b6e0365ac2172ca6b7f1de0341297458d'
```
- Don't try to update the LLVM submodule when using system LLVM
Previously, this would try to update LLVM unconditionally. Now the
submodule is only initialized if `llvm-config` is not set.
- Don't update LLVM submodule in dry runs
This prevents the following test failures:
```
running 17 tests
fatal: invalid gitfile format: /checkout/src/llvm-project/.git
test builder::tests::defaults::build_cross_compile ... FAILED
---- builder::tests::defaults::build_default stdout ----
thread 'main' panicked at 'command did not execute successfully: "git" "rev-parse" "HEAD"
expected success, got: exit code: 128', src/build_helper/lib.rs:139:9
```
- Try running git without --progress if it fails the first time
This avoids having to do version detection to see if --progress is
supported or not.
- Don't try to update submodules when the source repository isn't managed by git
- Update LLVM submodules that have already been checked out
- Only check for whether the submodule should be updated in lib.rs; update
it unconditionally in native.rs
CTFE get_alloc_extra_mut: also provide ref to MemoryExtra
This would let me use mutable references in more places in Stacked Borrows, avoiding some `RefCell` overhead. :)
r? `@oli-obk`
This sets their toggles to be closed in the HTML (matching the default
setting), and opens them if the setting indicates to do so.
This distinguishes between implementations and implementors based on
being descendants of certain named elements.
Swap TargetOptions::linker_is_gnu default from false to true and update targets as appropriate.
#85274 gated the `--gc-sections` flag on targets that specified `linker_is_gnu` to stop us from passing it to incompatible linkers. But that had the unintended effect of the flag no longer being passed on targets for which it is valid and hence caused a regression in binary size. Given that most `ld`-style linkers are GNU compatible, this change flips our default for `linker_is_gnu` from false to true. That also means updating the targets that relied on the previous default:
* Apple
* Illumos
* L4Re (not sure about this one)
* MSVC
* NvtPtx
* Solaris
Fixes#85519
Rollup of 4 pull requests
Successful merges:
- #85506 (Reset "focusedByTab" field when doing another search)
- #85548 (Remove dead toggle JS code)
- #85550 (facepalm: operator precedence fail on my part.)
- #85555 (Check for more things in THIR unsafeck)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
facepalm: operator precedence fail on my part.
This bug was only visible on mac. Also, print_step_rusage is a relatively new
internal feature, that is not heavily used, and has no tests. All of these
factors contributed to how this went uncaught this long. Thanks to Josh Triplett
for pointing it out!
Remove dead toggle JS code
Explanations on how I got there: I randomly saw `adjustToggle` while browsing through code, checked where it was called, put a `debugger;` instruction in it and checked on all pages while playing with settings and toggles. The breakpoint was never triggered. I then looked at `collapseNonInherent` (its grand-parent). In there, the breakpoint was triggered so I look at what was being done and in fact... nothing. So I simply removed it all, re-ran the tests and play with the UI. Everything is working as expected.
Better double check in case I forgot to check a case though, but if nothing has been left out, then it's a great cleanup once again. :)
r? ``@jsha``
Reset "focusedByTab" field when doing another search
Fixes https://github.com/rust-lang/rust/issues/85467.
The problem was simply that we forget to reset the `focusedByTab` field, which was still referring to removed DOM elements.
r? ``@jsha``
Adjust self-type check to require equality
When we encounter `SomeType::<X>::foo`, `self_ty` is `SomeType<X>` and the method is defined in an impl on `SomeType<A>`. Previously, we required simply that `self_ty <: impl_ty`, but this is too lax: we should require equality in order to use the method. This was found as part of unrelated work on never type stabilization, but also fixes one of the wf test cases.
This bug was only visible on mac. Also, print_step_rusage is a relatively new
internal feature, that is not heavily used, and has no tests. All of these
factors contributed to how this went uncaught this long. Thanks to Josh Triplett
for pointing it out!