]> git.lizzy.rs Git - rust.git/log
rust.git
22 months agomove `type_check_internal` into `type_check`
lcnr [Thu, 7 Apr 2022 09:28:31 +0000 (11:28 +0200)]
move `type_check_internal` into `type_check`

22 months agosmall mir typeck cleanup
lcnr [Thu, 7 Apr 2022 09:16:37 +0000 (11:16 +0200)]
small mir typeck cleanup

22 months agoAuto merge of #99541 - timvermeulen:flatten_cleanup, r=the8472
bors [Fri, 19 Aug 2022 02:34:30 +0000 (02:34 +0000)]
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.

22 months agoAuto merge of #98851 - klensy:encode_symbols, r=cjgillot
bors [Thu, 18 Aug 2022 23:53:22 +0000 (23:53 +0000)]
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.

22 months agoAuto merge of #98807 - cbeuw:derived-obligation, r=compiler-errors
bors [Thu, 18 Aug 2022 21:12:05 +0000 (21:12 +0000)]
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}`"

22 months agoReword "Required because of the requirements on the impl of ..."
Andy Wang [Mon, 15 Aug 2022 20:31:37 +0000 (21:31 +0100)]
Reword "Required because of the requirements on the impl of ..."

22 months agoAuto merge of #99860 - oli-obk:revert_97346, r=pnkfelix
bors [Thu, 18 Aug 2022 15:41:30 +0000 (15:41 +0000)]
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 c703d11dccb4a895c7aead3b2fcd8cea8c483184, reversing
changes made to 64eb9ab869bc3f9ef3645302fbf22e706eea16cf.

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

22 months agoAuto merge of #100682 - RalfJung:miri, r=RalfJung
bors [Thu, 18 Aug 2022 12:56:21 +0000 (12:56 +0000)]
Auto merge of #100682 - RalfJung:miri, r=RalfJung

update Miri

Fixes https://github.com/rust-lang/rust/issues/100614
r? `@ghost`

22 months agoAuto merge of #98655 - nnethercote:dont-derive-PartialEq-ne, r=dtolnay
bors [Thu, 18 Aug 2022 10:11:11 +0000 (10:11 +0000)]
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.

22 months agoAuto merge of #100708 - matthiaskrgr:rollup-vl0olnj, r=matthiaskrgr
bors [Thu, 18 Aug 2022 07:09:06 +0000 (07:09 +0000)]
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

22 months agoRollup merge of #100688 - compiler-errors:issue-100684, r=wesleywiser
Matthias Krüger [Thu, 18 Aug 2022 03:10:51 +0000 (05:10 +0200)]
Rollup merge of #100688 - compiler-errors:issue-100684, r=wesleywiser

`ty::Error` does not match other types for region constraints

Fixes #100684

22 months agoRollup merge of #100674 - PragmaTwice:mig-typeck-unused-crate-diag, r=davidtwco
Matthias Krüger [Thu, 18 Aug 2022 03:10:50 +0000 (05:10 +0200)]
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

22 months agoRollup merge of #100670 - Xiretza:parser-stmt-force-collect-docs, r=davidtwco
Matthias Krüger [Thu, 18 Aug 2022 03:10:49 +0000 (05:10 +0200)]
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.

22 months agoRollup merge of #100669 - nnethercote:attribute-cleanups, r=spastorino
Matthias Krüger [Thu, 18 Aug 2022 03:10:48 +0000 (05:10 +0200)]
Rollup merge of #100669 - nnethercote:attribute-cleanups, r=spastorino

Attribute cleanups

r? `@ghost`

22 months agoRollup merge of #100651 - nidnogg:diagnostics_migration_expand_transcribe, r=davidtwco
Matthias Krüger [Thu, 18 Aug 2022 03:10:47 +0000 (05:10 +0200)]
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```

22 months agoRollup merge of #100643 - TaKO8Ki:point-at-type-parameter-shadowing-another-type...
Matthias Krüger [Thu, 18 Aug 2022 03:10:46 +0000 (05:10 +0200)]
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.

22 months agoRollup merge of #100637 - andrewpollack:fuchsia-docs-adjustments, r=tmandry
Matthias Krüger [Thu, 18 Aug 2022 03:10:45 +0000 (05:10 +0200)]
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

22 months agoRollup merge of #99966 - RalfJung:try-dont-panic, r=lcnr
Matthias Krüger [Thu, 18 Aug 2022 03:10:42 +0000 (05:10 +0200)]
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```

22 months agoRollup merge of #97962 - eholk:drop-tracking-must-not-suspend, r=cjgillot
Matthias Krüger [Thu, 18 Aug 2022 03:10:41 +0000 (05:10 +0200)]
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](https://cs.github.com/rust-lang/rust/blob/9a74608543d499bcc7dd505e195e8bfab9447315/src/test/ui/lint/must_not_suspend/dedup.rs#L4)), so we only use the new behavior when drop tracking is enabled.

cc ``@guswynn``

22 months agoty::Error does not match other types for region constraints
Michael Goulet [Wed, 17 Aug 2022 17:23:52 +0000 (17:23 +0000)]
ty::Error does not match other types for region constraints

22 months agoHotfix for duplicated slug name on VarStillRepeating struct
nidnogg [Wed, 17 Aug 2022 16:13:07 +0000 (13:13 -0300)]
Hotfix for duplicated slug name on VarStillRepeating struct

22 months agoAuto merge of #100677 - matthiaskrgr:rollup-au41ho1, r=matthiaskrgr
bors [Wed, 17 Aug 2022 14:49:05 +0000 (14:49 +0000)]
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

22 months agoMoved structs to rustc_expand::errors, added several more migrations, fixed slug...
nidnogg [Wed, 17 Aug 2022 14:20:37 +0000 (11:20 -0300)]
Moved structs to rustc_expand::errors, added several more migrations, fixed slug name

22 months agoMoved structs to rustc_expand::errors, added several more migrations, fixed slug...
nidnogg [Wed, 17 Aug 2022 14:18:19 +0000 (11:18 -0300)]
Moved structs to rustc_expand::errors, added several more migrations, fixed slug name

22 months agoremove #[primary_span]
PragmaTwice [Wed, 17 Aug 2022 14:08:06 +0000 (22:08 +0800)]
remove #[primary_span]

22 months agoupdate Miri
Ralf Jung [Wed, 17 Aug 2022 13:09:33 +0000 (09:09 -0400)]
update Miri

22 months agofix test file
PragmaTwice [Wed, 17 Aug 2022 13:05:21 +0000 (21:05 +0800)]
fix test file

22 months agouse `suggestion_short` in `LintDiagnostic`
Twice [Wed, 17 Aug 2022 12:45:18 +0000 (20:45 +0800)]
use `suggestion_short` in `LintDiagnostic`

Co-authored-by: David Wood <agile.lion3441@fuligin.ink>
22 months agoRollup merge of #100661 - PunkyMunky64:patch-1, r=thomcc
Matthias Krüger [Wed, 17 Aug 2022 10:33:02 +0000 (12:33 +0200)]
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.

22 months agoRollup merge of #100660 - PunkyMunky64:patch-2, r=thomcc
Matthias Krüger [Wed, 17 Aug 2022 10:33:01 +0000 (12:33 +0200)]
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.

22 months agoRollup merge of #100656 - ehuss:update-cargo, r=ehuss
Matthias Krüger [Wed, 17 Aug 2022 10:33:00 +0000 (12:33 +0200)]
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)

22 months agoRollup merge of #100655 - ehuss:update-books, r=ehuss
Matthias Krüger [Wed, 17 Aug 2022 10:32:58 +0000 (12:32 +0200)]
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)

22 months agoRollup merge of #100652 - compiler-errors:no-defer-sized-checks, r=TaKO8Ki
Matthias Krüger [Wed, 17 Aug 2022 10:32:57 +0000 (12:32 +0200)]
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>)>>,
```

22 months agoRollup merge of #100646 - finalchild:emoji-diag, r=compiler-errors
Matthias Krüger [Wed, 17 Aug 2022 10:32:56 +0000 (12:32 +0200)]
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

22 months agoRollup merge of #100621 - taiki-e:armv4t-atomics-32, r=cuviper
Matthias Krüger [Wed, 17 Aug 2022 10:32:55 +0000 (12:32 +0200)]
Rollup merge of #100621 - taiki-e:armv4t-atomics-32, r=cuviper

Pass +atomics-32 feature for {arm,thumb}v4t-none-eabi

Similar to https://github.com/rust-lang/rust/commit/89582e8193e0da64a54c4ffae7f9fa64ed9fe2af, 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``

22 months agoRollup merge of #100608 - tshepang:needless-separation, r=TaKO8Ki
Matthias Krüger [Wed, 17 Aug 2022 10:32:54 +0000 (12:32 +0200)]
Rollup merge of #100608 - tshepang:needless-separation, r=TaKO8Ki

needless separation of impl blocks

22 months agoRollup merge of #100532 - RalfJung:unwind-miri, r=Mark-Simulacrum
Matthias Krüger [Wed, 17 Aug 2022 10:32:53 +0000 (12:32 +0200)]
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````

22 months agoRollup merge of #100489 - lcnr:is_knowable-Result, r=davidtwco
Matthias Krüger [Wed, 17 Aug 2022 10:32:52 +0000 (12:32 +0200)]
Rollup merge of #100489 - lcnr:is_knowable-Result, r=davidtwco

`is_knowable` use `Result` instead of `Option`

22 months agoRollup merge of #100389 - compiler-errors:return-type-suggestion-cycle, r=cjgillot
Matthias Krüger [Wed, 17 Aug 2022 10:32:51 +0000 (12:32 +0200)]
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.

22 months agoRollup merge of #100379 - davidtwco:triagebot-diag, r=Mark-Simulacrum
Matthias Krüger [Wed, 17 Aug 2022 10:32:50 +0000 (12:32 +0200)]
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`

22 months agoRollup merge of #100018 - nnethercote:clean-up-LitKind, r=petrochenkov
Matthias Krüger [Wed, 17 Aug 2022 10:32:49 +0000 (12:32 +0200)]
Rollup merge of #100018 - nnethercote:clean-up-LitKind, r=petrochenkov

Clean up `LitKind`

r? ``@petrochenkov``

22 months agoRollup merge of #99972 - RalfJung:1zst, r=lcnr
Matthias Krüger [Wed, 17 Aug 2022 10:32:48 +0000 (12:32 +0200)]
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.

22 months agoRollup merge of #99474 - aDotInTheVoid:rustdoc-json-noinline-test-cleanup, r=CraftSpider
Matthias Krüger [Wed, 17 Aug 2022 10:32:47 +0000 (12:32 +0200)]
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

22 months agoMigrate lint reports in typeck::check_unused to LintDiagnostic
PragmaTwice [Wed, 17 Aug 2022 09:47:44 +0000 (17:47 +0800)]
Migrate lint reports in typeck::check_unused to LintDiagnostic

22 months agoFix documentation of rustc_parse::parser::Parser::parse_stmt_without_recovery
Xiretza [Wed, 17 Aug 2022 09:18:48 +0000 (11:18 +0200)]
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.

22 months ago`is_knowable` use `Result` instead of `Option`
lcnr [Sat, 13 Aug 2022 11:35:27 +0000 (13:35 +0200)]
`is_knowable` use `Result` instead of `Option`

22 months agoFixed a few documentation errors
PunkyMunky64 [Wed, 17 Aug 2022 05:29:14 +0000 (22:29 -0700)]
Fixed a few documentation errors

Quick pull request; IEEE-754, not IEEE-745. May save someone a quick second some time.

22 months agoFixed a few documentation errors
PunkyMunky64 [Wed, 17 Aug 2022 05:28:11 +0000 (22:28 -0700)]
Fixed a few documentation errors

IEEE-754, not IEEE-745. May save someone a second sometime

22 months agoRemove `AttributesExt::other_attrs`.
Nicholas Nethercote [Wed, 17 Aug 2022 02:38:21 +0000 (12:38 +1000)]
Remove `AttributesExt::other_attrs`.

It's unused.

22 months agoRemove `attrs` arg from `typaram` and `mk_ty_param`.
Nicholas Nethercote [Wed, 17 Aug 2022 02:33:42 +0000 (12:33 +1000)]
Remove `attrs` arg from `typaram` and `mk_ty_param`.

Because it's always empty.

22 months agoRemove `TraitDef::attributes`.
Nicholas Nethercote [Wed, 17 Aug 2022 02:20:25 +0000 (12:20 +1000)]
Remove `TraitDef::attributes`.

Because it's always empty.

22 months agoUpdate cargo
Eric Huss [Wed, 17 Aug 2022 02:02:19 +0000 (19:02 -0700)]
Update cargo

22 months agoUpdate books
Eric Huss [Wed, 17 Aug 2022 01:52:39 +0000 (18:52 -0700)]
Update books

22 months agoRemove deferred sized checks
Michael Goulet [Tue, 16 Aug 2022 22:01:51 +0000 (22:01 +0000)]
Remove deferred sized checks

22 months agoPrevious commit under x.py fmt
nidnogg [Tue, 16 Aug 2022 22:19:59 +0000 (19:19 -0300)]
Previous commit under x.py fmt

22 months agoMigrated more diagnostics under transcribe.rs
nidnogg [Tue, 16 Aug 2022 22:02:51 +0000 (19:02 -0300)]
Migrated more diagnostics under transcribe.rs

22 months agoAdded first migration for repeated expressions without syntax vars
nidnogg [Tue, 16 Aug 2022 21:34:13 +0000 (18:34 -0300)]
Added first migration for repeated expressions without syntax vars

22 months agoAuto merge of #100644 - TaKO8Ki:rollup-n0o6a1t, r=TaKO8Ki
bors [Tue, 16 Aug 2022 21:10:08 +0000 (21:10 +0000)]
Auto merge of #100644 - TaKO8Ki:rollup-n0o6a1t, r=TaKO8Ki

Rollup of 4 pull requests

Successful merges:

 - #100243 (Remove opt_remap_env_constness from rustc_query_impl)
 - #100625 (Add `IpDisplayBuffer` helper struct.)
 - #100629 (Use `merged_ty` method instead of rewriting it every time)
 - #100630 (rustdoc JSON: Fix ICE with `pub extern crate self as <self_crate_name>`)

Failed merges:

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

22 months agoRollup merge of #100630 - Enselic:export_extern_crate_as_self, r=GuillaumeGomez
Takayuki Maeda [Tue, 16 Aug 2022 20:08:05 +0000 (05:08 +0900)]
Rollup merge of #100630 - Enselic:export_extern_crate_as_self, r=GuillaumeGomez

rustdoc JSON: Fix ICE with `pub extern crate self as <self_crate_name>`

Closes #100531

r? `@GuillaumeGomez`

`@rustbot` labels +A-rustdoc-json +T-rustdoc

22 months agoRollup merge of #100629 - GuillaumeGomez:merged-ty, r=compiler-errors
Takayuki Maeda [Tue, 16 Aug 2022 20:08:04 +0000 (05:08 +0900)]
Rollup merge of #100629 - GuillaumeGomez:merged-ty, r=compiler-errors

Use `merged_ty` method instead of rewriting it every time

`merged_ty` [source code](https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_typeck/check/coercion.rs.html#1331-1333) is quite literally the same, so instead of rewriting it, makes more sense to use the method instead.

r? `@compiler-errors`

22 months agoRollup merge of #100625 - reitermarkus:ip-display-buffer, r=thomcc
Takayuki Maeda [Tue, 16 Aug 2022 20:08:03 +0000 (05:08 +0900)]
Rollup merge of #100625 - reitermarkus:ip-display-buffer, r=thomcc

Add `IpDisplayBuffer` helper struct.

This removes the dependency on `std::io::Write` for implementing `Display`, allowing it to be moved to `core` as proposed in https://github.com/rust-lang/rfcs/pull/2832.

22 months agoRollup merge of #100243 - kckeiks:remove-macros-in-query-system, r=cjgillot
Takayuki Maeda [Tue, 16 Aug 2022 20:08:02 +0000 (05:08 +0900)]
Rollup merge of #100243 - kckeiks:remove-macros-in-query-system, r=cjgillot

Remove opt_remap_env_constness from rustc_query_impl

1st task off #96524.

r? `@cjgillot`

22 months agoMigrate emoji identifier diagnostics to `SessionDiagnostic`
finalchild [Tue, 16 Aug 2022 20:07:47 +0000 (05:07 +0900)]
Migrate emoji identifier diagnostics to `SessionDiagnostic`

22 months agoavoid a `&str` to `String` conversion
Takayuki Maeda [Tue, 16 Aug 2022 19:58:26 +0000 (04:58 +0900)]
avoid a `&str` to `String` conversion

22 months agopoint at a type parameter shadowing another type
Takayuki Maeda [Tue, 16 Aug 2022 19:53:06 +0000 (04:53 +0900)]
point at a type parameter shadowing another type

22 months agoAuto merge of #100626 - Dylan-DPC:rollup-mwbm7kj, r=Dylan-DPC
bors [Tue, 16 Aug 2022 18:07:02 +0000 (18:07 +0000)]
Auto merge of #100626 - Dylan-DPC:rollup-mwbm7kj, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #99942 (Fix nonsense non-tupled `Fn` trait error)
 - #100609 (Extend invalid floating point literal suffix suggestion)
 - #100610 (Ast and parser tweaks)
 - #100613 (compiletest: fix typo in runtest.rs)
 - #100616 (:arrow_up: rust-analyzer)
 - #100622 (Support 128-bit atomics on all aarch64 targets)

Failed merges:

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

22 months agoSimplify `IpDisplayBuffer` API.
Markus Reiter [Tue, 16 Aug 2022 17:32:00 +0000 (19:32 +0200)]
Simplify `IpDisplayBuffer` API.

22 months agoUse `MaybeUninit<u8>` for `IpDisplayBuffer`.
Markus Reiter [Tue, 16 Aug 2022 16:12:06 +0000 (18:12 +0200)]
Use `MaybeUninit<u8>` for `IpDisplayBuffer`.

22 months agoImproving Fuchsia rustc support documentation
Andrew Pollack [Tue, 16 Aug 2022 15:56:38 +0000 (15:56 +0000)]
Improving Fuchsia rustc support documentation

Improving wording

22 months agoMove `IpDisplayBuffer` into submodule.
Markus Reiter [Tue, 16 Aug 2022 15:48:55 +0000 (17:48 +0200)]
Move `IpDisplayBuffer` into submodule.

22 months agoAdd `IpDisplayBuffer` helper struct.
Markus Reiter [Tue, 16 Aug 2022 12:42:00 +0000 (14:42 +0200)]
Add `IpDisplayBuffer` helper struct.

22 months agorustdoc JSON: Fix ICE with `pub extern crate self as <self_crate_name>`
Martin Nordholts [Tue, 16 Aug 2022 13:37:31 +0000 (15:37 +0200)]
rustdoc JSON: Fix ICE with `pub extern crate self as <self_crate_name>`

22 months agoUse `merged_ty` method instead of rewriting it every time
Guillaume Gomez [Tue, 16 Aug 2022 13:33:46 +0000 (15:33 +0200)]
Use `merged_ty` method instead of rewriting it every time

22 months agoRollup merge of #100622 - taiki-e:aarch64-atomic-128, r=Amanieu
Dylan DPC [Tue, 16 Aug 2022 12:46:16 +0000 (18:16 +0530)]
Rollup merge of #100622 - taiki-e:aarch64-atomic-128, r=Amanieu

Support 128-bit atomics on all aarch64 targets

Some aarch64 targets currently set `max_atomic_width` to 64, but aarch64 always supports 128-bit atomics.

r? `@Amanieu`

22 months agoRollup merge of #100616 - lnicola:rust-analyzer-2022-08-16, r=lnicola
Dylan DPC [Tue, 16 Aug 2022 12:46:15 +0000 (18:16 +0530)]
Rollup merge of #100616 - lnicola:rust-analyzer-2022-08-16, r=lnicola

:arrow_up: rust-analyzer

r? `@ghost`

22 months agoRollup merge of #100613 - eltociear:patch-15, r=Mark-Simulacrum
Dylan DPC [Tue, 16 Aug 2022 12:46:14 +0000 (18:16 +0530)]
Rollup merge of #100613 - eltociear:patch-15, r=Mark-Simulacrum

compiletest: fix typo in runtest.rs

nonexistant -> nonexistent

22 months agoRollup merge of #100610 - nnethercote:ast-and-parser-tweaks, r=spastorino
Dylan DPC [Tue, 16 Aug 2022 12:46:13 +0000 (18:16 +0530)]
Rollup merge of #100610 - nnethercote:ast-and-parser-tweaks, r=spastorino

Ast and parser tweaks

r? `@spastorino`

22 months agoRollup merge of #100609 - chenyukang:fix-100527, r=davidtwco
Dylan DPC [Tue, 16 Aug 2022 12:46:12 +0000 (18:16 +0530)]
Rollup merge of #100609 - chenyukang:fix-100527, r=davidtwco

Extend invalid floating point literal suffix suggestion

Fixes #100527

22 months agoRollup merge of #99942 - compiler-errors:nonsense-un-tupled-fn-trait-error, r=cjgillot
Dylan DPC [Tue, 16 Aug 2022 12:46:11 +0000 (18:16 +0530)]
Rollup merge of #99942 - compiler-errors:nonsense-un-tupled-fn-trait-error, r=cjgillot

Fix nonsense non-tupled `Fn` trait error

Given this code:

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

fn a<F: Fn<usize>>(f: F) {}

fn main() {
    a(|_: usize| {});
}
```

We currently emit this error:
```
error[E0631]: type mismatch in closure arguments
 --> src/main.rs:6:5
  |
6 |     a(|_: usize| {});
  |     ^ ---------- found signature of `fn(usize) -> _`
  |     |
  |     expected signature of `fn(usize) -> _`
  |
note: required by a bound in `a`
 --> src/main.rs:3:9
  |
3 | fn a<F: Fn<usize>>(f: F) {}
  |         ^^^^^^^^^ required by this bound in `a`

For more information about this error, try `rustc --explain E0631`.
error: could not compile `playground` due to previous error
```
Notably, it says the same thing for "expected" and "found"!

Fix the output so that we instead emit:
```
error[E0308]: mismatched types
 --> /home/gh-compiler-errors/test.rs:6:5
  |
6 |     a(|_: usize| {});
  |     ^ types differ
  |
  = note: expected trait `Fn<usize>`
             found trait `Fn<(usize,)>`
note: required by a bound in `a`
 --> /home/gh-compiler-errors/test.rs:3:9
  |
3 | fn a<F: Fn<usize>>(f: F) {}
  |         ^^^^^^^^^ required by this bound in `a`

error: aborting due to previous error
```

The error could still use some work, namely the "mismatched types" part, but I'm leaving it a bit rough since the only way you'd ever get this error is when you're messing with `#![feature(unboxed_closures)]`.

Simply making sure we actually print out the difference in trait-refs is good enough for me. I could probably factor in some additional improvements if those are desired.

22 months agouse proper words in help message for floating point
yukang [Tue, 16 Aug 2022 11:12:36 +0000 (19:12 +0800)]
use proper words in help message for floating point

22 months agoAuto merge of #99612 - yanchen4791:issue-95079-fix, r=compiler-errors
bors [Tue, 16 Aug 2022 11:00:25 +0000 (11:00 +0000)]
Auto merge of #99612 - yanchen4791:issue-95079-fix, r=compiler-errors

Fix #95079 unhelpful error when missing move in nested closure

Fix #95079 by adding help for missing move in nested closure

22 months agoSupport 128-bit atomics on all aarch64 targets
Taiki Endo [Tue, 16 Aug 2022 10:52:19 +0000 (19:52 +0900)]
Support 128-bit atomics on all aarch64 targets

22 months agoPass +atomics-32 feature for {arm,thumb}v4t-none-eabi
Taiki Endo [Tue, 16 Aug 2022 10:24:12 +0000 (19:24 +0900)]
Pass +atomics-32 feature for {arm,thumb}v4t-none-eabi

22 months ago:arrow_up: rust-analyzer
Laurențiu Nicola [Tue, 16 Aug 2022 08:24:50 +0000 (11:24 +0300)]
:arrow_up: rust-analyzer

22 months agoAuto merge of #100441 - nnethercote:shrink-ast-Attribute, r=petrochenkov
bors [Tue, 16 Aug 2022 07:54:22 +0000 (07:54 +0000)]
Auto merge of #100441 - nnethercote:shrink-ast-Attribute, r=petrochenkov

Shrink `ast::Attribute`.

r? `@ghost`

22 months agocompiletest: fix typo in runtest.rs
Ikko Ashimine [Tue, 16 Aug 2022 07:51:52 +0000 (16:51 +0900)]
compiletest: fix typo in runtest.rs

nonexistant -> nonexistent

22 months agoAuto merge of #100611 - matthiaskrgr:rollup-rxj10ur, r=matthiaskrgr
bors [Tue, 16 Aug 2022 05:13:38 +0000 (05:13 +0000)]
Auto merge of #100611 - matthiaskrgr:rollup-rxj10ur, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #100338 (when there are 3 or more return statements in the loop)
 - #100384 (Add support for generating unique profraw files by default when using `-C instrument-coverage`)
 - #100460 (Update the minimum external LLVM to 13)
 - #100567 (Add missing closing quote)
 - #100590 (Suggest adding an array length if possible)
 - #100600 (Rename Machine memory hooks to suggest when they run)

Failed merges:

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

22 months agoRollup merge of #100600 - saethlin:rename-memory-hooks, r=RalfJung
Matthias Krüger [Tue, 16 Aug 2022 04:06:00 +0000 (06:06 +0200)]
Rollup merge of #100600 - saethlin:rename-memory-hooks, r=RalfJung

Rename Machine memory hooks to suggest when they run

Some of the other memory hooks start with `before_` or `after_` to indicate that they run before or after a certain operation. These don't, so I was a bit confused as to when they are supposed to run.

`memory_read` can be read two ways in English, "memory was read" or "this is a memory read" so without the prefix this was especially ambiguous.

22 months agoRollup merge of #100590 - TaKO8Ki:suggest-adding-array-length, r=compiler-errors
Matthias Krüger [Tue, 16 Aug 2022 04:05:59 +0000 (06:05 +0200)]
Rollup merge of #100590 - TaKO8Ki:suggest-adding-array-length, r=compiler-errors

Suggest adding an array length if possible

fixes #100448

22 months agoRollup merge of #100567 - Rageking8:fix-100563, r=wesleywiser
Matthias Krüger [Tue, 16 Aug 2022 04:05:58 +0000 (06:05 +0200)]
Rollup merge of #100567 - Rageking8:fix-100563, r=wesleywiser

Add missing closing quote

fixes #100563

22 months agoRollup merge of #100460 - cuviper:drop-llvm-12, r=nagisa
Matthias Krüger [Tue, 16 Aug 2022 04:05:57 +0000 (06:05 +0200)]
Rollup merge of #100460 - cuviper:drop-llvm-12, r=nagisa

Update the minimum external LLVM to 13

With this change, we'll have stable support for LLVM 13 through 15 (pending release).
For reference, the previous increase to LLVM 12 was #90175.

r? `@nagisa`

22 months agoRollup merge of #100384 - ridwanabdillahi:instr_profile_output, r=wesleywiser
Matthias Krüger [Tue, 16 Aug 2022 04:05:56 +0000 (06:05 +0200)]
Rollup merge of #100384 - ridwanabdillahi:instr_profile_output, r=wesleywiser

Add support for generating unique profraw files by default when using `-C instrument-coverage`

Currently, enabling the rustc flag `-C instrument-coverage` instruments the given crate and by default uses the naming scheme `default.profraw` for any instrumented profile files generated during the execution of a binary linked against this crate. This leads to multiple binaries being executed overwriting one another and causing only the last executable run to contain actual coverage results.

This can be overridden by manually setting the environment variable `LLVM_PROFILE_FILE` to use a unique naming scheme.

This PR adds a change to add support for a reasonable default for rustc to use when enabling coverage instrumentation similar to how the Rust compiler treats generating these same `profraw` files when PGO is enabled.

The new naming scheme is set to `default_%m_%p.profraw` to ensure the uniqueness of each file being generated using [LLVMs special pattern strings](https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#running-the-instrumented-program).

Today the compiler sets the default for PGO `profraw` files to `default_%m.profraw` to ensure a unique file for each run. The same can be done for the instrumented profile files generated via the `-C instrument-coverage` flag as well which LLVM has API support for.

Linked Issue: https://github.com/rust-lang/rust/issues/100381

r? `@wesleywiser`

22 months agoRollup merge of #100338 - lyming2007:issue-100285-fix, r=petrochenkov
Matthias Krüger [Tue, 16 Aug 2022 04:05:55 +0000 (06:05 +0200)]
Rollup merge of #100338 - lyming2007:issue-100285-fix, r=petrochenkov

when there are 3 or more return statements in the loop

emit the first 3 errors and duplicated diagnostic information
modified:   compiler/rustc_typeck/src/check/coercion.rs
new file:   src/test/ui/typeck/issue-100285.rs
new file:   src/test/ui/typeck/issue-100285.stderr

22 months agoRename some things related to literals.
Nicholas Nethercote [Mon, 1 Aug 2022 06:46:08 +0000 (16:46 +1000)]
Rename some things related to literals.

- Rename `ast::Lit::token` as `ast::Lit::token_lit`, because its type is
  `token::Lit`, which is not a token. (This has been confusing me for a
  long time.)
  reasonable because we have an `ast::token::Lit` inside an `ast::Lit`.
- Rename `LitKind::{from,to}_lit_token` as
  `LitKind::{from,to}_token_lit`, to match the above change and
  `token::Lit`.

22 months agoAdd some more AST node size assertions.
Nicholas Nethercote [Tue, 16 Aug 2022 02:18:34 +0000 (12:18 +1000)]
Add some more AST node size assertions.

There is some redundancy here, but the extra assertions make it easier
to keep track of relative things, e.g. `ExprKind` is the biggest part
of `Expr`.

22 months agoDo not report cycle error when inferring return type for suggestion
Michael Goulet [Wed, 10 Aug 2022 20:53:06 +0000 (20:53 +0000)]
Do not report cycle error when inferring return type for suggestion

22 months agoExtend invalid floating point literal suffix suggestion
yukang [Tue, 16 Aug 2022 02:50:04 +0000 (10:50 +0800)]
Extend invalid floating point literal suffix suggestion

22 months agoAuto merge of #100237 - cjgillot:no-special-hash-hir, r=nagisa
bors [Tue, 16 Aug 2022 02:32:47 +0000 (02:32 +0000)]
Auto merge of #100237 - cjgillot:no-special-hash-hir, r=nagisa

Remove manual implementations of HashStable for hir::Expr and hir::Ty.

We do not need to force hashing HIR bodies inside those nodes. The contents of bodies are not accessible from the `hir_owner` query which used `hash_without_bodies`. When the content of a body is required, the access is still done using `hir_owner_nodes`, which continues hashing HIR bodies.

22 months agoAvoid unnecessary cloning in `Parser::get_ident_from_generic_arg`.
Nicholas Nethercote [Tue, 16 Aug 2022 02:14:52 +0000 (12:14 +1000)]
Avoid unnecessary cloning in `Parser::get_ident_from_generic_arg`.

22 months agoRemove `{ast,hir}::WhereEqPredicate::id`.
Nicholas Nethercote [Fri, 29 Jul 2022 00:16:25 +0000 (10:16 +1000)]
Remove `{ast,hir}::WhereEqPredicate::id`.

These fields are unused.