]> git.lizzy.rs Git - rust.git/log
rust.git
23 months agoAuto merge of #99182 - RalfJung:mitigate-uninit, r=scottmcm
bors [Thu, 28 Jul 2022 01:11:10 +0000 (01:11 +0000)]
Auto merge of #99182 - RalfJung:mitigate-uninit, r=scottmcm

mem::uninitialized: mitigate many incorrect uses of this function

Alternative to https://github.com/rust-lang/rust/pull/98966: fill memory with `0x01` rather than leaving it uninit. This is definitely bitewise valid for all `bool` and nonnull types, and also those `Option<&T>` that we started putting `noundef` on. However it is still invalid for `char` and some enums, and on references the `dereferenceable` attribute is still violated, so the generated LLVM IR still has UB -- but in fewer cases, and `dereferenceable` is hopefully less likely to cause problems than clearly incorrect range annotations.

This can make using `mem::uninitialized` a lot slower, but that function has been deprecated for years and we keep telling everyone to move to `MaybeUninit` because it is basically impossible to use `mem::uninitialized` correctly. For the cases where that hasn't helped (and all the old code out there that nobody will ever update), we can at least mitigate the effect of using this API. Note that this is *not* in any way a stable guarantee -- it is still UB to call `mem::uninitialized::<bool>()`, and Miri will call it out as such.

This is somewhat similar to https://github.com/rust-lang/rust/pull/87032, which proposed to make `uninitialized` return a buffer filled with 0x00. However
- That PR also proposed to reduce the situations in which we panic, which I don't think we should do at this time.
- The 0x01 bit pattern means that nonnull requirements are satisfied, which (due to references) is the most common validity invariant.

`@5225225` I hope I am using `cfg(sanitize)` the right way; I was not sure for which ones to test here.
Cc https://github.com/rust-lang/rust/issues/66151
Fixes https://github.com/rust-lang/rust/issues/87675

23 months agoAuto merge of #99725 - lcnr:dedup-region_bound_pairs, r=compiler-errors
bors [Wed, 27 Jul 2022 22:02:14 +0000 (22:02 +0000)]
Auto merge of #99725 - lcnr:dedup-region_bound_pairs, r=compiler-errors

use `FxIndexSet` for `region_bound_pairs`

should help with #99217 and might generally be a perf improvement.

r? types

23 months agoAuto merge of #99816 - GuillaumeGomez:rollup-tyobksa, r=GuillaumeGomez
bors [Wed, 27 Jul 2022 18:22:33 +0000 (18:22 +0000)]
Auto merge of #99816 - GuillaumeGomez:rollup-tyobksa, r=GuillaumeGomez

Rollup of 7 pull requests

Successful merges:

 - #94247 (Fix slice::ChunksMut aliasing)
 - #99358 (Allow `ValTree::try_to_raw_bytes` on `u8` array)
 - #99651 (Deeply deny fn and raw ptrs in const generics)
 - #99710 (lint: add bad opt access internal lint)
 - #99717 (Add some comments to the docs issue template to clarify)
 - #99728 (Clean up HIR-based lifetime resolution)
 - #99812 (Fix headings colors)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

23 months agoRollup merge of #99812 - GuillaumeGomez:fix-headings-colors, r=jsha,notriddle
Guillaume Gomez [Wed, 27 Jul 2022 15:55:08 +0000 (17:55 +0200)]
Rollup merge of #99812 - GuillaumeGomez:fix-headings-colors, r=jsha,notriddle

Fix headings colors

Fixes #99797.

![image](https://user-images.githubusercontent.com/3050060/181260966-49faf9d3-f6b8-4de4-bc7d-ed9f0467cf68.png)

cc `@jsha`
r? `@notriddle`

23 months agoRollup merge of #99728 - cjgillot:ast-lifetimes-anon-clean, r=petrochenkov
Guillaume Gomez [Wed, 27 Jul 2022 15:55:07 +0000 (17:55 +0200)]
Rollup merge of #99728 - cjgillot:ast-lifetimes-anon-clean, r=petrochenkov

Clean up HIR-based lifetime resolution

Based on https://github.com/rust-lang/rust/pull/97313.

Fixes #98932.

r? `@petrochenkov`

23 months agoRollup merge of #99717 - JohnTitor:upd-docs-issue-tmpl, r=Mark-Simulacrum
Guillaume Gomez [Wed, 27 Jul 2022 15:55:06 +0000 (17:55 +0200)]
Rollup merge of #99717 - JohnTitor:upd-docs-issue-tmpl, r=Mark-Simulacrum

Add some comments to the docs issue template to clarify

Newcomers may not know that some docs have their own repositories (e.g. the book, the reference), or that the documentation and rustdoc are different.
Actually, this template was used to report an issue related to the book: https://github.com/rust-lang/rust/issues/99699
This adds some comments to clarify the above things. I'm not sure if the current wording is the best, any suggestion would be helpful!

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
23 months agoRollup merge of #99710 - davidtwco:internal-lint-opts, r=lcnr
Guillaume Gomez [Wed, 27 Jul 2022 15:55:05 +0000 (17:55 +0200)]
Rollup merge of #99710 - davidtwco:internal-lint-opts, r=lcnr

lint: add bad opt access internal lint

Prompted by [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/sess.2Ecrate_types.28.29.20vs.20sess.2Eopts.2Ecrate_types/near/290682847).

Some command-line options accessible through `sess.opts` are best accessed through wrapper functions on `Session`, `TyCtxt` or otherwise, rather than through field access on the option struct in the `Session`.

Adds a new lint which triggers on those options that should be accessed through a wrapper function so that this is prohibited. Options are annotated with a new attribute `rustc_lint_opt_deny_field_access` which can specify the error message (i.e. "use this other function instead") to be emitted.

A simpler alternative would be to simply rename the options in the option type so that it is clear they should not be used, however this doesn't prevent uses, just discourages them. Another alternative would be to make the option fields private, and adding accessor functions on the option types, however the wrapper functions sometimes rely on additional state from `Session` or `TyCtxt` which wouldn't be available in an function on the option type, so the accessor would simply make the field available and its use would be discouraged too.

**Leave a comment if there's an option I should add this to.**

23 months agoRollup merge of #99651 - compiler-errors:fn-and-raw-ptr-in-const-generics, r=oli-obk
Guillaume Gomez [Wed, 27 Jul 2022 15:55:04 +0000 (17:55 +0200)]
Rollup merge of #99651 - compiler-errors:fn-and-raw-ptr-in-const-generics, r=oli-obk

Deeply deny fn and raw ptrs in const generics

I think this is right -- just because we wrap a fn ptr in a wrapper type does not mean we should allow it in a const parameter.

We now reject both of these in the same way:

```
#![feature(adt_const_params)]

#[derive(Eq, PartialEq)]
struct Wrapper();

fn foo<const W: Wrapper>() {}

fn foo2<const F: fn()>() {}
```

This does regress one test (`src/test/ui/consts/refs_check_const_eq-issue-88384.stderr`), but I'm not sure it should've passed in the first place.

cc: ``@b-naber`` who introduced that test^
fixes #99641

23 months agoRollup merge of #99358 - compiler-errors:issue-99325, r=oli-obk
Guillaume Gomez [Wed, 27 Jul 2022 15:55:03 +0000 (17:55 +0200)]
Rollup merge of #99358 - compiler-errors:issue-99325, r=oli-obk

Allow `ValTree::try_to_raw_bytes` on `u8` array

Fixes #99325

cc `@b-naber` I think who touched this last in 705d818bd52a6324d5e7693cc4306457395eebc8

23 months agoRollup merge of #94247 - saethlin:chunksmut-aliasing, r=the8472
Guillaume Gomez [Wed, 27 Jul 2022 15:55:01 +0000 (17:55 +0200)]
Rollup merge of #94247 - saethlin:chunksmut-aliasing, r=the8472

Fix slice::ChunksMut aliasing

Fixes https://github.com/rust-lang/rust/issues/94231, details in that issue.
cc `@RalfJung`

This isn't done just yet, all the safety comments are placeholders. But otherwise, it seems to work.

I don't really like this approach though. There's a lot of unsafe code where there wasn't before, but as far as I can tell the only other way to uphold the aliasing requirement imposed by `__iterator_get_unchecked` is to use raw slices, which I think require the same amount of unsafe code. All that would do is tie the `len` and `ptr` fields together.

Oh I just looked and I'm pretty sure that `ChunksExactMut`, `RChunksMut`, and `RChunksExactMut` also need to be patched. Even more reason to put up a draft.

23 months agoAuto merge of #99731 - ehuss:let-chain-bracket-check, r=compiler-errors
bors [Wed, 27 Jul 2022 15:32:01 +0000 (15:32 +0000)]
Auto merge of #99731 - ehuss:let-chain-bracket-check, r=compiler-errors

Remove let-chain close brace check.

#98633 added some checks to forbid let-expressions that aren't in a let chain. This check looks at the preceding token to determine if it is a valid let-chain position. One of those tokens it checks is the close brace `}`. However, to my understanding, it is not possible for a let chain to be preceded by a close brace. This PR removes the check to avoid any confusion.

This is a followup to the discussion at https://github.com/rust-lang/rust/pull/98633#pullrequestreview-1030962803. It wasn't clear what issues the original PR ran into, but I have run the full set of CI tests and nothing failed.  I also can't conceive of a situation where this would be possible.  This doesn't reject any valid code, I'm just removing it to avoid confusion to anyone looking at this code in the future.

23 months agoAdd GUI tests for headings border and text color
Guillaume Gomez [Wed, 27 Jul 2022 13:36:43 +0000 (15:36 +0200)]
Add GUI tests for headings border and text color

23 months agoFix headings border
Guillaume Gomez [Wed, 27 Jul 2022 13:36:27 +0000 (15:36 +0200)]
Fix headings border

23 months agoFix invalid css property value
Guillaume Gomez [Wed, 27 Jul 2022 13:00:43 +0000 (15:00 +0200)]
Fix invalid css property value

23 months agoAuto merge of #99802 - JohnTitor:rollup-uaklql1, r=JohnTitor
bors [Wed, 27 Jul 2022 12:32:54 +0000 (12:32 +0000)]
Auto merge of #99802 - JohnTitor:rollup-uaklql1, r=JohnTitor

Rollup of 5 pull requests

Successful merges:

 - #99079 (Check that RPITs constrained by a recursive call in a closure are compatible)
 - #99704 (Add `Self: ~const Trait` to traits with `#[const_trait]`)
 - #99769 (Sync rustc_codegen_cranelift)
 - #99783 (rustdoc: remove Clean trait impls for more items)
 - #99789 (Refactor: use `pluralize!`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

23 months agolint: add bad opt access internal lint
David Wood [Mon, 25 Jul 2022 12:02:39 +0000 (13:02 +0100)]
lint: add bad opt access internal lint

Some command-line options accessible through `sess.opts` are best
accessed through wrapper functions on `Session`, `TyCtxt` or otherwise,
rather than through field access on the option struct in the `Session`.

Adds a new lint which triggers on those options that should be accessed
through a wrapper function so that this is prohibited. Options are
annotated with a new attribute `rustc_lint_opt_deny_field_access` which
can specify the error message (i.e. "use this other function instead")
to be emitted.

A simpler alternative would be to simply rename the options in the
option type so that it is clear they should not be used, however this
doesn't prevent uses, just discourages them. Another alternative would
be to make the option fields private, and adding accessor functions on
the option types, however the wrapper functions sometimes rely on
additional state from `Session` or `TyCtxt` which wouldn't be available
in an function on the option type, so the accessor would simply make the
field available and its use would be discouraged too.

Signed-off-by: David Wood <david.wood@huawei.com>
23 months agosession: disable internal lints for rustdoc
David Wood [Tue, 26 Jul 2022 10:42:27 +0000 (11:42 +0100)]
session: disable internal lints for rustdoc

If an internal lint uses `typeck_results` or similar queries then that
can result in rustdoc checking code that it shouldn't (e.g. from other
platforms) and emit compilation errors.

Signed-off-by: David Wood <david.wood@huawei.com>
23 months agoAdd some comments to the docs issue template to clarify
Yuki Okushi [Mon, 25 Jul 2022 13:50:16 +0000 (22:50 +0900)]
Add some comments to the docs issue template to clarify

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
23 months agoRollup merge of #99789 - TaKO8Ki:use-pluralize-macro, r=compiler-errors
Yuki Okushi [Wed, 27 Jul 2022 10:05:36 +0000 (19:05 +0900)]
Rollup merge of #99789 - TaKO8Ki:use-pluralize-macro, r=compiler-errors

Refactor: use `pluralize!`

Use `pluralize!` in more places

23 months agoRollup merge of #99783 - notriddle:notriddle/clean-trait-removal, r=GuillaumeGomez
Yuki Okushi [Wed, 27 Jul 2022 10:05:35 +0000 (19:05 +0900)]
Rollup merge of #99783 - notriddle:notriddle/clean-trait-removal, r=GuillaumeGomez

rustdoc: remove Clean trait impls for more items

Follow up to #99638 and #99672

23 months agoRollup merge of #99769 - bjorn3:sync_cg_clif-2022-07-26, r=bjorn3
Yuki Okushi [Wed, 27 Jul 2022 10:05:34 +0000 (19:05 +0900)]
Rollup merge of #99769 - bjorn3:sync_cg_clif-2022-07-26, r=bjorn3

Sync rustc_codegen_cranelift

I did a large refactoring of the intrinsics module to remove the intrinsic_match macro which is not very clear to other people. This also enables rustfmt to run on this code. While I already did a sync yesterday, I am going to do another sync again to avoid potential conflicts as those will likely be painful to resolve.

r? ``@ghost``

``@rustbot`` label +A-codegen +A-cranelift +T-compiler

23 months agoRollup merge of #99704 - fee1-dead-contrib:add_self_tilde_const_trait, r=oli-obk
Yuki Okushi [Wed, 27 Jul 2022 10:05:33 +0000 (19:05 +0900)]
Rollup merge of #99704 - fee1-dead-contrib:add_self_tilde_const_trait, r=oli-obk

Add `Self: ~const Trait` to traits with `#[const_trait]`

r? `@oli-obk`

23 months agoRollup merge of #99079 - compiler-errors:issue-99073, r=oli-obk
Yuki Okushi [Wed, 27 Jul 2022 10:05:32 +0000 (19:05 +0900)]
Rollup merge of #99079 - compiler-errors:issue-99073, r=oli-obk

Check that RPITs constrained by a recursive call in a closure are compatible

Fixes #99073

Adapts a similar visitor pattern to `find_opaque_ty_constraints` (that we use to check TAITs), but with some changes:
0. Only walk the "OnlyBody" children, instead of all items in the RPIT's defining scope
1. Only walk through the body's children if we found a constraining usage
2. Don't actually do any inference, just do a comparison and error if they're mismatched

----

r? `@oli-obk` -- you know all this impl-trait stuff best... is this the right approach? I can explain the underlying issue better if you'd like, in case that might reveal a better solution. Not sure if it's possible to gather up the closure's defining usages of the RPIT while borrowck'ing the outer function, that might be a better place to put this check...

23 months agolint: add comment about diag lints in group
David Wood [Tue, 26 Jul 2022 10:46:01 +0000 (11:46 +0100)]
lint: add comment about diag lints in group

Add a brief comment explaining why the diagnostic migration lints aren't
included in the `rustc::internal` diagnostic group.

Signed-off-by: David Wood <david.wood@huawei.com>
23 months agoAuto merge of #98748 - saethlin:optimize-bufreader, r=Mark-Simulacrum
bors [Wed, 27 Jul 2022 09:49:06 +0000 (09:49 +0000)]
Auto merge of #98748 - saethlin:optimize-bufreader, r=Mark-Simulacrum

Remove some redundant checks from BufReader

The implementation of BufReader contains a lot of redundant checks. While any one of these checks is not particularly expensive to execute, especially when taken together they dramatically inhibit LLVM's ability to make subsequent optimizations by confusing data flow increasing the code size of anything that uses BufReader.

In particular, these changes have a ~2x increase on the benchmark that this adds a `black_box` to. I'm adding that `black_box` here just in case LLVM gets clever enough to remove the reads entirely. Right now it can't, but these optimizations are really setting it up to do so.

We get this optimization by factoring all the actual buffer management and bounds-checking logic into a new module inside `bufreader` with a new `Buffer` type. This makes it much easier to ensure that we have correctly encapsulated the management of the region of the buffer that we have read bytes into, and it lets us provide a new faster way to do small reads. `Buffer::consume_with` lets a caller do a read from the buffer with a single bounds check, instead of the double-check that's required to use `buffer` + `consume`.

Unfortunately I'm not aware of a lot of open-source usage of `BufReader` in perf-critical environments. Some time ago I tweaked this code because I saw `BufReader` in a profile at work, and I contributed some benchmarks to the `bincode` crate which exercise `BufReader::buffer`. These changes appear to help those benchmarks at little, but all these sorts of benchmarks are kind of fragile so I'm wary of quoting anything specific.

23 months agoAuto merge of #99778 - ehuss:update-cargo, r=ehuss
bors [Wed, 27 Jul 2022 06:59:51 +0000 (06:59 +0000)]
Auto merge of #99778 - ehuss:update-cargo, r=ehuss

Update cargo

5 commits in d8d30a75376f78bb0fabe3d28ee9d87aa8035309..85b500ccad8cd0b63995fd94a03ddd4b83f7905b
2022-07-19 13:59:17 +0000 to 2022-07-24 21:10:46 +0000
- Make the empty rustc-wrapper test more explicit. (rust-lang/cargo#10899)
- expand RUSTC_WRAPPER docs (rust-lang/cargo#10896)
- Stabilize Workspace Inheritance (rust-lang/cargo#10859)
- Fix typo in unstable docs: s/PROGJCT/PROJECT/ (rust-lang/cargo#10890)
- refactor(source): Open query API for adding more types of queries (rust-lang/cargo#10883)

23 months agoAuto merge of #99792 - JohnTitor:rollup-20i7ewx, r=JohnTitor
bors [Wed, 27 Jul 2022 04:18:49 +0000 (04:18 +0000)]
Auto merge of #99792 - JohnTitor:rollup-20i7ewx, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #98583 (Stabilize Windows `FileTypeExt` with `is_symlink_dir` and `is_symlink_file`)
 - #99698 (Prefer visibility map parents that are not `doc(hidden)` first)
 - #99700 (Add a clickable link to the layout section)
 - #99712 (passes: port more of `check_attr` module)
 - #99759 (Remove dead code from cg_llvm)
 - #99765 (Don't build std for *-uefi targets)
 - #99771 (Update pulldown-cmark version to 0.9.2 (fixes url encoding for some chars))
 - #99775 (rustdoc: do not allocate String when writing path full name)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

23 months agoRollup merge of #99775 - notriddle:notriddle/as-str, r=camelid
Yuki Okushi [Wed, 27 Jul 2022 02:52:59 +0000 (11:52 +0900)]
Rollup merge of #99775 - notriddle:notriddle/as-str, r=camelid

rustdoc: do not allocate String when writing path full name

No idea if this makes any perf difference, but it just seems like premature pessimisation to use String when str will do.

23 months agoRollup merge of #99771 - GuillaumeGomez:update-pulldown-cmark, r=Urgau
Yuki Okushi [Wed, 27 Jul 2022 02:52:58 +0000 (11:52 +0900)]
Rollup merge of #99771 - GuillaumeGomez:update-pulldown-cmark, r=Urgau

Update pulldown-cmark version to 0.9.2 (fixes url encoding for some chars)

Fixes https://github.com/rust-lang/rust/issues/97125.

r? ``@Dylan-DPC``

23 months agoRollup merge of #99765 - nicholasbishop:bishop-disable-uefi-std-build, r=jyn514
Yuki Okushi [Wed, 27 Jul 2022 02:52:57 +0000 (11:52 +0900)]
Rollup merge of #99765 - nicholasbishop:bishop-disable-uefi-std-build, r=jyn514

Don't build std for *-uefi targets

https://github.com/rust-lang/rust/issues/97322

23 months agoRollup merge of #99759 - bjorn3:remove_llvm_dead_code, r=nikic
Yuki Okushi [Wed, 27 Jul 2022 02:52:56 +0000 (11:52 +0900)]
Rollup merge of #99759 - bjorn3:remove_llvm_dead_code, r=nikic

Remove dead code from cg_llvm

Found while working on https://github.com/rust-lang/rust/pull/97485

23 months agoRollup merge of #99712 - davidtwco:translation-migrate-passes-2, r=compiler-errors
Yuki Okushi [Wed, 27 Jul 2022 02:52:55 +0000 (11:52 +0900)]
Rollup merge of #99712 - davidtwco:translation-migrate-passes-2, r=compiler-errors

passes: port more of `check_attr` module

Continues from #99213.

Port more diagnostics in `rustc_passes::check_attr` to using the diagnostic derive and translation machinery.

r? `@compiler-errors`

23 months agoRollup merge of #99700 - est31:rustdoc_layout_heading, r=GuillaumeGomez
Yuki Okushi [Wed, 27 Jul 2022 02:52:54 +0000 (11:52 +0900)]
Rollup merge of #99700 - est31:rustdoc_layout_heading, r=GuillaumeGomez

Add a clickable link to the layout section

The layout section (activated by `--show-type-layout`) is currently not linkable to (outside of chrome's link to text feature). This PR makes it linkable via `#layout`.

23 months agoRollup merge of #99698 - compiler-errors:no-doc-hidden, r=cjgillot
Yuki Okushi [Wed, 27 Jul 2022 02:52:53 +0000 (11:52 +0900)]
Rollup merge of #99698 - compiler-errors:no-doc-hidden, r=cjgillot

Prefer visibility map parents that are not `doc(hidden)` first

Far simpler approach to #98876.

This only fixes the case where the parent is `doc(hidden)`, not where the child is `doc(hidden)` since I don't know how to get the attrs on the import statement given a `ModChild`... I'll try to follow up with that, but this is a good first step.

23 months agoRollup merge of #98583 - joshtriplett:stabilize-windows-symlink-types, r=thomcc
Yuki Okushi [Wed, 27 Jul 2022 02:52:52 +0000 (11:52 +0900)]
Rollup merge of #98583 - joshtriplett:stabilize-windows-symlink-types, r=thomcc

Stabilize Windows `FileTypeExt` with `is_symlink_dir` and `is_symlink_file`

These calls allow detecting whether a symlink is a file or a directory,
a distinction Windows maintains, and one important to software that
wants to do further operations on the symlink (e.g. removing it).

23 months agoClarify safety comments
Ben Kimock [Wed, 27 Jul 2022 00:47:53 +0000 (20:47 -0400)]
Clarify safety comments

23 months agoAuto merge of #98553 - the8472:next_chunk_opt, r=Mark-Simulacrum
bors [Wed, 27 Jul 2022 01:12:30 +0000 (01:12 +0000)]
Auto merge of #98553 - the8472:next_chunk_opt, r=Mark-Simulacrum

Optimized vec::IntoIter::next_chunk impl

```
x86_64v1, default
test vec::bench_next_chunk                               ... bench:         696 ns/iter (+/- 22)
x86_64v1, pr
test vec::bench_next_chunk                               ... bench:         309 ns/iter (+/- 4)

znver2, default
test vec::bench_next_chunk                               ... bench:      17,272 ns/iter (+/- 117)
znver2, pr
test vec::bench_next_chunk                               ... bench:         211 ns/iter (+/- 3)
```

On znver2 the default impl seems to be slow due to different inlining decisions. It goes through `core::array::iter_next_chunk`
which has a deep call tree.

23 months agouse `pluralize!`
Takayuki Maeda [Wed, 27 Jul 2022 01:09:06 +0000 (10:09 +0900)]
use `pluralize!`

23 months agoAdd Buffer::consume_with to enable direct buffer access with one check
Ben Kimock [Wed, 27 Jul 2022 00:03:14 +0000 (20:03 -0400)]
Add Buffer::consume_with to enable direct buffer access with one check

23 months agoExplain how *mut [T] helps, and how we rely on the check in split_at_mut
Ben Kimock [Tue, 26 Jul 2022 22:37:00 +0000 (18:37 -0400)]
Explain how *mut [T] helps, and how we rely on the check in split_at_mut

23 months agorustdoc: remove Clean trait impl for ty::PolyTraitPredicate
Michael Howell [Tue, 26 Jul 2022 22:32:32 +0000 (15:32 -0700)]
rustdoc: remove Clean trait impl for ty::PolyTraitPredicate

23 months agorustdoc: remove Clean trait impls for ty::OutlivesPredicate
Michael Howell [Tue, 26 Jul 2022 22:28:20 +0000 (15:28 -0700)]
rustdoc: remove Clean trait impls for ty::OutlivesPredicate

23 months agorustdoc: remove Clean trait impl for ProjectionPredicate
Michael Howell [Tue, 26 Jul 2022 22:16:51 +0000 (15:16 -0700)]
rustdoc: remove Clean trait impl for ProjectionPredicate

23 months agorustdoc: remove Clean trait impl for ProjectionTy
Michael Howell [Tue, 26 Jul 2022 22:10:39 +0000 (15:10 -0700)]
rustdoc: remove Clean trait impl for ProjectionTy

23 months agoUpdate cargo
Eric Huss [Tue, 26 Jul 2022 19:48:39 +0000 (12:48 -0700)]
Update cargo

23 months agoadd test for vec::IntoIter::next_chunk() impl
The 8472 [Tue, 26 Jul 2022 19:28:14 +0000 (21:28 +0200)]
add test for vec::IntoIter::next_chunk() impl

an adaption of the default impl's doctest

23 months agoAuto merge of #99574 - durin42:allocator-patch-redux, r=nikic
bors [Tue, 26 Jul 2022 19:35:57 +0000 (19:35 +0000)]
Auto merge of #99574 - durin42:allocator-patch-redux, r=nikic

codegen: use new {re,de,}allocator annotations in llvm

This obviates the patch that teaches LLVM internals about
_rust_{re,de}alloc functions by putting annotations directly in the IR
for the optimizer.

The sole test change is required to anchor FileCheck to the body of the
`box_uninitialized` method, so it doesn't see the `allocalign` on
`__rust_alloc` and get mad about the string `alloca` showing up. Since I
was there anyway, I added some checks on the attributes to prove the
right attributes got set.

r? `@nikic`

23 months agorustdoc: do not allocate String when writing path full name
Michael Howell [Tue, 26 Jul 2022 19:23:59 +0000 (12:23 -0700)]
rustdoc: do not allocate String when writing path full name

No idea if this makes any perf difference, but it just seems like premature
pessimisation to use String when str will do.

23 months agoUpdate pulldown-cmark version
Guillaume Gomez [Tue, 26 Jul 2022 18:36:20 +0000 (20:36 +0200)]
Update pulldown-cmark version

23 months agoOptimized vec::IntoIter::next_chunk impl
The 8472 [Sun, 26 Jun 2022 20:53:25 +0000 (22:53 +0200)]
Optimized vec::IntoIter::next_chunk impl

```
test vec::bench_next_chunk                               ... bench:         696 ns/iter (+/- 22)
x86_64v1, pr
test vec::bench_next_chunk                               ... bench:         309 ns/iter (+/- 4)

znver2, default
test vec::bench_next_chunk                               ... bench:      17,272 ns/iter (+/- 117)
znver2, pr
test vec::bench_next_chunk                               ... bench:         211 ns/iter (+/- 3)
```

The znver2 default impl seems to be slow due to inlining decisions. It goes through `core::array::iter_next_chunk`
which has a deeper call tree.

23 months agoPacify tidy.
Camille GILLOT [Sun, 19 Jun 2022 14:35:16 +0000 (16:35 +0200)]
Pacify tidy.

23 months agoClippy fallout.
Camille GILLOT [Mon, 13 Jun 2022 09:53:31 +0000 (11:53 +0200)]
Clippy fallout.

23 months agoStop creating anonymous late lifetimes.
Camille GILLOT [Tue, 24 May 2022 06:23:24 +0000 (08:23 +0200)]
Stop creating anonymous late lifetimes.

23 months agoRemove resolve_elided_lifetimes.
Camille GILLOT [Mon, 23 May 2022 15:03:14 +0000 (17:03 +0200)]
Remove resolve_elided_lifetimes.

23 months agoStop resolving lifetime elision on HIR.
Camille GILLOT [Mon, 23 May 2022 14:27:52 +0000 (16:27 +0200)]
Stop resolving lifetime elision on HIR.

23 months agoMove fn parameter ribs outwards.
Camille GILLOT [Sun, 22 May 2022 21:31:39 +0000 (23:31 +0200)]
Move fn parameter ribs outwards.

23 months agoCheck that we do not ICE when anonymous lifetimes appear in AnonConst.
Camille GILLOT [Wed, 6 Jul 2022 16:27:43 +0000 (18:27 +0200)]
Check that we do not ICE when anonymous lifetimes appear in AnonConst.

Fixes #98932.

23 months agoReplace LifetimeRes::Anonymous by LifetimeRes::Infer.
Camille GILLOT [Mon, 13 Jun 2022 06:22:06 +0000 (08:22 +0200)]
Replace LifetimeRes::Anonymous by LifetimeRes::Infer.

23 months agoRemove the distinction between LifetimeName::Implicit and LifetimeName::Underscore.
Camille GILLOT [Sun, 22 May 2022 08:22:20 +0000 (10:22 +0200)]
Remove the distinction between LifetimeName::Implicit and LifetimeName::Underscore.

23 months agoDo not produce extra lifetime parameters when not needed.
Camille GILLOT [Mon, 13 Jun 2022 05:36:45 +0000 (07:36 +0200)]
Do not produce extra lifetime parameters when not needed.

23 months agoMerge commit 'd3a2366ee877075c59b38bd8ced55f224fc7ef51' into sync_cg_clif-2022-07-26
bjorn3 [Tue, 26 Jul 2022 16:53:46 +0000 (18:53 +0200)]
Merge commit 'd3a2366ee877075c59b38bd8ced55f224fc7ef51' into sync_cg_clif-2022-07-26

23 months agoAuto merge of #99764 - matthiaskrgr:rollup-fawyb3m, r=matthiaskrgr
bors [Tue, 26 Jul 2022 16:47:36 +0000 (16:47 +0000)]
Auto merge of #99764 - matthiaskrgr:rollup-fawyb3m, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #99235 (rustdoc: Add support for `#[rustc_must_implement_one_of]`)
 - #99716 (remove useless mut from examples)
 - #99724 (Fix some broken link fragments.)
 - #99729 (Remove unused tuple fields)
 - #99757 (Make `transmute_copy` docs read better)
 - #99758 (remove useless `#[allow]` in a test)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

23 months agoImplement some more llvm float compare intrinsic options
bjorn3 [Tue, 26 Jul 2022 16:27:14 +0000 (16:27 +0000)]
Implement some more llvm float compare intrinsic options

23 months agoOutline a bug! invocation
bjorn3 [Tue, 26 Jul 2022 16:26:35 +0000 (16:26 +0000)]
Outline a bug! invocation

This reduces the amount of llvm ir lines for intrinsic related code from
23801 to 20478.

23 months agoFully remove the intrinsic_match macro
bjorn3 [Tue, 26 Jul 2022 15:14:22 +0000 (15:14 +0000)]
Fully remove the intrinsic_match macro

23 months agoDon't build std for *-uefi targets
Nicholas Bishop [Tue, 26 Jul 2022 15:50:54 +0000 (11:50 -0400)]
Don't build std for *-uefi targets

https://github.com/rust-lang/rust/issues/97322

23 months agoStart moving away from the intrinsic_match macro
bjorn3 [Tue, 26 Jul 2022 14:45:00 +0000 (14:45 +0000)]
Start moving away from the intrinsic_match macro

It isn't clear most people other than me and it blocks formatting by
rustfmt.

23 months agoRollup merge of #99758 - WaffleLapkin:remove_useless_allow, r=Dylan-DPC
Matthias Krüger [Tue, 26 Jul 2022 14:57:53 +0000 (16:57 +0200)]
Rollup merge of #99758 - WaffleLapkin:remove_useless_allow, r=Dylan-DPC

remove useless `#[allow]` in a test

The mentioned issue, https://github.com/rust-lang/rust/issues/54586 was fixed 4 years ago :)

23 months agoRollup merge of #99757 - asquared31415:patch-1, r=Dylan-DPC
Matthias Krüger [Tue, 26 Jul 2022 14:57:52 +0000 (16:57 +0200)]
Rollup merge of #99757 - asquared31415:patch-1, r=Dylan-DPC

Make `transmute_copy` docs read better

23 months agoRollup merge of #99729 - cjgillot:rm-unused-tuple, r=michaelwoerister
Matthias Krüger [Tue, 26 Jul 2022 14:57:50 +0000 (16:57 +0200)]
Rollup merge of #99729 - cjgillot:rm-unused-tuple, r=michaelwoerister

Remove unused tuple fields

Found by https://github.com/rust-lang/rust/pull/95977

23 months agoICE on RawPtrComparison check
Deadbeef [Tue, 26 Jul 2022 14:28:09 +0000 (14:28 +0000)]
ICE on RawPtrComparison check

23 months agoRollup merge of #99724 - ehuss:fix-broken-links-fragment, r=Dylan-DPC
Matthias Krüger [Tue, 26 Jul 2022 14:57:49 +0000 (16:57 +0200)]
Rollup merge of #99724 - ehuss:fix-broken-links-fragment, r=Dylan-DPC

Fix some broken link fragments.

An exception for link fragments starting with `-` was added in #49590. However, it is not clear what issues were encountered at the time. Perhaps those were fixed in the meantime.

This removes the exception, and fixes a couple of broken links that were skipped due to it.

23 months agoRollup merge of #99716 - sourcelliu:iomut, r=Mark-Simulacrum
Matthias Krüger [Tue, 26 Jul 2022 14:57:48 +0000 (16:57 +0200)]
Rollup merge of #99716 - sourcelliu:iomut, r=Mark-Simulacrum

remove useless mut from examples

remove useless mut from examples

23 months agoRollup merge of #99235 - WaffleLapkin:rustdoc_implement_support_for_must_implement...
Matthias Krüger [Tue, 26 Jul 2022 14:57:46 +0000 (16:57 +0200)]
Rollup merge of #99235 - WaffleLapkin:rustdoc_implement_support_for_must_implement, r=GuillaumeGomez

rustdoc: Add support for `#[rustc_must_implement_one_of]`

This PR adds support for `#[rustc_must_implement_one_of]` attribute added in #92164. There is a desire to eventually use this attribute of `Read`, so making it show up in docs is a good thing.

I "stole" the styling from cfg notes, not sure what would be a proper styling. Currently it looks like this:
![2022-07-14_15-00](https://user-images.githubusercontent.com/38225716/178968170-913c1dd5-8875-4a95-9848-b075a0bb8998.png)

<details><summary>Code to reproduce</summary>
<p>

```rust
#![feature(rustc_attrs)]

#[rustc_must_implement_one_of(a, b)]
pub trait Trait {
    fn req();
    fn a(){ Self::b() }
    fn b(){ Self::a() }
}
```

</p>
</details>

23 months agoFix diagnostics for unfulfilled obligations
Deadbeef [Tue, 26 Jul 2022 13:57:19 +0000 (13:57 +0000)]
Fix diagnostics for unfulfilled obligations

23 months agobless tests, remove nonexistent E0395
Deadbeef [Mon, 25 Jul 2022 08:17:00 +0000 (08:17 +0000)]
bless tests, remove nonexistent E0395

23 months agoAdd `Self: ~const Trait` to traits with `#[const_trait]`
Deadbeef [Mon, 25 Jul 2022 08:16:34 +0000 (08:16 +0000)]
Add `Self: ~const Trait` to traits with `#[const_trait]`

23 months agocodegen: use new {re,de,}allocator annotations in llvm
Augie Fackler [Mon, 21 Mar 2022 19:30:54 +0000 (15:30 -0400)]
codegen: use new {re,de,}allocator annotations in llvm

This obviates the patch that teaches LLVM internals about
_rust_{re,de}alloc functions by putting annotations directly in the IR
for the optimizer.

The sole test change is required to anchor FileCheck to the body of the
`box_uninitialized` method, so it doesn't see the `allocalign` on
`__rust_alloc` and get mad about the string `alloca` showing up. Since I
was there anyway, I added some checks on the attributes to prove the
right attributes got set.

While we're here, we also emit allocator attributes on
__rust_alloc_zeroed. This should allow LLVM to perform more
optimizations for zeroed blocks, and probably fixes #90032. [This
comment](https://github.com/rust-lang/rust/issues/24194#issuecomment-308791157)
mentions "weird UB-like behaviour with bitvec iterators in
rustc_data_structures" so we may need to back this change out if things
go wrong.

The new test cases require LLVM 15, so we copy them into LLVM
14-supporting versions, which we can delete when we drop LLVM 14.

23 months agoAuto merge of #99680 - workingjubilee:revert-revert-icf, r=Mark-Simulacrum
bors [Tue, 26 Jul 2022 13:31:31 +0000 (13:31 +0000)]
Auto merge of #99680 - workingjubilee:revert-revert-icf, r=Mark-Simulacrum

Revert "Revert "Use ICF (identical code folding) for building rustc""

This reverts commit rust-lang/rust@45575d23f316af7476ccd0a895234ac59c47a6be,
thereby enabling identical code folding again.

Closes #99440 (again).

23 months agoRemove dead code from cg_llvm
bjorn3 [Tue, 26 Jul 2022 11:29:18 +0000 (11:29 +0000)]
Remove dead code from cg_llvm

23 months agoSimplify test
est31 [Tue, 26 Jul 2022 10:45:16 +0000 (12:45 +0200)]
Simplify test

Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
23 months agoAuto merge of #99753 - Dylan-DPC:rollup-k046940, r=Dylan-DPC
bors [Tue, 26 Jul 2022 10:35:25 +0000 (10:35 +0000)]
Auto merge of #99753 - Dylan-DPC:rollup-k046940, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #99618 (handle consts with param/infer in `const_eval_resolve` better)
 - #99666 (Restore `Opaque` behavior to coherence check)
 - #99692 (interpret, ptr_offset_from: refactor and test too-far-apart check)
 - #99739 (Remove erroneous E0133 code from an error message.)
 - #99748 (Use full type name instead of just saying `impl Trait` in "captures lifetime" error)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

23 months agoremove useless `#[allow]` in a test
Maybe Waffle [Tue, 26 Jul 2022 10:27:01 +0000 (14:27 +0400)]
remove useless `#[allow]` in a test

23 months agoMake `transmute_copy` docs read better
asquared31415 [Tue, 26 Jul 2022 09:59:44 +0000 (05:59 -0400)]
Make `transmute_copy` docs read better

23 months agoRollup merge of #99748 - compiler-errors:better-impl-trait-printing, r=fee1-dead
Dylan DPC [Tue, 26 Jul 2022 08:57:00 +0000 (14:27 +0530)]
Rollup merge of #99748 - compiler-errors:better-impl-trait-printing, r=fee1-dead

Use full type name instead of just saying `impl Trait` in "captures lifetime" error

I think this is very useful, especially when there's >1 `impl Trait`, and it just means passing around a bit more info that we already have access to.

23 months agoRollup merge of #99739 - nnethercote:rm-E0133, r=Dylan-DPC
Dylan DPC [Tue, 26 Jul 2022 08:56:59 +0000 (14:26 +0530)]
Rollup merge of #99739 - nnethercote:rm-E0133, r=Dylan-DPC

Remove erroneous E0133 code from an error message.

This error message is about `derive` and `packed`, but E0133 is for
"Unsafe code was used outside of an unsafe function or block".

r? ``@estebank``

23 months agoRollup merge of #99692 - RalfJung:too-far, r=oli-obk
Dylan DPC [Tue, 26 Jul 2022 08:56:58 +0000 (14:26 +0530)]
Rollup merge of #99692 - RalfJung:too-far, r=oli-obk

interpret, ptr_offset_from: refactor and test too-far-apart check

We didn't have any tests for the "too far apart" message, and indeed that check mostly relied on the in-bounds check and was otherwise probably not entirely correct... so I rewrote that check, and it is before the in-bounds check so we can test it separately.

23 months agoRollup merge of #99666 - compiler-errors:issue-99663, r=lcnr
Dylan DPC [Tue, 26 Jul 2022 08:56:57 +0000 (14:26 +0530)]
Rollup merge of #99666 - compiler-errors:issue-99663, r=lcnr

Restore `Opaque` behavior to coherence check

Fixes #99663.

This broke in 84c3fcd2a0285c06a682c9b064640084e4c7271b. I'm not exactly certain that adding this behavior back is necessarily correct, but at least the UI test I provided may stimulate some thoughts.

I think delaying a bug here is certainly not correct in the case of opaques -- if we want to change coherence behavior for opaques, then we should at least be emitting a new error.

r? ``@lcnr``

23 months agoRollup merge of #99618 - compiler-errors:uhh-idk, r=lcnr
Dylan DPC [Tue, 26 Jul 2022 08:56:56 +0000 (14:26 +0530)]
Rollup merge of #99618 - compiler-errors:uhh-idk, r=lcnr

handle consts with param/infer in `const_eval_resolve` better

This PR addresses [this thread here](https://github.com/rust-lang/rust/pull/99449#discussion_r924141230). Was this the change you were looking for ``@lcnr?``

Interestingly, one test has begun to pass. Was that expected?

r? ``@lcnr``

23 months agoCheck that RPITs constrained by a recursive call in a closure are compatible
Michael Goulet [Sat, 9 Jul 2022 07:11:03 +0000 (07:11 +0000)]
Check that RPITs constrained by a recursive call in a closure are compatible

23 months agoRevert "Do not allow typeck children items to constrain outer RPITs"
Michael Goulet [Tue, 26 Jul 2022 07:37:54 +0000 (07:37 +0000)]
Revert "Do not allow typeck children items to constrain outer RPITs"

This reverts commit e8d9f38141a0ee8ac5484783e1fb5c218f9d2eee.

23 months agoRevert "use opaque_ty_origin_unchecked instead of destructuring HIR"
Michael Goulet [Tue, 26 Jul 2022 07:36:23 +0000 (07:36 +0000)]
Revert "use opaque_ty_origin_unchecked instead of destructuring HIR"

This reverts commit 5a4601fea56502e4f50df046c4205e678397599b.

23 months agoAuto merge of #99677 - pietroalbini:pa-fix-97786-perf-regression, r=Mark-Simulacrum
bors [Tue, 26 Jul 2022 07:29:29 +0000 (07:29 +0000)]
Auto merge of #99677 - pietroalbini:pa-fix-97786-perf-regression, r=Mark-Simulacrum

Remove new allocations from `imported_source_files`

https://github.com/rust-lang/rust/pull/97786 introduced a [large performance regression](https://github.com/rust-lang/rust/pull/97786#issuecomment-1176552836). After some local investigation it turns out the allocations performed by my change were the cause of the perf regression. This PR refactors my change to remove those allocations.

23 months agoAllow try_to_raw_bytes on u8 array
Michael Goulet [Tue, 26 Jul 2022 07:05:31 +0000 (07:05 +0000)]
Allow try_to_raw_bytes on u8 array

23 months agoAddress nits, move substs replacement to separate function
Michael Goulet [Tue, 26 Jul 2022 00:43:29 +0000 (00:43 +0000)]
Address nits, move substs replacement to separate function

23 months agoUse real opaque type instead of just saying impl Trait
Michael Goulet [Tue, 26 Jul 2022 06:19:58 +0000 (06:19 +0000)]
Use real opaque type instead of just saying impl Trait

23 months agoAuto merge of #99745 - JohnTitor:rollup-lvrie64, r=JohnTitor
bors [Tue, 26 Jul 2022 04:28:41 +0000 (04:28 +0000)]
Auto merge of #99745 - JohnTitor:rollup-lvrie64, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #98211 (Implement `fs::get_path` for FreeBSD.)
 - #99353 (Slightly improve mismatched GAT where clause error)
 - #99593 (Suggest removing the tuple struct field for the unwrapped value)
 - #99615 (Remove some explicit `self.infcx` for `FnCtxt`, which already derefs into `InferCtxt`)
 - #99711 (Remove reachable coverage without counters)
 - #99718 (Avoid `&str`/`Symbol` to `String` conversions)
 - #99720 (Sync rustc_codegen_cranelift)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

23 months agoRollup merge of #99720 - bjorn3:sync_cg_clif-2022-07-25, r=bjorn3
Yuki Okushi [Tue, 26 Jul 2022 04:12:24 +0000 (13:12 +0900)]
Rollup merge of #99720 - bjorn3:sync_cg_clif-2022-07-25, r=bjorn3

Sync rustc_codegen_cranelift

This time most of the changes are bugfixes. No exciting new features to report. Thanks `@matthiaskrgr` for reporting a bunch of crashes!

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler

23 months agoRollup merge of #99718 - TaKO8Ki:avoid-&str-symbol-to-string-conversions, r=michaelwo...
Yuki Okushi [Tue, 26 Jul 2022 04:12:23 +0000 (13:12 +0900)]
Rollup merge of #99718 - TaKO8Ki:avoid-&str-symbol-to-string-conversions, r=michaelwoerister

Avoid `&str`/`Symbol` to `String` conversions

follow-up to #99342 and #98668

23 months agoRollup merge of #99711 - tmiasko:coverage, r=wesleywiser
Yuki Okushi [Tue, 26 Jul 2022 04:12:22 +0000 (13:12 +0900)]
Rollup merge of #99711 - tmiasko:coverage, r=wesleywiser

Remove reachable coverage without counters

Remove reachable coverage without counters to maintain invariant that
either there is no coverage at all or there is a live coverage counter
left that provides the function source hash.

The motivating example would be a following closure:

```rust
    let f = |x: bool| {
        debug_assert!(x);
    };
```

Which, with span changes from #93967, with disabled debug assertions,
after the final CFG simplifications but before removal of dead blocks,
gives rise to MIR:

```rust
fn main::{closure#0}(_1: &[closure@a.rs:2:13: 2:22], _2: bool) -> () {
    debug x => _2;
    let mut _0: ();

    bb0: {
        Coverage::Expression(4294967295) = 1 - 2;
        return;
    }

    ...
}
```

Which also makes the initial instrumentation quite suspect, although
this pull request doesn't attempt to address that aspect directly.

Fixes #98833.

r? ``@wesleywiser`` ``@richkadel``