bors [Sat, 27 Aug 2022 16:57:19 +0000 (16:57 +0000)]
Auto merge of #100591 - est31:stabilization_placeholder, r=Mark-Simulacrum
Require stabilizations to use a placeholder instead of writing out stabilization version
Implements the idea from [this](https://rust-lang.zulipchat.com/#narrow/stream/241545-t-release/topic/libs.20stabilization.20placeholder) zulip stream.
It's a common phenomenon that feature stabilizations don't make it into a particular release, but the version is still inaccurate. Often this is caught in the PR, but it can also require subsequent changes to adjust/correct the version. A list with examples of such PRs is given in #100577, but it's far from complete.
This PR requires stabilization PRs to use the placeholder `CURRENT_RUSTC_VERSION`, enforced via tidy tooling. The PR also adds a tool that replaces the placeholder with the version number. It can be invoked via `./x.py run src/tools/replace-version-placeholder` and is supposed to be ran upon beta branching as well as version bumping and any backports to the beta branch. I filed PRs to the dev guide and forge to document these changes in the release and stabilization workflows:
* The [dev guide](https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#determining-the-stabilization-version) PR: https://github.com/rust-lang/rustc-dev-guide/pull/1443
* The [std dev guide](https://std-dev-guide.rust-lang.org/) PR: https://github.com/rust-lang/std-dev-guide/pull/43
* The [forge](https://github.com/rust-lang/rust-forge) PR: https://github.com/rust-lang/rust-forge/pull/643
est31 [Mon, 15 Aug 2022 14:57:46 +0000 (16:57 +0200)]
tidy: forbid since values for features that point to the current release or future ones
It's a common phenomenon that feature stabilizations don't make it into
a particular release, but the version is still inaccurate. Often this
leads to subsequent changes to adjust/correct the version.
Instead, require people to put a placeholder that gets replaced during
beta branching time with the current rust version. That way, there is
no chance that an error can be introduced.
Usage of the placeholder is required on the nightly channel, and forbidden
on the stable and beta channels.
This selector was added in c7312fbae4979c6d4fdfbd1f55a71cd47d82a480. The bug can be seen at <https://doc.rust-lang.org/1.27.0/alloc/slice/trait.SliceIndex.html#foreign-impls>.
This rule was added to help with a `<table>` that was used for displaying the function signature [src] lockup. That lockup was changed in 34bd2b845b3acd84c5a9bddae3ff8081c19ec5e9 to use flexbox instead, leaving this selector unused (at least, for its original purpose).
Yuki Okushi [Sat, 27 Aug 2022 04:14:22 +0000 (13:14 +0900)]
Rollup merge of #101044 - notriddle:notriddle/css-hidden-by, r=jsha
rustdoc: remove unused CSS for `hidden-by-*-hider`
This CSS seems to have become obsolete with the move to `<details>` tags,
and its corresponding JavaScript was removed in aee054d05d8b795d35c0b448a4b731b6507aa459
Yuki Okushi [Sat, 27 Aug 2022 04:14:20 +0000 (13:14 +0900)]
Rollup merge of #100953 - joshtriplett:write-docs, r=Mark-Simulacrum
Update documentation for `write!` and `writeln!`
https://github.com/rust-lang/rust/pull/37472 added this documentation, but it
needs updating:
- Remove some documentation duplicated between `writeln!` and `write!`
- Update `write!` docs: can now import traits as `_` to avoid conflicts
- Expand example to show how to implement qualified trait names
Yuki Okushi [Sat, 27 Aug 2022 04:14:18 +0000 (13:14 +0900)]
Rollup merge of #100811 - czzrr:master, r=Mark-Simulacrum
Fix wrong compiletest filters on Windows
As discussed in [#79334](https://github.com/rust-lang/rust/issues/79334), when calling e.g.
```
python x.py test src/test/ui/expr/compound-assignment/eval-order.rs
```
on Windows, compiletest passes the filter `expr/compound-assignment/eval-order.rs` to libtest, which instead should be `expr\compound-assignment\eval-order.rs`, as that is the file found when collecting tests. This is what I fixed.
I'm not sure how to organize a test for this. Any suggestions?
Yuki Okushi [Sat, 27 Aug 2022 04:14:16 +0000 (13:14 +0900)]
Rollup merge of #99784 - est31:deny_cfg_attr_crate_type_name, r=Mark-Simulacrum
Make forward compatibility lint deprecated_cfg_attr_crate_type_name deny by default
Turns the forward compatibility lint added by #83744 to deprecate `cfg_attr` usage with `#![crate_type]` and `#![crate_name]` attributes into deny by default. Copying the example from #83744:
```Rust
#![crate_type = "lib"] // remains working
#![cfg_attr(foo, crate_type = "bin")] // will stop working
```
Over 8 months have passed since #83744 was merged so I'd say this gives ample time for people to have been warned, so we can make the warning stronger. No usage was found via grep.app except for one, which was in an unmaintained code base that didn't seem to be used in the open source eco system. The crater run conducted in #83744 also didn't show up anything.
bors [Sat, 27 Aug 2022 03:19:12 +0000 (03:19 +0000)]
Auto merge of #100732 - dpaoliello:import_name_type, r=wesleywiser
Implementation of import_name_type
Fixes #96534 by implementing https://github.com/rust-lang/compiler-team/issues/525
Symbols that are exported or imported from a binary on 32bit x86 Windows can be named in four separate ways, corresponding to the [import name types](https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-name-type) from the PE-COFF spec. The exporting and importing binaries must use the same name encoding, otherwise mismatches can lead to link failures due to "missing symbols" or to 0xc0000139 (`STATUS_ENTRYPOINT_NOT_FOUND`) errors when the executable/library is loaded. For details, see the comments on the raw-dylib feature's https://github.com/rust-lang/rust/issues/58713. To generate the correct import libraries for these DLLs, therefore, rustc must know the import name type for each `extern` function, and there is currently no way for users to provide this information.
This change adds a new `MetaNameValueStr` key to the `#[link]` attribute called `import_name_type`, and which accepts one of three values: `decorated`, `noprefix`, and `undecorated`.
A single DLL is likely to export all its functions using the same import type name, hence `import_name_type` is a parameter of `#[link]` rather than being its own attribute that is applied per-function. It is possible to have a single DLL that exports different functions using different import name types, but users could express such cases by providing multiple export blocks for the same DLL, each with a different import name type.
Note: there is a fourth import name type defined in the PE-COFF spec, `IMPORT_ORDINAL`. This case is already handled by the `#[link_ordinal]` attribute. While it could be merged into `import_type_name`, that would not make sense as `#[link_ordinal]` provides per-function information (namely the ordinal itself).
Design decisions (these match the MCP linked above):
* For GNU, `decorated` matches the PE Spec and MSVC rather than the default behavior of `dlltool` (i.e., there will be a leading `_` for `stdcall`).
* If `import_name_type` is not present, we will keep our current behavior of matching the environment (MSVC vs GNU) default for decorating.
* Using `import_name_type` on architectures other than 32bit x86 will result in an error.
* Using `import_name_type` with link kinds other than `"raw-dylib"` will result in an error.
bors [Sat, 27 Aug 2022 00:38:06 +0000 (00:38 +0000)]
Auto merge of #101064 - compiler-errors:rollup-fwm5m5f, r=compiler-errors
Rollup of 9 pull requests
Successful merges:
- #100724 (Migrate ast lowering to session diagnostic)
- #100735 (Migrate `rustc_ty_utils` to `SessionDiagnostic`)
- #100738 (Diagnostics migr const eval)
- #100744 (Migrate rustc_mir_dataflow to diagnostic structs)
- #100776 (Migrate `rustc_lint` errors to `SessionDiagnostic`)
- #100817 (sugg: suggest the usage of boolean value when there is a typo in the keyword)
- #100836 (Migrate `rustc_attr` crate diagnostics)
- #100890 (Migrate rustc_driver to SessionDiagnostic)
- #100900 (on `region_errors.rs`)
Failed merges:
- #100831 (Migrate `symbol_mangling` module to new diagnostics structs)
Michael Goulet [Fri, 26 Aug 2022 22:56:29 +0000 (15:56 -0700)]
Rollup merge of #100890 - adriantombu:migrate_diagnostic_rustc_driver, r=davidtwco
Migrate rustc_driver to SessionDiagnostic
First timer noob here 👋🏽 I'm having a problem understanding how I can retrieve the span, and how to properly construct the error structs to avoid the current compilation errors.
Any help pointing me in the right direction would be much appreciated 🙌🏽
Michael Goulet [Fri, 26 Aug 2022 22:56:28 +0000 (15:56 -0700)]
Rollup merge of #100836 - hampuslidin:migrate-attr-crate-diagnostics, r=davidtwco
Migrate `rustc_attr` crate diagnostics
Hi!
This is my first PR to the rustc project, excited to be part of the development! This PR is part of the diagnostics effort, to make diagnostics translatable.
This adds a new suggestion when there is a well-known typo
With the following program
```rust
fn main() {
let x = True;
}
```
Now we have the following suggestion
```
error[E0425]: cannot find value `True` in this scope
--> test.rs:2:13
|
2 | let x = True;
| ^^^^ not found in this scope
|
help: you may want to use a bool value instead
|
2 | let x = true;
| ~~~~
Michael Goulet [Fri, 26 Aug 2022 22:56:25 +0000 (15:56 -0700)]
Rollup merge of #100776 - Rejyr:diagnostic-migration-rustc-lint, r=davidtwco
Migrate `rustc_lint` errors to `SessionDiagnostic`
Draft PR for migrating `rustc_lint` to `SessionDiagnostic`, as part of the [recent blog post](https://blog.rust-lang.org/inside-rust/2022/08/16/diagnostic-effort.html)
Michael Goulet [Fri, 26 Aug 2022 22:56:22 +0000 (15:56 -0700)]
Rollup merge of #100735 - Facel3ss1:ty-utils-translation, r=davidtwco
Migrate `rustc_ty_utils` to `SessionDiagnostic`
I have migrated the `rustc_ty_utils` crate to use `SessionDiagnostic`, motivated by the [recent blog post about the diagnostic translation effort](https://blog.rust-lang.org/inside-rust/2022/08/16/diagnostic-effort.html).
This is my first PR to the Rust repository, so if I have missed anything, or anything needs to be changed, please let me know! 😄
Michael Goulet [Fri, 26 Aug 2022 22:56:21 +0000 (15:56 -0700)]
Rollup merge of #100724 - JeanCASPAR:migrate-ast_lowering-to-session-diagnostic, r=davidtwco
Migrate ast lowering to session diagnostic
I migrated the whole rustc_ast_lowering crate to session diagnostic *except* the for the use of `span_fatal` at /compiler/rustc_ast_lowering/src/expr.rs#L1268 because `#[fatal(...)]` is not yet supported (see https://github.com/rust-lang/rust/pull/100694).
bors [Fri, 26 Aug 2022 21:50:09 +0000 (21:50 +0000)]
Auto merge of #100043 - RalfJung:scalar-always-init, r=RalfJung
interpret: remove support for uninitialized scalars
With Miri no longer supporting `-Zmiri-allow-uninit-numbers`, we no longer need to support storing uninit data in a `Scalar`. We anyway already only use this representation for types with *initialized* `Scalar` layout (and we have to, due to partial initialization), so let's get rid of the `ScalarMaybeUninit` type entirely.
I tried to stage this into meaningful commits, but the one that changes `read_immediate` to always trigger UB on uninit is the largest chunk of the PR and I don't see how it could be subdivided.
This selector was added in c7312fbae4979c6d4fdfbd1f55a71cd47d82a480.
The bug can be seen at <https://doc.rust-lang.org/1.27.0/alloc/slice/trait.SliceIndex.html#foreign-impls>.
This rule was added to help with a `<table>` that was used for displaying the
function signature [src] lockup. That lockup was changed in 34bd2b845b3acd84c5a9bddae3ff8081c19ec5e9 to use flexbox instead, leaving this
selector unused (at least, for its original purpose).
bors [Fri, 26 Aug 2022 15:47:26 +0000 (15:47 +0000)]
Auto merge of #98051 - davidtwco:split-dwarf-stabilization, r=wesleywiser
session: stabilize split debuginfo on linux
Stabilize the `-Csplit-debuginfo` flag...
- ...on Linux for all values of the flag. Split DWARF has been implemented for a few months, hasn't had any bug reports and has had some promising benchmarking for incremental debug build performance.
- ..on other platforms for the default value. It doesn't make any sense that `-Csplit-debuginfo=packed` is unstable on Windows MSVC when that's the default behaviour, but keep the other values unstable.
Michael Howell [Fri, 26 Aug 2022 14:34:55 +0000 (07:34 -0700)]
rustdoc: remove unused CSS for `hidden-by-*-hider`
This CSS seems to have become obsolete with the move to `<details>` tags,
and its corresponding JavaScript was removed in aee054d05d8b795d35c0b448a4b731b6507aa459
Guillaume Gomez [Fri, 26 Aug 2022 12:08:50 +0000 (14:08 +0200)]
Rollup merge of #101023 - notriddle:notriddle/head-shrink, r=Dylan-DPC
rustdoc: remove `type="text/css"` from stylesheet links
MDN directly recommends this in <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link>, since "CSS is the only stylesheet language used on the web."
Guillaume Gomez [Fri, 26 Aug 2022 12:08:49 +0000 (14:08 +0200)]
Rollup merge of #101012 - notriddle:notriddle/variants_table, r=jsha
rustdoc: remove unused CSS for `.variants_table`
Continuation of #100938 and #101010. This rule was added to support the old, table-based style for displaying enum variants, which are now displayed using headers and paragraphs.
Guillaume Gomez [Fri, 26 Aug 2022 12:08:48 +0000 (14:08 +0200)]
Rollup merge of #101006 - GuillaumeGomez:doc-cfg-reexport, r=notriddle
Fix doc cfg on reexports
Fixes #83428.
The problem was that the newly inlined item cfg propagation was not working since its real parent is different than its current one.
For the implementation, I decided to put it directly into `CfgPropagation` instead of inside `inline.rs` because I thought it would be simpler to maintain and to not forget if new kind of items are added if it's all done in one place.
Guillaume Gomez [Fri, 26 Aug 2022 12:08:47 +0000 (14:08 +0200)]
Rollup merge of #100956 - GuillaumeGomez:reduce-rightside-dom-size, r=notriddle
Reduce right-side DOM size
This is another follow-up of https://github.com/rust-lang/rust/pull/100429 but not in code blocks this time.
So the idea is: if there is only one element in the `.rightside` element, there is no need to wrap it, we can just create one node.
On each page, I run this JS: `document.getElementsByTagName('*').length`. Important to note: the bigger the number of elements inside the page, the greater the gain. It also doesn't work very nicely on std docs because there are a lot of version annotations. So with this PR, It allows to get the following results:
Guillaume Gomez [Fri, 26 Aug 2022 12:08:44 +0000 (14:08 +0200)]
Rollup merge of #99742 - sigaloid:master, r=thomcc
Add comments about stdout locking
This is the source of some confusion regarding the `println!` macro:
* https://llogiq.github.io/2017/06/01/perf-pitfalls.html#unbuffered-io
* https://news.ycombinator.com/item?id=18794930
* https://reddit.com/r/rust/comments/5puyx2/why_is_println_so_slow/dcua5g5/
* https://reddit.com/r/rust/comments/ab7hsi/comparing_pythagorean_triples_in_c_d_and_rust/ecy7ql8/
In some of these cases it's not the locking behavior where the bottleneck lies, but it's still mentioned as a surprise when, eg, benchmarking a million `println!`'s in a very tight loop.
If there's any stylistic problems please feel free to correct me! This is my first contribution and I want to get it right :crab:
Guillaume Gomez [Fri, 26 Aug 2022 12:08:43 +0000 (14:08 +0200)]
Rollup merge of #95005 - ssomers:btree_static_assert, r=thomcc
BTree: evaluate static type-related check at compile time
`assert`s like the ones replaced here would only go off when you run the right test cases, if the code were ever incorrectly changed such that rhey would trigger. But [inspired on a nice forum question](https://users.rust-lang.org/t/compile-time-const-generic-parameter-check/69202), they can be checked at compile time.
bors [Fri, 26 Aug 2022 06:05:06 +0000 (06:05 +0000)]
Auto merge of #100705 - compiler-errors:issue-100620, r=oli-obk
Avoid reporting overflow in `is_impossible_method`
Fixes #100620
We're evaluating a new predicate in a different param-env than it was checked during typeck, so be more careful about handling overflow errors. Instead of using `FulfillmentCtxt`, using `InferCtxt::evaluate_obligation` by itself will give us back the overflow error, so we can throw it away properly.
This may give us more false-positives, but it doesn't regress the `<HashMap as Iterator>::rev` example that originally motivated adding `is_impossible_method` in the first place.
Michael Howell [Fri, 26 Aug 2022 04:28:20 +0000 (21:28 -0700)]
rustdoc: remove `type="text/css" from stylesheet links
MDN directly recommends this in <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link>,
since "CSS is the only stylesheet language used on the web."
Yuki Okushi [Fri, 26 Aug 2022 00:51:47 +0000 (09:51 +0900)]
Rollup merge of #101010 - notriddle:notriddle/multi-column, r=jsha
rustdoc: remove unused CSS for `.multi-column`
As a sanity check, [this tool] can be used to run a CSS query across an HTML tree to detect if a selector ever matches (I use compiler-docs and std docs). This isn't good enough, because I also need to account for JavaScript, but this class is never mentioned in any of the JS files, either.
According to [blame], this class was added when rustdoc was first written, and, as far as I can tell, was never actually used.
Yuki Okushi [Fri, 26 Aug 2022 00:51:43 +0000 (09:51 +0900)]
Rollup merge of #100076 - tspiteri:const_slice_split_at, r=oli-obk
make slice::{split_at,split_at_unchecked} const functions
Now that `slice::from_raw_parts` is const in stable 1.64, it makes sense to have `split_at` const as well, otherwise unsafe code is required to achieve a const equivalent.
Yuki Okushi [Fri, 26 Aug 2022 00:51:42 +0000 (09:51 +0900)]
Rollup merge of #100034 - tmiasko:elaborate-box-derefs, r=oli-obk
Elaborate all box dereferences in `ElaborateBoxDerefs`
so that it is the only pass responsible for elaboration, instead of
splitting this responsibility between the `StateTransform` and
`ElaborateBoxDerefs`.
Yuki Okushi [Fri, 26 Aug 2022 00:51:40 +0000 (09:51 +0900)]
Rollup merge of #99064 - lyming2007:issue-97687-fix, r=estebank
distinguish the method and associated function diagnostic information
Methods are defined within the context of a struct and their first parameter is always self
Associated functions don’t take self as a parameter
```
modified: compiler/rustc_typeck/src/check/method/suggest.rs
modified: src/test/ui/auto-ref-slice-plus-ref.stderr
modified: src/test/ui/block-result/issue-3563.stderr
modified: src/test/ui/issues/issue-28344.stderr
modified: src/test/ui/suggestions/dont-suggest-pin-array-dot-set.stderr
modified: src/test/ui/suggestions/suggest-methods.stderr
modified: src/test/ui/traits/trait-upcasting/subtrait-method.stderr
```
Currently they try to be very precise. But they are wrong, i.e. they
don't match what's happening in the loop below. This code isn't hot
enough for it to matter that much.
bors [Fri, 26 Aug 2022 00:42:40 +0000 (00:42 +0000)]
Auto merge of #99487 - bmacnaughton:is_whitespace_updates, r=thomcc
is_whitespace() performance improvements
This is my first rust PR, so if I miss anything obvious please let me know and I'll do my best to fix it.
This was a bit more of a challenge than I realized because, while I made working code locally and tested it against the native `is_whitespace()`, this PR required changing `src/tools/unicode-table-generator`, the code that generated the code.
I have benchmarked this locally, using criterion, and have seen meaningful performance improvements. I can add those outputs to this if you'd like, but am guessing that the perf run that `@fmease` recommended is what's needed.
I have run ` ./x.py test --stage 0 library/std` after building it locally after executing `./x.py build library`. I didn't try to build the whole compiler, but maybe I should have - any guidance would be appreciated.
If this general approach makes sense, I'll take a look at some other candidate categories, e.g., `Cc`, in the future.
Oh, and I wasn't sure whether the generated code should be included in this PR or not. I did include it.
Michael Howell [Thu, 25 Aug 2022 21:27:40 +0000 (14:27 -0700)]
rustdoc: remove unused CSS for `.variants_table`
Continuation of #100938 and #101010. This rule was added to support the old,
table-based style for displaying enum variants, which are now displayed using
headers and paragraphs.
bors [Thu, 25 Aug 2022 21:27:38 +0000 (21:27 +0000)]
Auto merge of #100748 - SparrowLii:query_depth, r=cjgillot
add `depth_limit` in `QueryVTable` to avoid entering a new tcx in `layout_of`
Fixes #49735
Updates #48685
The `layout_of` query needs to check whether it overflows the depth limit, and the current implementation needs to create a new `ImplicitCtxt` inside `layout_of`. However, `start_query` will already create a new `ImplicitCtxt`, so we can check the depth limit in `start_query`.
We can tell whether we need to check the depth limit simply by whether the return value of `to_debug_str` of the query is `layout_of`. But I think adding the `depth_limit` field in `QueryVTable` may be more elegant and more scalable.
Michael Howell [Thu, 25 Aug 2022 18:43:36 +0000 (11:43 -0700)]
rustdoc: remove unused CSS for `.multi-column`
As a sanity check, [this tool] can be used to run a CSS query across an HTML
tree to detect if a selector ever matches (I use compiler-docs and std
docs). This isn't good enough, because I also need to account for JavaScript,
but this class is never mentioned in any of the JS files, either.
According to [blame], this class was added when rustdoc was first written,
and, as far as I can tell, was never actually used.
bors [Thu, 25 Aug 2022 18:17:42 +0000 (18:17 +0000)]
Auto merge of #100911 - tmiasko:update-stdarch, r=Amanieu
Update stdarch submodule
Changes from stdarch:
* Fix links in documentation of cmpxchg16b
* Use load intrinsic and loop for intrinsic-test programs. Add --release flag back to intrinsic-test programs.
* Properly fix vext intrinsic tests
* Replace some calls to `pointer::offset` with `add` and `sub`
* Allow internal use of stdsimd from detect_feature
* fix target name in contributing.md
* Tweak constant for ARM vext instruction tests
* Use `llvm.ppc.altivec.lvx` intrinsic for `vec_ld`
* Adding doc links for arm neon intrinsics
* Adding doc links for arm crypto and aes intrinsics
* Remove instruction tests for `__mmask*` intrinsics
* Update ubuntu 21.10 docker containers to 22.04
* Adding documentation links for arm crc32 intrinsics
* Remove restrictions on compare-exchange memory ordering.
* Fix a typo in the document.
* Allow mapping a runtime feature to a set of target_features
* Update atomic intrinsics
* Fully qualify recursive macro calls
* Ensure the neon vector aggregates like `float32x4x4_t` are `#[repr(C)]`
* Remove useless conditional compilation
* Fix ARM vbsl* NEON intrinsics