Commit Graph

197553 Commits

Author SHA1 Message Date
Maybe Waffle
3ba393465f Make some docs nicer wrt pointer offsets 2022-08-21 02:22:20 +04:00
bors
6c943bad02 Auto merge of #99541 - timvermeulen:flatten_cleanup, r=the8472
Refactor iteration logic in the `Flatten` and `FlatMap` iterators

The `Flatten` and `FlatMap` iterators both delegate to `FlattenCompat`:
```rust
struct FlattenCompat<I, U> {
    iter: Fuse<I>,
    frontiter: Option<U>,
    backiter: Option<U>,
}
```
Every individual iterator method that `FlattenCompat` implements needs to carefully manage this state, checking whether the `frontiter` and `backiter` are present, and storing the current iterator appropriately if iteration is aborted. This has led to methods such as `next`, `advance_by`, and `try_fold` all having similar code for managing the iterator's state.

I have extracted this common logic of iterating the inner iterators with the option to exit early into a `iter_try_fold` method:
```rust
impl<I, U> FlattenCompat<I, U>
where
    I: Iterator<Item: IntoIterator<IntoIter = U>>,
{
    fn iter_try_fold<Acc, Fold, R>(&mut self, acc: Acc, fold: Fold) -> R
    where
        Fold: FnMut(Acc, &mut U) -> R,
        R: Try<Output = Acc>,
    { ... }
}
```
It passes each of the inner iterators to the given function as long as it keep succeeding. It takes care of managing `FlattenCompat`'s state, so that the actual `Iterator` methods don't need to. The resulting code that makes use of this abstraction is much more straightforward:
```rust
fn next(&mut self) -> Option<U::Item> {
    #[inline]
    fn next<U: Iterator>((): (), iter: &mut U) -> ControlFlow<U::Item> {
        match iter.next() {
            None => ControlFlow::CONTINUE,
            Some(x) => ControlFlow::Break(x),
        }
    }

    self.iter_try_fold((), next).break_value()
}
```
Note that despite being implemented in terms of `iter_try_fold`, `next` is still able to benefit from `U`'s `next` method. It therefore does not take the performance hit that implementing `next` directly in terms of `Self::try_fold` causes (in some benchmarks).

This PR also adds `iter_try_rfold` which captures the shared logic of `try_rfold` and `advance_back_by`, as well as `iter_fold` and `iter_rfold` for folding without early exits (used by `fold`, `rfold`, `count`, and `last`).

Benchmark results:
```
                                             before                after
bench_flat_map_sum                       423,255 ns/iter      414,338 ns/iter
bench_flat_map_ref_sum                 1,942,139 ns/iter    2,216,643 ns/iter
bench_flat_map_chain_sum               1,616,840 ns/iter    1,246,445 ns/iter
bench_flat_map_chain_ref_sum           4,348,110 ns/iter    3,574,775 ns/iter
bench_flat_map_chain_option_sum          780,037 ns/iter      780,679 ns/iter
bench_flat_map_chain_option_ref_sum    2,056,458 ns/iter      834,932 ns/iter
```

I added the last two benchmarks specifically to demonstrate an extreme case where `FlatMap::next` can benefit from custom internal iteration of the outer iterator, so take it with a grain of salt. We should probably do a perf run to see if the changes to `next` are worth it in practice.
2022-08-19 02:34:30 +00:00
bors
71ecf5d359 Auto merge of #98851 - klensy:encode_symbols, r=cjgillot
rustc_metadata: dedupe strings to prevent multiple copies in rmeta/query cache blow file size

r? `@cjgillot`

Encodes strings in rmeta/query cache so duplicated ones will be encoded as offsets to first strings, reducing file size.
2022-08-18 23:53:22 +00:00
bors
0b79f758c9 Auto merge of #98807 - cbeuw:derived-obligation, r=compiler-errors
Reword "Required because of the requirements on the impl of ..."

Rephrases the awkward "Required because of the requirements on the impl of `{trait}` for `{type}`" to "required for `{type}` to implement `{trait}`"
2022-08-18 21:12:05 +00:00
Andy Wang
84a199369b
Reword "Required because of the requirements on the impl of ..." 2022-08-18 21:08:08 +01:00
bors
8064a49508 Auto merge of #99860 - oli-obk:revert_97346, r=pnkfelix
Revert "Rollup merge of #97346 - JohnTitor:remove-back-compat-hacks, …

…r=oli-obk"

This reverts commit c703d11dcc, reversing
changes made to 64eb9ab869.

it didn't apply cleanly, so now it works the same for RPIT and for TAIT instead of just working for RPIT, but we should keep those in sync anyway. It also exposed a TAIT bug (see the feature gated test that now ICEs).

r? `@pnkfelix`

fixes #99536
2022-08-18 15:41:30 +00:00
bors
bb99e6fdd9 Auto merge of #100682 - RalfJung:miri, r=RalfJung
update Miri

Fixes https://github.com/rust-lang/rust/issues/100614
r? `@ghost`
2022-08-18 12:56:21 +00:00
bors
361c599fee Auto merge of #98655 - nnethercote:dont-derive-PartialEq-ne, r=dtolnay
Don't derive `PartialEq::ne`.

Currently we skip deriving `PartialEq::ne` for C-like (fieldless) enums
and empty structs, thus reyling on the default `ne`. This behaviour is
unnecessarily conservative, because the `PartialEq` docs say this:

> Implementations must ensure that eq and ne are consistent with each other:
>
> `a != b` if and only if `!(a == b)` (ensured by the default
> implementation).

This means that the default implementation (`!(a == b)`) is always good
enough. So this commit changes things such that `ne` is never derived.

The motivation for this change is that not deriving `ne` reduces compile
times and binary sizes.

Observable behaviour may change if a user has defined a type `A` with an
inconsistent `PartialEq` and then defines a type `B` that contains an
`A` and also derives `PartialEq`. Such code is already buggy and
preserving bug-for-bug compatibility isn't necessary.

Two side-effects of the change:
- There is only one error message produced for types where `PartialEq`
  cannot be derived, instead of two.
- For coverage reports, some warnings about generated `ne` methods not
  being executed have disappeared.

Both side-effects seem fine, and possibly preferable.
2022-08-18 10:11:11 +00:00
bors
f241c0c43d Auto merge of #100708 - matthiaskrgr:rollup-vl0olnj, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #97962 (Make must_not_suspend lint see through references when drop tracking is enabled)
 - #99966 (avoid assertion failures in try_to_scalar_int)
 - #100637 (Improving Fuchsia rustc support documentation)
 - #100643 (Point at a type parameter shadowing another type)
 - #100651 (Migrations for rustc_expand transcribe.rs)
 - #100669 (Attribute cleanups)
 - #100670 (Fix documentation of rustc_parse::parser::Parser::parse_stmt_without_recovery)
 - #100674 (Migrate lint reports in typeck::check_unused to LintDiagnostic)
 - #100688 (`ty::Error` does not match other types for region constraints)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-18 07:09:06 +00:00
Matthias Krüger
c7a4942588
Rollup merge of #100688 - compiler-errors:issue-100684, r=wesleywiser
`ty::Error` does not match other types for region constraints

Fixes #100684
2022-08-18 05:10:51 +02:00
Matthias Krüger
3de034d401
Rollup merge of #100674 - PragmaTwice:mig-typeck-unused-crate-diag, r=davidtwco
Migrate lint reports in typeck::check_unused to LintDiagnostic

In this PR, I migrate two lint reports in `typeck::check_unused` by `LintDiagnostic`, all of which is about extern crates.

```@rustbot``` label +A-translation
r? rust-lang/diagnostics
2022-08-18 05:10:50 +02:00
Matthias Krüger
5548e585c1
Rollup merge of #100670 - Xiretza:parser-stmt-force-collect-docs, r=davidtwco
Fix documentation of rustc_parse::parser::Parser::parse_stmt_without_recovery

Something seems to have gotten out of sync during the creation of #81177, where both the argument and comment were introduced.
2022-08-18 05:10:49 +02:00
Matthias Krüger
3e057d1512
Rollup merge of #100669 - nnethercote:attribute-cleanups, r=spastorino
Attribute cleanups

r? `@ghost`
2022-08-18 05:10:48 +02:00
Matthias Krüger
8b180ed3c0
Rollup merge of #100651 - nidnogg:diagnostics_migration_expand_transcribe, r=davidtwco
Migrations for rustc_expand transcribe.rs

This PR includes some migrations to the new diagnostics API for the `rustc_expand` module.
r? ```@davidtwco```
2022-08-18 05:10:47 +02:00
Matthias Krüger
b295639f14
Rollup merge of #100643 - TaKO8Ki:point-at-type-parameter-shadowing-another-type, r=estebank
Point at a type parameter shadowing another type

This patch fixes a part of #97459.
2022-08-18 05:10:46 +02:00
Matthias Krüger
795e55f1e1
Rollup merge of #100637 - andrewpollack:fuchsia-docs-adjustments, r=tmandry
Improving Fuchsia rustc support documentation

* Adjusting `package/meta/package` to fit current schema
* Adding repository server step
* Adjusting step to give default repository
* Adding "recreate" step for easier step following
2022-08-18 05:10:45 +02:00
Matthias Krüger
092f4600bb
Rollup merge of #99966 - RalfJung:try-dont-panic, r=lcnr
avoid assertion failures in try_to_scalar_int

Given that this is called `try_to_scalar_int`, we probably shouldn't `assert_int` here. Similarly `try_to_bits` also doesn't `assert!` that the size is correct.

Also add some `track_caller` for debugging, while we are at it.

r? ```@oli-obk```
2022-08-18 05:10:42 +02:00
Matthias Krüger
370bf1543d
Rollup merge of #97962 - eholk:drop-tracking-must-not-suspend, r=cjgillot
Make must_not_suspend lint see through references when drop tracking is enabled

See #97333.

With drop tracking enabled, sometimes values that were previously linted are now considered dropped and not linted. This change makes must_not_suspend traverse through references to still catch these values.

Unfortunately, this leads to duplicate warnings in some cases (e.g. [dedup.rs](9a74608543/src/test/ui/lint/must_not_suspend/dedup.rs (L4))), so we only use the new behavior when drop tracking is enabled.

cc ``@guswynn``
2022-08-18 05:10:41 +02:00
Michael Goulet
fc7fc0fae5 ty::Error does not match other types for region constraints 2022-08-17 17:23:52 +00:00
nidnogg
a468f13162 Hotfix for duplicated slug name on VarStillRepeating struct 2022-08-17 13:13:07 -03:00
bors
9c20b2a8cc Auto merge of #100677 - matthiaskrgr:rollup-au41ho1, r=matthiaskrgr
Rollup of 15 pull requests

Successful merges:

 - #99474 (Rustdoc json tests: New `@hasexact` test command)
 - #99972 (interpret: only consider 1-ZST when searching for receiver)
 - #100018 (Clean up `LitKind`)
 - #100379 (triagebot: add translation-related mention groups)
 - #100389 (Do not report cycle error when inferring return type for suggestion)
 - #100489 (`is_knowable` use `Result` instead of `Option`)
 - #100532 (unwind: don't build dependency when building for Miri)
 - #100608 (needless separation of impl blocks)
 - #100621 (Pass +atomics-32 feature for {arm,thumb}v4t-none-eabi)
 - #100646 (Migrate emoji identifier diagnostics to `SessionDiagnostic` in rustc_interface)
 - #100652 (Remove deferred sized checks (make them eager))
 - #100655 (Update books)
 - #100656 (Update cargo)
 - #100660 (Fixed a few documentation errors)
 - #100661 (Fixed a few documentation errors)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-17 14:49:05 +00:00
nidnogg
caab20c431 Moved structs to rustc_expand::errors, added several more migrations, fixed slug name 2022-08-17 11:20:37 -03:00
nidnogg
c6f9a9c410 Moved structs to rustc_expand::errors, added several more migrations, fixed slug name 2022-08-17 11:18:19 -03:00
PragmaTwice
9efe979511 remove #[primary_span] 2022-08-17 22:08:06 +08:00
Ralf Jung
2c9baf73f3 update Miri 2022-08-17 09:09:33 -04:00
PragmaTwice
b704843c44 fix test file 2022-08-17 21:05:21 +08:00
Twice
52418d661b
use suggestion_short in LintDiagnostic
Co-authored-by: David Wood <agile.lion3441@fuligin.ink>
2022-08-17 20:45:18 +08:00
Matthias Krüger
1199dbdcf5
Rollup merge of #100661 - PunkyMunky64:patch-1, r=thomcc
Fixed a few documentation errors

Quick pull request; IEEE-754, not IEEE-745. May save someone a quick second some time.
2022-08-17 12:33:02 +02:00
Matthias Krüger
bd8aa6dffe
Rollup merge of #100660 - PunkyMunky64:patch-2, r=thomcc
Fixed a few documentation errors

Quick pull request; IEEE-754, not IEEE-745. May save someone a quick second some time.
2022-08-17 12:33:01 +02:00
Matthias Krüger
36d8d5565d
Rollup merge of #100656 - ehuss:update-cargo, r=ehuss
Update cargo

3 commits in efd4ca3dc0b89929dc8c5f5c023d25978d76cb61..9809f8ff33c2b998919fd0432c626f0f7323697a
2022-08-12 01:28:28 +0000 to 2022-08-16 22:10:06 +0000
- Improve error message for an array value in the manifest (rust-lang/cargo#10944)
- Fix file locking being not supported on Android raising an error (rust-lang/cargo#10975)
- Bump to 0.66.0, update changelog (rust-lang/cargo#10983)
2022-08-17 12:33:00 +02:00
Matthias Krüger
c0d9feac1e
Rollup merge of #100655 - ehuss:update-books, r=ehuss
Update books

## nomicon

2 commits in 8d1e4dccf71114ff56f328f671f2026d8e6b62a2..8e6aa3448515a0654e347b5e2510f1d4bc4d5a64
2022-07-18 18:12:35 -0400 to 2022-08-15 15:36:13 -0700
- Update the `repr(transparent)` section to reflect the current state (rust-lang/nomicon#376)
- [typo] typo on limits of lifetime chapter (rust-lang/nomicon#377)

## reference

5 commits in f3d3953bf3b158d596c96d55ce5366f9f3f972e9..e647eb102890e8927f488bea12672b079eff8d9d
2022-08-01 17:17:37 -0700 to 2022-08-16 11:35:27 -0700
- #[non_exhaustive] on variant blocks cross-crate as casts (rust-lang/reference#1249)
- Revert let chains reference docs (rust-lang/reference#1251)
- Update subtyping.md (rust-lang/reference#1240)
- a fix about .await (rust-lang/reference#1245)
- Be less specific about the representation of `+bundle` (rust-lang/reference#1246)

## book

2 commits in 36383b4da21dbd0a0781473bc8ad7ef0ed1b6751..42ca0ef484fcc8437a0682cee23abe4b7c407d52
2022-07-19 21:03:20 -0400 to 2022-08-12 21:52:02 -0400
- Missing period at end of sentence
- Fix grammar in ch06-02

## rust-by-example

8 commits in ee342dc91e1ba1bb1e1f1318f84bbe3bfac04798..03301f8ae55fa6f20f7ea152a517598e6db2cdb7
2022-07-27 11:06:36 -0300 to 2022-08-14 08:51:44 -0300
- Update print.md (rust-lang/rust-by-example#1597)
- in Meta, replace 'playpen' with 'playground' (rust-lang/rust-by-example#1596)
- Update doc comment to link to name field without compilation warning (rust-lang/rust-by-example#1595)
- add line numbers for playpen fixes rust-lang/rust-by-example#1593 (rust-lang/rust-by-example#1594)
- clarify that the map-reduce example relies on static data (rust-lang/rust-by-example#1592)
- Update flow_control.md (rust-lang/rust-by-example#1591)
- Remove duplicate line in the hello/print.md file (rust-lang/rust-by-example#1590)
- Make rust editable in chapter on defaults (rust-lang/rust-by-example#1589)

## rustc-dev-guide

15 commits in 04f3cf0bb2f5a6ee2bfc4b1a6a6cd8c11d1c5531..d3daa1f28e169087becbc5e2b49ac91ca0405a44
2022-07-31 07:46:57 +0200 to 2022-08-13 10:00:38 +0900
- Improve the "Diagnostic items" chapter (rust-lang/rustc-dev-guide#1427)
- date-check: crates-io
- fix/improve compiler-debugging
- Update src/compiler-debugging.md
- add gdb tips for symbol-mangling-version
- move references down to avoid clutter (rust-lang/rustc-dev-guide#1420)
- update date-check format on github issue (rust-lang/rustc-dev-guide#1416)
- Fix legend colors in dark mode
- Add color for downloaded nodes
- Add colors to diagram
- Add bootstrapping diagram
- date-check: rustc_codegen_ssa is still alive
- note is now too old to be relevant
- date-check: be more strict
- make date-check more lightweight (rust-lang/rustc-dev-guide#1394)

## edition-guide

3 commits in c55611dd6c58bdeb52423b5c52fd0f3c93615ba8..6038be9d37d7251c966b486154af621d1794d7af
2022-02-21 14:21:39 +0100 to 2022-08-15 08:12:42 -0700
- use title "The Rust Edition Guide" everywhere (rust-lang/edition-guide#280)
- "Creating a new project": add example using 'cargo new --edition YEAR' (rust-lang/edition-guide#279)
- fixes rust-lang/edition-guide#277: mention rust 1.0 release month and year (rust-lang/edition-guide#278)
2022-08-17 12:32:58 +02:00
Matthias Krüger
6eed54a2c9
Rollup merge of #100652 - compiler-errors:no-defer-sized-checks, r=TaKO8Ki
Remove deferred sized checks (make them eager)

Improves diagnostics spans... this doesn't seem to be the case anymore:

```rust
// Some additional `Sized` obligations badly affect type inference.
// These obligations are added in a later stage of typeck.
pub(super) deferred_sized_obligations:
        RefCell<Vec<(Ty<'tcx>, Span, traits::ObligationCauseCode<'tcx>)>>,
```
2022-08-17 12:32:57 +02:00
Matthias Krüger
c0297e2330
Rollup merge of #100646 - finalchild:emoji-diag, r=compiler-errors
Migrate emoji identifier diagnostics to `SessionDiagnostic` in rustc_interface

* Migrate emoji identifier diagnostics to `interface_ferris_identifier` and `interface_emoji_identifier`.

This is my first PR! I'm learning how to migrate these diagnostics. Thanks in advance.

r? rust-lang/diagnostics
2022-08-17 12:32:56 +02:00
Matthias Krüger
64cd65758c
Rollup merge of #100621 - taiki-e:armv4t-atomics-32, r=cuviper
Pass +atomics-32 feature for {arm,thumb}v4t-none-eabi

Similar to 89582e8193, but for ARMv4t.
Pre-v6 ARM target does not have atomic CAS, except for Linux and Android where atomic CAS is provided by compiler-builtins. So, there is a similar issue as thumbv6m.

I have confirmed that enabling the `atomics-32` target feature fixes the problem in the project affected by this issue. (https://github.com/taiki-e/portable-atomic/pull/28#discussion_r946604136)

Closes #100619

r? ``@nikic``
cc ``@Lokathor``
2022-08-17 12:32:55 +02:00
Matthias Krüger
d956734f9f
Rollup merge of #100608 - tshepang:needless-separation, r=TaKO8Ki
needless separation of impl blocks
2022-08-17 12:32:54 +02:00
Matthias Krüger
56b02b2137
Rollup merge of #100532 - RalfJung:unwind-miri, r=Mark-Simulacrum
unwind: don't build dependency when building for Miri

This is basically re-submitting https://github.com/rust-lang/rust/pull/94813.

In that PR there was a suggestion to instead have bootstrap set a `RUST_CHECK` env var and use that rather than doing something Miri-specific. However, such an env var would mean that when switching between `./x.py check` and `./x.py build`, the build script gets re-run each time, which doesn't seem good. So I think for now checking for Miri probably causes fewer problems.

r? ````@Mark-Simulacrum````
2022-08-17 12:32:53 +02:00
Matthias Krüger
1e93994b4d
Rollup merge of #100489 - lcnr:is_knowable-Result, r=davidtwco
`is_knowable` use `Result` instead of `Option`
2022-08-17 12:32:52 +02:00
Matthias Krüger
1948288615
Rollup merge of #100389 - compiler-errors:return-type-suggestion-cycle, r=cjgillot
Do not report cycle error when inferring return type for suggestion

The UI test is a good example of a case where this happens. The cycle is due to needing the value of the return type `-> _` to compute the variances of items in the crate, but then needing the variances of the items in the crate to do typechecking to infer what `-> _`'s real type is.

Since we're already gonna emit an error in astconv, just delay the cycle bug as an error.
2022-08-17 12:32:51 +02:00
Matthias Krüger
989e4ffc7c
Rollup merge of #100379 - davidtwco:triagebot-diag, r=Mark-Simulacrum
triagebot: add translation-related mention groups

- Move some code around so that triagebot can ping relevant parties when translation logic is modified.
- Add mention groups to triagebot for translation-related files/folders.
- Auto-label pull requests with changes to translation-related files/folders with `A-translation`.

r? `@Mark-Simulacrum`
2022-08-17 12:32:50 +02:00
Matthias Krüger
d5dca26a94
Rollup merge of #100018 - nnethercote:clean-up-LitKind, r=petrochenkov
Clean up `LitKind`

r? ``@petrochenkov``
2022-08-17 12:32:49 +02:00
Matthias Krüger
bb77336c0a
Rollup merge of #99972 - RalfJung:1zst, r=lcnr
interpret: only consider 1-ZST when searching for receiver

`repr(transparent)` currently entirely rejects ZST with alignment larger than 1 (which is odd, arguably [this](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=02870f29396fa948c3123cb53d869ad1) should be accepted), so this should be safe. And if it ever isn't safe then that is very likely a bug elsewhere in the compiler.
2022-08-17 12:32:48 +02:00
Matthias Krüger
0491fdad6f
Rollup merge of #99474 - aDotInTheVoid:rustdoc-json-noinline-test-cleanup, r=CraftSpider
Rustdoc json tests: New @hasexact test command

Alot of the time, we wanted to assert that a module had an exact set of items. Most of the time this was done by asserting that the ```@count``` of the module was `n`, and then doing `n` ```@has``` checks on the module.

This was tedious, so often shortcuts were done.

This PR adds a new command to jsondocck to allow consistently expressing this behavior, and then uses it to clean up the tests.

``@rustbot`` modify labels: +A-rustdoc-json +A-testsuite
2022-08-17 12:32:47 +02:00
PragmaTwice
98fb65eff9 Migrate lint reports in typeck::check_unused to LintDiagnostic 2022-08-17 17:47:44 +08:00
Xiretza
d3bf103d1b Fix documentation of rustc_parse::parser::Parser::parse_stmt_without_recovery
Something seems to have gotten out of sync during the creation of #81177,
where both the argument and comment were introduced.
2022-08-17 11:18:48 +02:00
lcnr
1cede2c126 is_knowable use Result instead of Option 2022-08-17 10:17:54 +02:00
PunkyMunky64
683b3f4e6e
Fixed a few documentation errors
Quick pull request; IEEE-754, not IEEE-745. May save someone a quick second some time.
2022-08-16 22:29:14 -07:00
PunkyMunky64
89d9a35b3e
Fixed a few documentation errors
IEEE-754, not IEEE-745. May save someone a second sometime
2022-08-16 22:28:11 -07:00
Nicholas Nethercote
52d8397985 Remove AttributesExt::other_attrs.
It's unused.
2022-08-17 12:38:21 +10:00
Nicholas Nethercote
6cd40d0e51 Remove attrs arg from typaram and mk_ty_param.
Because it's always empty.
2022-08-17 12:33:42 +10:00
Nicholas Nethercote
2c24958cfd Remove TraitDef::attributes.
Because it's always empty.
2022-08-17 12:29:02 +10:00