Matthias Krüger [Wed, 22 Dec 2021 23:28:52 +0000 (00:28 +0100)]
Rollup merge of #92026 - jsha:jsdoc-search, r=GuillaumeGomez
Add some JSDoc comments to rustdoc JS
This follows the Closure Compiler dialect of JSDoc, so we can use it to do some basic type checking. We don't plan to compile with Closure Compiler, just use it to check types. See https://github.com/google/closure-compiler/wiki/ for details.
The addition of:
```rust
derives.sort();
derives.dedup();
```
is what actually solves the problem.
The rest is just cleanup.
I want to improve the diagnostic message to provide the suggestion as a proper diff but ran into some problems, so I'll attempt that again in a follow up PR.
Matthias Krüger [Wed, 22 Dec 2021 23:28:51 +0000 (00:28 +0100)]
Rollup merge of #88858 - spektom:to_lower_upper_rev, r=dtolnay
Allow reverse iteration of lowercase'd/uppercase'd chars
The PR implements `DoubleEndedIterator` trait for `ToLowercase` and `ToUppercase`.
This enables reverse iteration of lowercase/uppercase variants of character sequences.
One of use cases: determining whether a char sequence is a suffix of another one.
This follows the Closure Compiler dialect of JSDoc, so we
can use it to do some basic type checking. We don't plan to
compile with Closure Compiler, just use it to check types. See
https://github.com/google/closure-compiler/wiki/ for details.
bors [Wed, 22 Dec 2021 19:21:25 +0000 (19:21 +0000)]
Auto merge of #92201 - ChrisDenton:fix-tests, r=Mark-Simulacrum
Fix failing tests
Fixes tests that have been failing in CI.
I hope it's ok but I've temporarily commented out some of the Windows resolver tests. I actually have a bigger fix for that test code as part of another PR. I could separate it out and patch as necessary but I'd prefer not to rush into that if possible.
bors [Tue, 21 Dec 2021 09:01:25 +0000 (09:01 +0000)]
Auto merge of #92152 - matthiaskrgr:rollup-nmskpw6, r=matthiaskrgr
Rollup of 7 pull requests
Successful merges:
- #90345 (Stabilise entry_insert)
- #91412 (Improve suggestions for importing out-of-scope traits reexported as `_`)
- #91770 (Suggest adding a `#[cfg(test)]` to to a test module)
- #91823 (Make `PTR::as_ref` and similar methods `const`.)
- #92127 (Move duplicates removal when generating results instead of when displaying them)
- #92129 (JoinHandle docs: add missing 'the')
- #92131 (Sync rustc_codegen_cranelift)
Matthias Krüger [Tue, 21 Dec 2021 07:33:43 +0000 (08:33 +0100)]
Rollup merge of #92131 - bjorn3:sync_cg_clif-2021-12-20, r=bjorn3
Sync rustc_codegen_cranelift
The main highlight this sync is improved support for inline assembly. Thanks `@nbdd0121!` Inline assembly is still disabled by default for builds in the main rust repo though. Cranelift will now also be built from the crates.io releases rather than the git repo. Git repos are incompatible with vendoring.
Matthias Krüger [Tue, 21 Dec 2021 07:33:41 +0000 (08:33 +0100)]
Rollup merge of #92127 - GuillaumeGomez:search-results-duplicate-removal, r=jsha
Move duplicates removal when generating results instead of when displaying them
Currently, we store 200 results per tab and then display them. However, it was possible to have duplicates which is why we have this check. However, instead of doing it when displaying the results, it's much better instead to do it even before to simplify the display part a bit.
Matthias Krüger [Tue, 21 Dec 2021 07:33:37 +0000 (08:33 +0100)]
Rollup merge of #91412 - compiler-errors:issue-86035, r=oli-obk
Improve suggestions for importing out-of-scope traits reexported as `_`
1. Fix up the `parent_map` query to prefer visible parents that _don't_ export items with the name `_`.
* I'm not sure if I modified this query properly. Not sure if we want to check for other idents than `kw::Underscore`.
* This also has the side-effect of not doing BFS on any modules re-exported as `_`, but I think that's desirable here too (or else we get suggestions for paths like `a::_::b` like in [this doctest example](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d9505ea45bb80adf40bb991298f952be)).
2. Bail in `try_print_visible_def_path` if the `def_id` is re-exported as `_`, which will fall back to printing the def-id's real (definition) path.
* Side-effect of this is that we print paths that are not actually public, but it seems we already sometimes suggest `use`ing paths that are private anyways. See [this doctest example](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=bad513ed3241f8ff87579eed8046ad10) for demonstration of current behavior.
3. Suggest a glob-import (for example `my_library::prelude::*`) if the trait in question is only pub-exported as `_`, as a fallback.
```
use foo::bar::prelude::*; // trait MyTrait
```
* I think this is good fallback behavior to suggest instead of doing nothing. Thanks to the original issue filer for suggesting this.
I was somewhat opinionated about behaviors in this PR, and I'm totally open to limiting the impact of my changes or only landing parts of this. Happy to receive feedback if there are better ways to the same end.
bors [Mon, 20 Dec 2021 04:21:12 +0000 (04:21 +0000)]
Auto merge of #91900 - pitaj:fix-91714, r=jyn514
rustdoc: make `--passes` and `--no-defaults` have no effect
Fixes #91714
One potential issue is that currently there is no stable way to achieve `--document-hidden-items`. This affects test `issue-15347`.
I also had to modify the tests `issue-42875` and `no-compiler-export`. Regardless of combinations of `--document-hidden-items` and `--document-private-items`, I was unable to get these to pass without the modifications. I left behind a comment noting the change.
vacuus [Sun, 19 Dec 2021 02:54:59 +0000 (21:54 -0500)]
Omit check of a successive line in loop
I think that s == "" is the only edge case (as it makes iter.next() return None the first time). The early return is necessary so that the last character of 'out' isn't popped if s == "" && !frag.need_backline
bors [Sun, 19 Dec 2021 17:14:12 +0000 (17:14 +0000)]
Auto merge of #92106 - matthiaskrgr:rollup-zw6t1mu, r=matthiaskrgr
Rollup of 4 pull requests
Successful merges:
- #91791 (Fix an ICE when lowering a float with missing exponent magnitude)
- #91878 (Remove `in_band_lifetimes` from `rustc_infer`)
- #91895 (Remove `in_band_lifetimes` for `rustc_monomorphize`)
- #92029 (Explicitly set no ELF flags for .rustc section)
Matthias Krüger [Sun, 19 Dec 2021 16:38:35 +0000 (17:38 +0100)]
Rollup merge of #92029 - nikic:section-flags-fix, r=davidtwco
Explicitly set no ELF flags for .rustc section
For a data section, the object crate will set the SHF_ALLOC by default, which is exactly what we don't want. Explicitly set sh_flags to zero to avoid this.
I checked with `objdump -h` that this produces the right flags for ELF.
Matthias Krüger [Sun, 19 Dec 2021 16:38:33 +0000 (17:38 +0100)]
Rollup merge of #91878 - LegionMammal978:less-inband-infer, r=Aaron1011
Remove `in_band_lifetimes` from `rustc_infer`
See #91867 for more information.
This crate actually had a typo `'ctx` in one of its functions:
```diff
-pub fn same_type_modulo_infer(a: Ty<'tcx>, b: Ty<'ctx>) -> bool {
+pub fn same_type_modulo_infer<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
```
Also, I wasn't entirely sure about the lifetimes in `suggest_new_region_bound`:
```diff
pub fn suggest_new_region_bound(
- tcx: TyCtxt<'tcx>,
+ tcx: TyCtxt<'_>,
err: &mut DiagnosticBuilder<'_>,
fn_returns: Vec<&rustc_hir::Ty<'_>>,
```
Should all of those lifetimes really be distinct?
Matthias Krüger [Sun, 19 Dec 2021 09:45:55 +0000 (10:45 +0100)]
Rollup merge of #92077 - jyn514:remove-collapsed, r=GuillaumeGomez
rustdoc: Remove unused `collapsed` field
`render/context` always runs after `run_global_context`, so it was always set to `true`.
This is a holdover from when rustdoc allowed configuring passes, but the `collapse-docs` pass was
removed ages ago, and the ability to configure passes is about to be removed.
Found while reviewing https://github.com/rust-lang/rust/pull/91305.
Matthias Krüger [Sun, 19 Dec 2021 09:45:54 +0000 (10:45 +0100)]
Rollup merge of #92071 - ajtribick:patch-1, r=the8472
Update example code for Vec::splice to change the length
The current example for `Vec::splice` illustrates the replacement of a section of length 2 with a new section of length 2. This isn't a particularly interesting case for splice, and makes it look a bit like a shorthand for the kind of manipulations that could be done with a mutable slice.
In order to provide a stronger example, this updates the example to use different lengths for the source and destination regions, and uses a slice from the middle of the vector to illustrate that this does not necessarily have to be at the beginning or the end.
Matthias Krüger [Sun, 19 Dec 2021 09:45:53 +0000 (10:45 +0100)]
Rollup merge of #92042 - ChrisDenton:msvc-static-tls, r=nagisa
Enable `#[thread_local]` for all windows-msvc targets
As it stands, `#[thread_local]` is enabled haphazardly for msvc. It seems all 64-bit targets have it enabled, but not 32-bit targets unless they're also UWP targets (perhaps because UWP was added more recently?). So this PR simply enables it for 32-bit targets as well. I can't think of a reason not to and I've confirmed by running tests locally which pass.
Matthias Krüger [Sun, 19 Dec 2021 09:45:51 +0000 (10:45 +0100)]
Rollup merge of #91984 - Aaron1011:rustc-middle-lifetime, r=oli-obk
Remove `in_band_lifetimes` from `rustc_middle`
See #91867
This was mostly straightforward. In several places, I take advantage
of the fact that lifetimes are non-hygenic: a macro declares the
'tcx' lifetime, which is then used in types passed in as macro
arguments.
bors [Sun, 19 Dec 2021 09:31:37 +0000 (09:31 +0000)]
Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obk
Remove `SymbolStr`
This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences.
bors [Sun, 19 Dec 2021 09:31:37 +0000 (09:31 +0000)]
Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obk
Remove `SymbolStr`
This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences.
bors [Sun, 19 Dec 2021 06:26:07 +0000 (06:26 +0000)]
Auto merge of #91871 - camelid:urlpartsbuilder, r=GuillaumeGomez
rustdoc: Add `UrlPartsBuilder`
This is a type for efficiently and easily constructing the part of a URL
after the domain: `nightly/core/str/struct.Bytes.html`.
It allows simplifying some code and avoiding some allocations in the
`href_*` functions.
It will also allow making `Cache.paths` et al. use `Symbol` without
having to allocate `String`s in the `href_*` functions. `String`s would
be necessary otherwise because `Symbol::as_str()` returns `SymbolStr`,
whose `Deref<Target = str>` impl requires the `str` to not outlive it.
This is the primary motivation for the addition of `UrlPartsBuilder`.
bors [Sun, 19 Dec 2021 03:33:19 +0000 (03:33 +0000)]
Auto merge of #89831 - Aaron1011:project-caching-speedup, r=jackh726
Re-introduce concept of projection cache 'completion'
Instead of clearing out the cache entirely, we store
the intermediate evaluation result into the cache entry.
This accomplishes several things:
* We avoid the performance hit associated with re-evaluating
the sub-obligations
* We avoid causing issues with incremental compilation, since
the final evaluation result is always the same
* We avoid affecting other uses of the same `InferCtxt` which
might care about 'side effects' from processing the sub-obligations
(e,g. region constraints). Only code that is specifically aware
of the new 'complete' code is affected
Aaron Hill [Sat, 9 Oct 2021 16:29:39 +0000 (11:29 -0500)]
Re-introduce concept of projection cache 'completion'
Instead of clearing out the cache entirely, we store
the intermediate evaluation result into the cache entry.
This accomplishes several things:
* We avoid the performance hit associated with re-evaluating
the sub-obligations
* We avoid causing issues with incremental compilation, since
the final evaluation result is always the same
* We avoid affecting other uses of the same `InferCtxt` which
might care about 'side effects' from processing the sub-obligations
(e,g. region constraints). Only code that is specifically aware
of the new 'complete' code is affected
Matthias Krüger [Sat, 18 Dec 2021 23:38:44 +0000 (00:38 +0100)]
Rollup merge of #92082 - jyn514:remove-from-iterator, r=jyn514
rustdoc: Write doc-comments directly instead of using FromIterator
The FromIterator impl made the code much harder to understand. The types
don't make sense until you realize there's a custom FromIterator impl.
This is the first commit from https://github.com/rust-lang/rust/pull/91305; since ``@camelid`` wrote it originally I don't feel bad unilaterally approving it.
r? ``@ghost``
``@bors`` r+
Note that this will conflict with https://github.com/rust-lang/rust/pull/92078.
Matthias Krüger [Sat, 18 Dec 2021 23:38:41 +0000 (00:38 +0100)]
Rollup merge of #91932 - Kixiron:randomize-seed, r=nagisa
Add user seed to `-Z randomize-layout`
Allows users of -`Z randomize-layout` to provide `-Z layout-seed=<seed>` in order to further randomizing type layout randomization. Extension of [compiler-team/#457](https://github.com/rust-lang/compiler-team/issues/457), allows users to change struct layouts without changing code and hoping that item path hashes change, aiding in detecting layout errors
bors [Sat, 18 Dec 2021 21:23:37 +0000 (21:23 +0000)]
Auto merge of #91837 - Kobzol:stable-hash-map-avoid-sort, r=the8472
Avoid sorting in hash map stable hashing
Suggested by `@the8472` [here](https://github.com/rust-lang/rust/pull/89404#issuecomment-991813333). I hope that I understood it right, I replaced the sort with modular multiplication, which should be commutative.
Can I ask for a perf. run? However, locally it didn't help at all. Creating the `StableHasher` all over again is probably slowing it down quite a lot. And using `FxHasher` is not straightforward, because the keys and values only implement `HashStable` (and probably they shouldn't be just hashed via `Hash` anyway for it to actually be stable).
Maybe the `StableHash` interface could be changed somehow to better suppor these scenarios where the hasher is short-lived. Or the `StableHasher` implementation could have variants with e.g. a shorter buffer for these scenarios.
bors [Sat, 18 Dec 2021 18:08:51 +0000 (18:08 +0000)]
Auto merge of #92065 - matthiaskrgr:rollup-qmpcsuj, r=matthiaskrgr
Rollup of 7 pull requests
Successful merges:
- #91566 (Apply path remapping to DW_AT_GNU_dwo_name when producing split DWARF)
- #91926 (Remove `in_band_lifetimes` from `rustc_metadata`)
- #91931 (Remove `in_band_lifetimes` from `rustc_codegen_llvm`)
- #92024 (rustc_codegen_llvm: Give each codegen unit a unique DWARF name on all platforms, not just Apple ones.)
- #92037 (Use a const ParamEnv when in default_method_body_is_const)
- #92047 (Set `RUST_BACKTRACE=0` when running location-detail tests)
- #92050 (Add a space and 2 grave accents )
Nikita Popov [Fri, 17 Dec 2021 10:26:39 +0000 (11:26 +0100)]
Explicitly set no ELF flags for .rustc section
For a data section, the object crate will set the SHF_ALLOC by
default, which is exactly what we don't want. Explicitly set
sh_flags to zero to avoid this.
Joshua Nelson [Sat, 18 Dec 2021 16:44:58 +0000 (10:44 -0600)]
Remove `collapsed` field
`render/context` always runs after `run_global_context`, so it was always set to `true`.
This is a holdover from when rustdoc allowed configuring passes, but the `collapse-docs` pass was
removed ages ago, and the ability to configure passes is about to be removed.
bors [Sat, 18 Dec 2021 15:01:32 +0000 (15:01 +0000)]
Auto merge of #92064 - matthiaskrgr:rollup-tgj2pai, r=matthiaskrgr
Rollup of 7 pull requests
Successful merges:
- #91858 (pass -Wl,-z,origin to set DF_ORIGIN when using rpath)
- #91923 (Remove `in_band_lifetimes` from `rustc_query_impl`)
- #91925 (Remove `in_band_lifetimes` from `rustc_privacy`)
- #91977 (Clean up search code and unify function returned values)
- #92018 (Fix typo in "new region bound" suggestion)
- #92022 (Eliminate duplicate codes of expected_found_bool)
- #92032 (hir: Do not introduce dummy type names for `extern` blocks in def paths)
Matthias Krüger [Sat, 18 Dec 2021 13:49:42 +0000 (14:49 +0100)]
Rollup merge of #92037 - fee1-dead:fix_env_dmbic, r=oli-obk
Use a const ParamEnv when in default_method_body_is_const
r? `@oli-obk`
This PR fixes the param_env function to return `constness: Const` correctly for trait methods marked with `#[default_method_body_is_const]`. The snippet below is erroneously accepted by the compiler and has been fixed by this change. ([Playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=12dc6681b2eeee5f604203d96259eeb4))
Matthias Krüger [Sat, 18 Dec 2021 13:49:41 +0000 (14:49 +0100)]
Rollup merge of #92024 - pcwalton:per-codegen-unit-names, r=davidtwco
rustc_codegen_llvm: Give each codegen unit a unique DWARF name on all platforms, not just Apple ones.
To avoid breaking split DWARF, we need to ensure that each codegen unit has a
unique `DW_AT_name`. This is because there's a remote chance that different
codegen units for the same module will have entirely identical DWARF entries
for the purpose of the DWO ID, which would violate Appendix F ("Split Dwarf
Object Files") of the DWARF 5 specification. LLVM uses the algorithm specified
in section 7.32 "Type Signature Computation" to compute the DWO ID, which does
not include any fields that would distinguish compilation units. So we must
embed the codegen unit name into the `DW_AT_name`.
Matthias Krüger [Sat, 18 Dec 2021 13:49:40 +0000 (14:49 +0100)]
Rollup merge of #91931 - LegionMammal978:less-inband-codegen_llvm, r=davidtwco
Remove `in_band_lifetimes` from `rustc_codegen_llvm`
See #91867 for more information.
This one took a while. This crate has dozens of functions not associated with any type, and most of them were using in-band lifetimes for `'ll` and `'tcx`.
Matthias Krüger [Sat, 18 Dec 2021 13:49:38 +0000 (14:49 +0100)]
Rollup merge of #91566 - cbeuw:remap-dwo-name, r=davidtwco
Apply path remapping to DW_AT_GNU_dwo_name when producing split DWARF
`--remap-path-prefix` doesn't apply to paths to `.o` (in case of packed) or `.dwo` (in case of unpacked) files in `DW_AT_GNU_dwo_name`. GCC also has this bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91888
Matthias Krüger [Sat, 18 Dec 2021 10:28:06 +0000 (11:28 +0100)]
Rollup merge of #92022 - woodenarrow:br_expected_bool, r=estebank
Eliminate duplicate codes of expected_found_bool
The function expected_found_bool is the same as ExpectedFound::new. So use ExpectedFound::new to replace expected_found_bool to eliminate duplicate codes.
Matthias Krüger [Sat, 18 Dec 2021 10:28:01 +0000 (11:28 +0100)]
Rollup merge of #91858 - semarie:runpath, r=petrochenkov
pass -Wl,-z,origin to set DF_ORIGIN when using rpath
DF_ORIGIN flag signifies that the object being loaded may make reference to the $ORIGIN substitution string.
Some implementations are just ignoring [DF_ORIGIN](http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#df_flags) and do [substitution](http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#substitution) for $ORIGIN if present (whatever DF_ORIGIN presence or not) like glibc. But some others mandate the present of DF_ORIGIN for the substitution (like OpenBSD).
Set the flag inconditionally if rpath is wanted.
One possible fallout is if the linker rejects `-z origin` option.