bors [Thu, 20 Oct 2022 10:40:09 +0000 (10:40 +0000)]
Auto merge of #103185 - chenyukang:yukang/fix-span-next-point, r=davidtwco
Fix the bug of next_point in source_map
There is a bug in `next_point`, the new span won't move to next position when be called in the first time.
For this reason, our current code is working like this:
1. When we really want to move to the next position, we called two times of `next_point`
2. Some code which use `next_point` actually done the same thing with `shrink_to_hi`
This fix make sure when `next_point` is called, span will move with the width at least 1, and also work correctly in the scenario of multiple bytes.
As mentioned in the issue, https://github.com/rust-lang/rust/pull/102924 introduced this regression. This PR partially reverts it and adds a regression test.
Matthias Krüger [Thu, 20 Oct 2022 05:58:55 +0000 (07:58 +0200)]
Rollup merge of #103197 - est31:stabilize_proc_macro_source_text, r=petrochenkov
Stabilize proc_macro::Span::source_text
Splits `proc_macro::Span::source_text` into a new feature gate and stabilizes it. The [FCP is complete](https://github.com/rust-lang/rust/issues/101991#issuecomment-1279393265).
bors [Thu, 20 Oct 2022 05:56:56 +0000 (05:56 +0000)]
Auto merge of #103220 - compiler-errors:deny-infers, r=lcnr
Deny hashing ty/re/ct inference variables
cc `@cjgillot` and https://github.com/rust-lang/rust/pull/102695#issuecomment-1275706528
r? `@lcnr`
best reviewed one commit at a time, mostly because the second commit that fixes `ClosureOutlivesRequirement` is mostly noise because of losing its `<'tcx>` lifetime parameter.
bors [Wed, 19 Oct 2022 21:17:09 +0000 (21:17 +0000)]
Auto merge of #103264 - matthiaskrgr:rollup-3ja4spo, r=matthiaskrgr
Rollup of 7 pull requests
Successful merges:
- #103211 (rustdoc: remove class name `location` from sidebar sibling nav)
- #103223 (Use already checked RHS ty for LHS deref suggestions)
- #103237 (Clean up codeblock-tooltip rustdoc-gui test)
- #103239 (Allow #[unstable] impls for fn() with unstable abi.)
- #103246 (Mark `rust-analyzer` as a host-only tool)
- #103257 (rustdoc: move `setting-line` color CSS to settings.css)
- #103258 (Make miri read_dir test a little more robust)
Matthias Krüger [Wed, 19 Oct 2022 19:38:41 +0000 (21:38 +0200)]
Rollup merge of #103246 - ferrocene:pa-rust-analyzer-hosts, r=Mark-Simulacrum
Mark `rust-analyzer` as a host-only tool
All tools meant to be shipped with host toolchains only should be marked as `ONLY_HOSTS = true`, but rust-analyzer was marked as `ONLY_HOSTS = false` incorrectly. This meant that bootstrap attempted to build rust-analyzer for cross-compilation-only targets, causing errors because libstd is not present on some of them.
It will still be possible to cross-compile rust-analyzer by passing a different `--host` flag to `./x`, like you can cross-compile other tools.
Matthias Krüger [Wed, 19 Oct 2022 19:38:40 +0000 (21:38 +0200)]
Rollup merge of #103223 - compiler-errors:deref-sugg-slow, r=wesleywiser
Use already checked RHS ty for LHS deref suggestions
There's no reason to do the `check_lhs_assignable` and RHS `check_expr_with_hint` in that order, so invert them and use the typeck results to avoid exponential blowup on error.
This change tweaks the CSS to apply most of its styles to `.sidebar h2`, cleaning up a few redundant rules from `.mobile-topbar .location` and restoring useful navigation aids in mobile mode.
bors [Wed, 19 Oct 2022 13:53:06 +0000 (13:53 +0000)]
Auto merge of #103214 - Nilstrieb:set-theory, r=petrochenkov
Use Set instead of Vec in transitive_relation
Helps with #103195. It doesn't fix the underlying quadraticness but it makes it _a lot_ faster to an extent where even doubling the amount of nested references still takes less than two seconds (50s on nightly).
I want to see whether this causes regressions (because the vec was usually quite small) or improvements (as lookup for bigger sets is now much faster) in real code.
Pietro Albini [Wed, 19 Oct 2022 12:33:17 +0000 (14:33 +0200)]
mark rust-analyzer as a host-only tool
All tools meant to be shipped with host toolchains only should be marked
as `ONLY_HOSTS = true`, but rust-analyzer was marked as `ONLY_HOSTS =
false` incorrectly. This meant that bootstrap attempted to build
rust-analyzer for cross-compilation-only targets, causing errors because
libstd is not present on some of them.
It will still be possible to cross-compile rust-analyzer by passing a
different --host flag to ./x, like you can cross-compile other tools.
bors [Wed, 19 Oct 2022 11:12:10 +0000 (11:12 +0000)]
Auto merge of #103228 - Dylan-DPC:rollup-31yiauw, r=Dylan-DPC
Rollup of 6 pull requests
Successful merges:
- #102863 (Standardize "use parentheses to call" suggestions between typeck and trait selection)
- #103034 (Let expressions on RHS shouldn't be terminating scopes)
- #103127 (Make transpose const and inline)
- #103153 (Allow `Vec::leak` when using `no_global_oom_handling`)
- #103182 (Clean up query descriptions)
- #103216 (Consider patterns in fn params in an `Elided(Infer)` lifetime rib.)
Dylan DPC [Wed, 19 Oct 2022 08:35:52 +0000 (14:05 +0530)]
Rollup merge of #103127 - SUPERCILEX:inline-const-uninit, r=scottmcm
Make transpose const and inline
r? `@scottmcm`
- These should have been const from the beginning since we're never going to do more than a transmute.
- Inline these always because that's what every other method in MaybeUninit which simply casts does. :) Ok, but a stronger justification is that because we're taking in arrays by `self`, not inlining would defeat the whole purpose of using `MaybeUninit` due to the copying.
Dylan DPC [Wed, 19 Oct 2022 08:35:52 +0000 (14:05 +0530)]
Rollup merge of #103034 - nathanwhit:let-chains-rhs-temporaries, r=wesleywiser
Let expressions on RHS shouldn't be terminating scopes
Fixes #100276.
Before this PR, we were unconditionally marking the RHS of short-circuiting binary expressions as a terminating scope.
In the case of a let chain where the `let` expression was on the RHS, this meant that temporaries within the `let` expr would only live until the end of the expression. Since this only affected the RHS, this led to surprising behavior ([example](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=d1b0a5d1f01882f9c89c2194a75eb19f)).
After this PR, we only mark the RHS as a terminating scope if it is not a `let` expression.
Dylan DPC [Wed, 19 Oct 2022 08:35:51 +0000 (14:05 +0530)]
Rollup merge of #102863 - compiler-errors:call-suggestion-on-unimplemented, r=nagisa
Standardize "use parentheses to call" suggestions between typeck and trait selection
1. Suggest calling constructors, since they're basically `FnDef`s but they have a different def kind and hir representation, so we were leaving them out.
2. Standardize the call suggestions between trait fulfillment errors and type mismatch. In the type mismatch suggestion, we suggest `/* Ty */` as the placeholder for an arg, and not the parameter's name, which is less helpful.
3. Use `predicate_must_hold_modulo_regions` instead of matching on `EvaluationResult` -- this might cause some suggestions to be filtered out, but we really shouldn't be suggesting a call if it "may" hold, only when it "must" hold.
4. Borrow some logic from `extract_callable_info` to generalize this suggestion to fn pointers, type parameters, and opaque types.
bors [Wed, 19 Oct 2022 08:26:55 +0000 (08:26 +0000)]
Auto merge of #103180 - ferrocene:pa-qemu-user-mode, r=Mark-Simulacrum
Handle core dumps output in QEMU user mode
In addition to the whole-system emulation/virtualization, QEMU also supports user-mode emulation, where the emulation happens as a normal process inside the parent system. This allows running most tests by simply spawning remote-test-server inside user-mode emulation.
Unfortunately, QEMU always writes its own message in addition to the system one when a core dump happens, which breaks a few tests which match on the exact output of the system.
This PR changes those tests to strip the (possible) QEMU output before checking if the output is expected.
Matthias Krüger [Wed, 19 Oct 2022 05:15:31 +0000 (07:15 +0200)]
Rollup merge of #103178 - ferrocene:pa-coverage-reports-tests, r=Mark-Simulacrum
Partially fix `src/test/run-make/coverage-reports` when cross-compiling
The test does not work on cross-compiled targets because the --target flag was not passed to rustc inside the test. This commit fixes that by adding the flag to the invocations.
Note that the test still fails on cross-compiled targets using remote-test, as remote-test is not capable (yet) of sending back to the host system the `*.profraw` file generated by the instrumentation.
Because of that, this is only a partial fix, and the test has been ignored on cross-compilation.
Matthias Krüger [Wed, 19 Oct 2022 05:15:30 +0000 (07:15 +0200)]
Rollup merge of #103166 - the8472:copied-next-chunk, r=m-ou-se
Optimize `slice_iter.copied().next_chunk()`
```
OLD:
test iter::bench_copied_array_chunks ... bench: 371 ns/iter (+/- 7)
NEW:
test iter::bench_copied_array_chunks ... bench: 31 ns/iter (+/- 0)
```
The default `next_chunk` implementation suffers from having to assemble the array byte by byte via `next()`, checking the `Option<&T>` and then dereferencing `&T`. The specialization copies the chunk directly from the slice.
bors [Wed, 19 Oct 2022 02:53:24 +0000 (02:53 +0000)]
Auto merge of #103213 - matthiaskrgr:rollup-diloxg3, r=matthiaskrgr
Rollup of 6 pull requests
Successful merges:
- #101889 (doc: rewrite doc for uint::{carrying_add,borrowing_sub})
- #102507 (More slice::partition_point examples)
- #103164 (rustdoc: remove CSS ``@media` (min-width: 701px)`)
- #103189 (Clean up code-color and headers-color rustdoc GUI tests)
- #103203 (Retrieve LLVM version from llvm-filecheck binary if it is not set yet)
- #103204 (Add some more autolabels)
bors [Wed, 19 Oct 2022 00:02:40 +0000 (00:02 +0000)]
Auto merge of #102769 - nnethercote:rustdoc-startup, r=jyn514
Clean up rustdoc startup
Startup is pretty hairy, in both rustdoc and rustc. The first commit here improves the rustdoc situation quite a bit. The remaining commits are smaller but also help.
Use `interface::run_compiler` for `markdown::render`.
It turns out `markdown::render` is more complex than it first appears,
because it can invoke `doctest::make_test`, which requires session
globals and a thread pool.
So this commit changes it to use `interface::run_compiler`. Three of the
four paths in `main_args` now use `interface::run_compiler`.
rustc's startup has several layers, including:
- `interface::run_compiler` passes a closure, `f`, to
`run_in_thread_pool_with_globals`, which creates a thread pool, sets
up session globals, and passes `f` to `create_compiler_and_run`.
- `create_compiler_and_run` creates a `Session`, a `Compiler`, sets the
source map, and calls `f`.
rustdoc is a bit different.
- `main_args` calls `main_options` via
`run_in_thread_pool_with_globals`, which (again) creates a thread pool
(hardcoded to a single thread!) and sets up session globals.
- `main_options` has four different paths.
- The second one calls `interface::run_compiler`, which redoes the
`run_in_thread_pool_with_globals`! This is bad.
- The fourth one calls `interface::create_compiler_and_run`, which is
reasonable.
- The first and third ones don't do anything of note involving the
above functions, except for some symbol interning which requires
session globals.
In other words, rustdoc calls into `rustc_interface` at three different
levels. It's a bit confused, and feels like code where functionality has
been added by different people at different times without fully
understanding how the globally accessible stuff is set up.
This commit tidies things up. It removes the
`run_in_thread_pool_with_globals` call in `main_args`, and adjust the
four paths in `main_options` as follows.
- `markdown::test` calls `test::test_main`, which provides its own
parallelism and so doesn't need a thread pool. It had one small use of
symbol interning, which required session globals, but the commit
removes this.
- `doctest::run` already calls `interface::run_compiler`, so it doesn't
need further adjustment.
- `markdown::render` is simple but needs session globals for interning
(which can't easily be removed), so it's now wrapped in
`create_session_globals_then`.
- The fourth path now uses `interface::run_compiler`, which is
equivalent to the old `run_in_thread_pool_with_globals` +
`create_compiler_and_run` pairing.
Matthias Krüger [Tue, 18 Oct 2022 19:18:48 +0000 (21:18 +0200)]
Rollup merge of #103203 - GuillaumeGomez:fix-llvm-runtools-condition, r=Amanieu
Retrieve LLVM version from llvm-filecheck binary if it is not set yet
In `rustc_codegen_gcc`, we run the `ASM` test suite. The problem is that, if a too recent version of the `llvm-filecheck` binary is provided, an extra argument needs to be passed and the to detect this version, it currently only expects a `--llvm-version` argument. With this, the version can be determined directly from the `llvm-filecheck` binary.
Matthias Krüger [Tue, 18 Oct 2022 19:18:46 +0000 (21:18 +0200)]
Rollup merge of #101889 - tspiteri:redoc-uint-adc-sbb, r=m-ou-se
doc: rewrite doc for uint::{carrying_add,borrowing_sub}
Reword the documentation for bigint helper methods `uint::{carrying_add,borrowing_sub}` (#85532).
The examples were also rewritten to demonstrate how the methods can be used in bignum arithmetic. No loops are used in the examples, but the variable names were chosen to include indices so that it is clear how this can be used in a loop if required.
Also, previously `carrying_add` had an example to say that if the input carry is false, the method is equivalent to `overflowing_add`. While the note was kept, the example was removed and an extra note was added to make sure this equivalence is not assumed for signed integers as well.
Michael Howell [Tue, 18 Oct 2022 18:14:01 +0000 (11:14 -0700)]
rustdoc: remove class name `location` from sidebar sibling nav
This change tweaks the CSS to apply most of its styles to `.sidebar h2`,
cleaning up a few redundant rules from `.mobile-topbar .location` and
restoring useful navigation aids in mobile mode.
bors [Tue, 18 Oct 2022 16:32:41 +0000 (16:32 +0000)]
Auto merge of #102418 - citrus-it:illumos-strip-debug, r=nagisa
The illumos linker does not support --strip-debug
When building and testing rust 1.64.0 on illumos, we saw a large number of failing tests associated with:
```
= note: ld: fatal: unrecognized option '--strip-debug'
ld: fatal: use the -z help option for usage information
collect2: error: ld returned 1 exit status
```
The illumos linker does not support the `--strip-debug` option (although it does support `--strip-all`).
bors [Tue, 18 Oct 2022 13:35:43 +0000 (13:35 +0000)]
Auto merge of #103188 - JohnTitor:rollup-pwilam1, r=JohnTitor
Rollup of 6 pull requests
Successful merges:
- #103023 (Adding `fuchsia-ignore` and `needs-unwind` to compiler test cases)
- #103142 (Make diagnostic for unsatisfied `Termination` bounds more precise)
- #103154 (Fix typo in `ReverseSearcher` docs)
- #103159 (Remove the redundant `Some(try_opt!(..))` in `checked_pow`)
- #103163 (Remove all uses of array_assume_init)
- #103168 (Stabilize asm_sym)
Yuki Okushi [Tue, 18 Oct 2022 12:21:31 +0000 (21:21 +0900)]
Rollup merge of #103159 - cuviper:check_pow-final-try_opt, r=Mark-Simulacrum
Remove the redundant `Some(try_opt!(..))` in `checked_pow`
The final return value doesn't need to be tried at all -- we can just
return the checked option directly. The optimizer can probably figure
this out anyway, but there's no need to make it work here.
Yuki Okushi [Tue, 18 Oct 2022 12:21:30 +0000 (21:21 +0900)]
Rollup merge of #103142 - fmease:fix-103052, r=oli-obk
Make diagnostic for unsatisfied `Termination` bounds more precise
Don't blindly emit a diagnostic claiming that “*`main` has an invalid return type*” if we encounter a type that should but doesn't implement `std::process::Termination` and isn't actually the return type of the program entry `main`.
bors [Tue, 18 Oct 2022 10:54:53 +0000 (10:54 +0000)]
Auto merge of #103075 - SUPERCILEX:miri-metadata, r=thomcc
Support DirEntry metadata calls in miri
This should work as it uses lstat64 which is supported here: ~https://github.com/rust-lang/miri/blob/d9ad25ee4bbd9364c498959cdc82b5fa6c41e63c/src/shims/unix/macos/foreign_items.rs#L42~ just noticed that's macos, linux would be using statx: https://github.com/rust-lang/miri/blob/86f0e63b21721fe2c14608644f467b9cb21945eb/src/shims/unix/linux/foreign_items.rs#L112
The failing syscall is `dirfd`, so maybe that should actually be added to the shims?
Pietro Albini [Mon, 10 Oct 2022 14:29:57 +0000 (16:29 +0200)]
handle core dumps output in qemu user mode
In addition to the whole-system emulation/virtualization, QEMU also
supports user-mode emulation, where the emulation happens as a normal
process inside the parent system. This allows running most tests by
simply spawning remote-test-server inside user-mode emulation.
Unfortunately, QEMU always writes its own message in addition to the
system one when a core dump happens, which breaks a few tests which
match on the exact output of the system.
This PR changes those tests to strip the (possible) QEMU output before
checking if the output is expected.