]> git.lizzy.rs Git - rust.git/log
rust.git
15 months agoSpecify dlltool prefix when generating import libs
Rafael Rivera [Tue, 7 Feb 2023 05:17:06 +0000 (21:17 -0800)]
Specify dlltool prefix when generating import libs

15 months agoAuto merge of #103761 - chenyukang:yukang/fix-103320-must-use, r=compiler-errors
bors [Mon, 6 Feb 2023 12:57:37 +0000 (12:57 +0000)]
Auto merge of #103761 - chenyukang:yukang/fix-103320-must-use, r=compiler-errors

Add explanatory message for [#must_use] in ops

Fixes #103320

15 months agoAuto merge of #107667 - cjgillot:no-on-hit, r=lcnr,Zoxc
bors [Mon, 6 Feb 2023 09:09:09 +0000 (09:09 +0000)]
Auto merge of #107667 - cjgillot:no-on-hit, r=lcnr,Zoxc

Remove `OnHit` callback from query caches.

This is not useful now that query results are `Copy`.

15 months agoAuto merge of #107697 - kiranshila:patch-1, r=the8472
bors [Mon, 6 Feb 2023 05:03:06 +0000 (05:03 +0000)]
Auto merge of #107697 - kiranshila:patch-1, r=the8472

Fix typo in HashMap::with_capacity

15 months agoAuto merge of #107141 - notriddle:notriddle/max-lev-distance-2023, r=GuillaumeGomez
bors [Mon, 6 Feb 2023 02:09:00 +0000 (02:09 +0000)]
Auto merge of #107141 - notriddle:notriddle/max-lev-distance-2023, r=GuillaumeGomez

rustdoc: compute maximum Levenshtein distance based on the query

Preview: https://notriddle.com/notriddle-rustdoc-demos/search-lev-distance-2023/std/index.html?search=regex

The heuristic is pretty close to the name resolver, maxLevDistance = `Math.floor(queryLen / 3)`.

Fixes #103357
Fixes #82131

Similar to https://github.com/rust-lang/rust/pull/103710, but following the suggestion in https://github.com/rust-lang/rust/pull/103710#issuecomment-1296360267 to use `floor` instead of `ceil`, and unblocked now that https://github.com/rust-lang/rust/pull/105796 made it so that setting the max lev distance to `0` doesn't cause substring matches to be removed.

15 months agoAuto merge of #107627 - nnethercote:optimize-fold_ty, r=compiler-errors
bors [Sun, 5 Feb 2023 23:13:41 +0000 (23:13 +0000)]
Auto merge of #107627 - nnethercote:optimize-fold_ty, r=compiler-errors

Optimize `fold_ty`

Micro-optimizing the heck out of the important `fold_ty` methods.

r? `@oli-obk`

15 months agoSplit and inline `TypeFreshener::fold_ty`.
Nicholas Nethercote [Fri, 3 Feb 2023 00:36:32 +0000 (11:36 +1100)]
Split and inline `TypeFreshener::fold_ty`.

15 months agoSplit and inline `ShallowResolver::fold_ty`.
Nicholas Nethercote [Fri, 3 Feb 2023 01:36:44 +0000 (12:36 +1100)]
Split and inline `ShallowResolver::fold_ty`.

15 months agoInline `OpportunisticVarResolver::fold_ty`.
Nicholas Nethercote [Thu, 2 Feb 2023 23:31:11 +0000 (10:31 +1100)]
Inline `OpportunisticVarResolver::fold_ty`.

15 months agoImprove early bailout test in `resolve_vars_if_possible`.
Nicholas Nethercote [Thu, 2 Feb 2023 23:15:24 +0000 (10:15 +1100)]
Improve early bailout test in `resolve_vars_if_possible`.

`!t.has_non_region_infer()` is the test used in
`OpportunisticVarResolver`, and catches a few cases that
`!t.needs_infer()` misses.

15 months agoPut a `ShallowResolver` within `OpportunisticVarResolver`.
Nicholas Nethercote [Thu, 2 Feb 2023 22:00:56 +0000 (09:00 +1100)]
Put a `ShallowResolver` within `OpportunisticVarResolver`.

So one doesn't have to be constructed every time.

15 months agoAuto merge of #107526 - obeis:for-missing-iterator, r=estebank,compiler-errors
bors [Sun, 5 Feb 2023 20:33:05 +0000 (20:33 +0000)]
Auto merge of #107526 - obeis:for-missing-iterator, r=estebank,compiler-errors

Recover form missing expression in `for` loop

Close #78537
r? `@estebank`

15 months agoFix typo in HashMap::with_capacity
Kiran Shila [Sun, 5 Feb 2023 18:13:30 +0000 (10:13 -0800)]
Fix typo in HashMap::with_capacity

15 months agoAuto merge of #107663 - matthiaskrgr:107423-point-at-EOF-code, r=compiler-errors
bors [Sun, 5 Feb 2023 17:32:26 +0000 (17:32 +0000)]
Auto merge of #107663 - matthiaskrgr:107423-point-at-EOF-code, r=compiler-errors

don't point at nonexisting code beyond EOF when warning about delims

Previously we would show this:
```
warning: unnecessary braces around block return value
 --> /tmp/bad.rs:1:8
  |
1 | fn a(){{{
  |        ^  ^
  |
  = note: `#[warn(unused_braces)]` on by default
help: remove these braces
  |
1 - fn a(){{{
1 + fn a(){{
  |
```

which is now hidden in this case.
We would create a span spanning between the pair of redundant {}s but there is only EOF instead of the `}` so we would previously point at nothing. This would cause the debug assertion ice to trigger. I would have loved to just only point at the second delim and say "you can remove that" but I'm not sure how to do that without refactoring the entire diagnostic which seems tricky. :( But given that this does not seem to regress any other tests we have, I think this edge-casey enough be acceptable.

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

r? `@compiler-errors`

15 months agoAdd ui test for missing expression in for loop
Obei Sideg [Fri, 3 Feb 2023 09:25:01 +0000 (12:25 +0300)]
Add ui test for missing expression in for loop

15 months agoRecover from missing expression in for loop
Obei Sideg [Fri, 3 Feb 2023 09:23:37 +0000 (12:23 +0300)]
Recover from missing expression in for loop

15 months agoAuto merge of #102842 - rol1510:issue-85566-fix, r=notriddle
bors [Sun, 5 Feb 2023 14:01:49 +0000 (14:01 +0000)]
Auto merge of #102842 - rol1510:issue-85566-fix, r=notriddle

rustdoc: change trait bound formatting

Fixes #85566

Before
<img width="268" alt="image" src="https://user-images.githubusercontent.com/29011024/208326689-cc9b4bae-529c-473c-81e2-fc5ddb738f07.png">

Now
<img width="268" alt="image" src="https://user-images.githubusercontent.com/29011024/216216918-d7923787-3e3b-486d-9735-4cecd2988dba.png">

15 months agoAuto merge of #107679 - est31:less_import_overhead, r=compiler-errors
bors [Sun, 5 Feb 2023 11:10:11 +0000 (11:10 +0000)]
Auto merge of #107679 - est31:less_import_overhead, r=compiler-errors

Less import overhead for errors

This removes huge (3+ lines) import lists found in files that had their error reporting migrated. These lists are bad for developer workflows as adding, removing, or editing a single error's name might cause a chain reaction that bloats the git diff. As the error struct names are long, the likelihood of such chain reactions is high.

Follows the suggestion by `@Nilstrieb` in the [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/massive.20use.20statements) to replace the `use errors::{FooErr, BarErr};` with `use errors;` and then changing to `errors::FooErr` on the usage sites.

I have used sed to do most of the changes, i.e. something like:

```
sed -i -E 's/(create_err|create_feature_err|emit_err|create_note|emit_fatal|emit_warning)\(([[:alnum:]]+|[A-Z][[:alnum:]:]*)( \{|\))/\1(errors::\2\3/' path/to/file.rs
```

& then I manually fixed the errors that occured. Most manual changes were required in `compiler/rustc_parse/src/parser/expr.rs`.

r? `@compiler-errors`

15 months agoAuto merge of #107434 - BoxyUwU:nll_const_equate, r=compiler-errors
bors [Sun, 5 Feb 2023 07:36:37 +0000 (07:36 +0000)]
Auto merge of #107434 - BoxyUwU:nll_const_equate, r=compiler-errors

emit `ConstEquate` in `TypeRelating<D>`

emitting `ConstEquate` during mir typeck is useful since it can help catch bugs in hir typeck incase our impl of `ConstEquate` is wrong.

doing this did actually catch a bug, when relating `Expr::Call` we `==` the types of all the argument consts which spuriously returns false if the type contains const projections/aliases which causes us to fall through to the `expected_found` error arm.
Generally its an ICE if the `Const`'s `Ty`s arent equal but `ConstKind::Expr` is kind of special since they are sort of like const items that are `const CALL<F: const Fn(...), const N: F>` though we dont actually explicitly represent the `F` type param explicitly in `Expr::Call` so I just made us relate the `Const`'s ty field to avoid getting ICEs from the tests I added and the following existing test:
```rust
// tests/ui/const-generics/generic_const_exprs/different-fn.rs
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

use std::mem::size_of;
use std::marker::PhantomData;

struct Foo<T>(PhantomData<T>);

fn test<T>() -> [u8; size_of::<T>()] {
    [0; size_of::<Foo<T>>()]
    //~^ ERROR unconstrained generic constant
    //~| ERROR mismatched types
}

fn main() {
    test::<u32>();
}
```
which has us relate two `ConstKind::Value` one for the fn item of `size_of::<Foo<T>>` and one for the fn item of `size_of::<T>()`, these only differ by their `Ty` and if we don't relate the `Ty` we'll end up getting an ICE from the checks that ensure the `ty` fields always match.

In theory `Expr::UnOp` has the same problem so I added a call to `relate` for the ty's, although I was unable to create a repro test.

15 months agoemit `ConstEquate` in `TypeRelating<D>`
Boxy [Sun, 29 Jan 2023 01:00:57 +0000 (01:00 +0000)]
emit `ConstEquate` in `TypeRelating<D>`

15 months agorustc_session: remove huge error imports
est31 [Sun, 5 Feb 2023 02:39:18 +0000 (03:39 +0100)]
rustc_session: remove huge error imports

15 months agorustc_parse: remove huge error imports
est31 [Sun, 5 Feb 2023 02:26:33 +0000 (03:26 +0100)]
rustc_parse: remove huge error imports

15 months agorustc_interface: remove huge error imports
est31 [Sun, 5 Feb 2023 02:20:06 +0000 (03:20 +0100)]
rustc_interface: remove huge error imports

15 months agorustc_passes: remove huge error imports
est31 [Sun, 5 Feb 2023 01:49:50 +0000 (02:49 +0100)]
rustc_passes: remove huge error imports

15 months agorustc_const_eval: remove huge error imports
est31 [Sun, 5 Feb 2023 01:09:56 +0000 (02:09 +0100)]
rustc_const_eval: remove huge error imports

15 months agorustc_metadata: remove huge error imports
est31 [Sun, 5 Feb 2023 00:58:22 +0000 (01:58 +0100)]
rustc_metadata: remove huge error imports

15 months agorustc_expand: remove huge error imports
est31 [Sun, 5 Feb 2023 00:07:25 +0000 (01:07 +0100)]
rustc_expand: remove huge error imports

15 months agoAuto merge of #107672 - matthiaskrgr:rollup-7e6dbuk, r=matthiaskrgr
bors [Sat, 4 Feb 2023 21:07:10 +0000 (21:07 +0000)]
Auto merge of #107672 - matthiaskrgr:rollup-7e6dbuk, r=matthiaskrgr

Rollup of 3 pull requests

Successful merges:

 - #107116 (consolidate bootstrap docs)
 - #107646 (Provide structured suggestion for binding needing type on E0594)
 - #107661 (Remove Esteban from review queues for a while)

Failed merges:

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

15 months agoRollup merge of #107661 - oli-obk:breathing_room, r=oli-obk
Matthias Krüger [Sat, 4 Feb 2023 19:29:07 +0000 (20:29 +0100)]
Rollup merge of #107661 - oli-obk:breathing_room, r=oli-obk

Remove Esteban from review queues for a while

r? `@estebank`

15 months agoRollup merge of #107646 - estebank:specific-span, r=compiler-errors
Matthias Krüger [Sat, 4 Feb 2023 19:29:06 +0000 (20:29 +0100)]
Rollup merge of #107646 - estebank:specific-span, r=compiler-errors

Provide structured suggestion for binding needing type on E0594

Partially address #45405.

15 months agoRollup merge of #107116 - ozkanonur:consolidate-bootstrap-docs, r=jyn514
Matthias Krüger [Sat, 4 Feb 2023 19:29:06 +0000 (20:29 +0100)]
Rollup merge of #107116 - ozkanonur:consolidate-bootstrap-docs, r=jyn514

consolidate bootstrap docs

With this diff, I tried to consolidate bootstrap documentations and remove the duplicated informations.

Coupled with https://github.com/rust-lang/rustc-dev-guide/pull/1563

Resolves #90686

Signed-off-by: ozkanonur <work@onurozkan.dev>
15 months agoAuto merge of #107549 - Zoxc:rustc-shared, r=jyn514
bors [Sat, 4 Feb 2023 18:11:02 +0000 (18:11 +0000)]
Auto merge of #107549 - Zoxc:rustc-shared, r=jyn514

Move code in `rustc_driver` out to a new `rustc_driver_impl` crate to allow pipelining

That adds a `rustc_shared` library which contains all the rustc library crates in a single dylib. It takes over this role from `rustc_driver`. This is done so that `rustc_driver` can be compiled in parallel with other crates. `rustc_shared` is intentionally left empty so it only does linking.

An alternative could be to move the code currently in `rustc_driver` into a new crate to avoid changing the name of the distributed library.

15 months agorustdoc: trait bound formatting
Roland Strasser [Sat, 26 Nov 2022 00:51:50 +0000 (01:51 +0100)]
rustdoc: trait bound formatting

rustdoc: fix item-spacer

rustdoc: use proper comment style

rustdoc: change formatting where clauses for traits

rustdoc: remove semicolon from provided methods

update provided methods formatting

15 months agoconsolidate bootstrap docs
ozkanonur [Fri, 20 Jan 2023 08:04:44 +0000 (11:04 +0300)]
consolidate bootstrap docs

Signed-off-by: ozkanonur <work@onurozkan.dev>
15 months agoSupport parallel compiler.
Camille GILLOT [Sat, 4 Feb 2023 15:56:21 +0000 (15:56 +0000)]
Support parallel compiler.

15 months agoRemove `OnHit` callback from query caches.
Camille GILLOT [Sat, 4 Feb 2023 15:16:59 +0000 (15:16 +0000)]
Remove `OnHit` callback from query caches.

This is not useful now that query results are `Copy`.

15 months agoAuto merge of #107267 - cjgillot:keep-aggregate, r=oli-obk
bors [Sat, 4 Feb 2023 15:17:32 +0000 (15:17 +0000)]
Auto merge of #107267 - cjgillot:keep-aggregate, r=oli-obk

Do not deaggregate MIR

This turns out to simplify a lot of things.
I haven't checked the consequences for miri yet.

cc `@JakobDegen`
r? `@oli-obk`

15 months agodon't point at nonexisting code beyond EOF when warning about unused delims
Matthias Krüger [Sat, 4 Feb 2023 12:27:53 +0000 (13:27 +0100)]
don't point at nonexisting code beyond EOF when warning about unused delims

Previously we would show this:
```
warning: unnecessary braces around block return value
 --> /tmp/bad.rs:1:8
  |
1 | fn a(){{{
  |        ^  ^
  |
  = note: `#[warn(unused_braces)]` on by default
help: remove these braces
  |
1 - fn a(){{{
1 + fn a(){{
  |
```

which is now hidden in this case.
We would create a span spanning between the pair of redundant {}s but there is only EOF instead of the `}` so we would previously point at nothing.
This would cause the debug assertion ice to trigger.
I would have loved to just only point at the second delim and say "you can remove that" but I'm not sure how to do that without refactoring the entire diagnostic which seems tricky. :(
But given that this does not seem to regress any other tests we have, I think this edge-casey enough be acceptable.

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

r? @compiler-errors

15 months agoRemove Esteban from review queues for a while
Oli Scherer [Sat, 4 Feb 2023 11:48:50 +0000 (11:48 +0000)]
Remove Esteban from review queues for a while

15 months agoAuto merge of #107618 - chriswailes:linker-arg, r=albertlarsan68
bors [Sat, 4 Feb 2023 11:22:31 +0000 (11:22 +0000)]
Auto merge of #107618 - chriswailes:linker-arg, r=albertlarsan68

Add a linker argument back to boostrap.py

In https://github.com/rust-lang/rust/pull/101783 I accidentally removed a load-bearing linker argument.  This PR adds it back in.

r? jyn514

15 months agoAuto merge of #107591 - krasimirgg:llvm-17-pgoopts, r=cuviper
bors [Sat, 4 Feb 2023 03:41:57 +0000 (03:41 +0000)]
Auto merge of #107591 - krasimirgg:llvm-17-pgoopts, r=cuviper

llvm-wrapper: adapt for LLVM API changes

Adapts the wrapper for https://github.com/llvm/llvm-project/commit/516e301752560311d2cd8c2b549493eb0f98d01b, where the constructor of PGOOptions gained a new FileSystem argument. Adapted to use the real file system, similarly to the changes inside of LLVM:
https://github.com/llvm/llvm-project/commit/516e301752560311d2cd8c2b549493eb0f98d01b#diff-f409934ba27ad86494f3012324e9a3995b56e0743609ded7a387ba62bbf5edb0R236

Found via our experimental Rust + LLVM at HEAD bot: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/16853#01860e2e-5eba-4f07-8359-0325913ff410/219-517

15 months agoreview comments
Esteban Küber [Fri, 3 Feb 2023 23:41:39 +0000 (23:41 +0000)]
review comments

15 months agoAuto merge of #107650 - compiler-errors:rollup-4pntchf, r=compiler-errors
bors [Fri, 3 Feb 2023 22:37:53 +0000 (22:37 +0000)]
Auto merge of #107650 - compiler-errors:rollup-4pntchf, r=compiler-errors

Rollup of 8 pull requests

Successful merges:

 - #106887 (Make const/fn return params more suggestable)
 - #107519 (Add type alias for raw OS errors)
 - #107551 ( Replace `ConstFnMutClosure` with const closures )
 - #107595 (Retry opening proc-macro DLLs a few times on Windows.)
 - #107615 (Replace nbsp in all rustdoc code blocks)
 - #107621 (Intern external constraints in new solver)
 - #107631 (loudly tell people when they change `Cargo.lock`)
 - #107632 (Clarifying that .map() returns None if None.)

Failed merges:

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

15 months agoRollup merge of #107632 - ameknite:issue-107622-fix, r=jyn514
Michael Goulet [Fri, 3 Feb 2023 22:15:24 +0000 (14:15 -0800)]
Rollup merge of #107632 - ameknite:issue-107622-fix, r=jyn514

Clarifying that .map() returns None if None.

Fix #107622

15 months agoRollup merge of #107631 - BoxyUwU:triagebot_cargo_lock, r=compiler-errors
Michael Goulet [Fri, 3 Feb 2023 22:15:24 +0000 (14:15 -0800)]
Rollup merge of #107631 - BoxyUwU:triagebot_cargo_lock, r=compiler-errors

loudly tell people when they change `Cargo.lock`

It keeps happening that people accidentally commit changes to `Cargo.lock` and then have to be told by a reviewer to undo this. I've also seen cases where PRs are merged that accidentally changed `Cargo.lock` during a rebase.. I figure that purposeful changes to `Cargo.lock` are likely rarer than these accidental ones?

15 months agoRollup merge of #107621 - compiler-errors:intern-external-constraints, r=lcnr
Michael Goulet [Fri, 3 Feb 2023 22:15:23 +0000 (14:15 -0800)]
Rollup merge of #107621 - compiler-errors:intern-external-constraints, r=lcnr

Intern external constraints in new solver

Makes the query response `Copy`, fixing a few FIXMEs.

15 months agoRollup merge of #107615 - notriddle:notriddle/nbsp, r=GuillaumeGomez
Michael Goulet [Fri, 3 Feb 2023 22:15:23 +0000 (14:15 -0800)]
Rollup merge of #107615 - notriddle:notriddle/nbsp, r=GuillaumeGomez

Replace nbsp in all rustdoc code blocks

Based on #106125 by `@dtolnay` — this PR fixes the line wrapping bug.

Fixes #106098. This makes code copyable from rustdoc rendered documentation into a Rust source file.

15 months agoRollup merge of #107595 - michaelwoerister:retry_proc_macro_loading, r=petrochenkov
Michael Goulet [Fri, 3 Feb 2023 22:15:22 +0000 (14:15 -0800)]
Rollup merge of #107595 - michaelwoerister:retry_proc_macro_loading, r=petrochenkov

Retry opening proc-macro DLLs a few times on Windows.

On Windows, the compiler [sometimes](https://users.rust-lang.org/t/error-loadlibraryexw-failed/77603) fails with the message `error: LoadLibraryExW failed` when trying to load a proc-macro crate. The error seems to occur intermittently, similar to https://github.com/rust-lang/rust/issues/86929, however, it seems to be almost impossible to reproduce outside of CI environments and thus very hard to debug. The fact that the error only occurs intermittently makes me think that this is a timing related issue.

This PR is an attempt to mitigate the issue by letting the compiler retry a few times when encountering this specific error (which resolved the issue described in https://github.com/rust-lang/rust/issues/86929).

15 months agoRollup merge of #107551 - fee1-dead-contrib:rm_const_fnmut_helper, r=oli-obk
Michael Goulet [Fri, 3 Feb 2023 22:15:22 +0000 (14:15 -0800)]
Rollup merge of #107551 - fee1-dead-contrib:rm_const_fnmut_helper, r=oli-obk

 Replace `ConstFnMutClosure` with const closures

Also fixes a parser bug. cc `@oli-obk` for compiler changes

15 months agoRollup merge of #107519 - joboet:raw_os_error_ty, r=Amanieu
Michael Goulet [Fri, 3 Feb 2023 22:15:21 +0000 (14:15 -0800)]
Rollup merge of #107519 - joboet:raw_os_error_ty, r=Amanieu

Add type alias for raw OS errors

Implement rust-lang/libs-team#173.

`@rustbot` label +S-waiting-on-ACP +T-libs-api

15 months agoRollup merge of #106887 - compiler-errors:suggest-types-more, r=oli-obk
Michael Goulet [Fri, 3 Feb 2023 22:15:21 +0000 (14:15 -0800)]
Rollup merge of #106887 - compiler-errors:suggest-types-more, r=oli-obk

Make const/fn return params more suggestable

Bumps const item type suggestions to MachineApplicable (fixes #106843), also replaces FnDef with FnPtr items in return type suggestions to make more things suggestable.

r? diagnostics

15 months agoMake const/fn return params more suggestable
Michael Goulet [Sat, 14 Jan 2023 22:55:27 +0000 (22:55 +0000)]
Make const/fn return params more suggestable

15 months agointern external constraints
Michael Goulet [Fri, 3 Feb 2023 02:29:52 +0000 (02:29 +0000)]
intern external constraints

15 months agonit fixed
Ame [Fri, 3 Feb 2023 17:41:59 +0000 (11:41 -0600)]
nit fixed

15 months agoClarifying that .map() returns None if None.
Ame [Fri, 3 Feb 2023 10:54:27 +0000 (04:54 -0600)]
Clarifying that .map() returns None if None.

15 months agoProvide structured suggestion for binding needing type on E0594
Esteban Küber [Fri, 3 Feb 2023 18:53:27 +0000 (18:53 +0000)]
Provide structured suggestion for binding needing type on E0594

Partially address #45405.

15 months agoAuto merge of #107642 - Dylan-DPC:rollup-edcqhm5, r=Dylan-DPC
bors [Fri, 3 Feb 2023 17:53:49 +0000 (17:53 +0000)]
Auto merge of #107642 - Dylan-DPC:rollup-edcqhm5, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #107082 (Autotrait bounds on dyn-safe trait methods)
 - #107427 (Add candidates for DiscriminantKind builtin)
 - #107539 (Emit warnings on unused parens in index expressions)
 - #107544 (Improve `TokenCursor`.)
 - #107585 (Don't cause a cycle when formatting query description that references a FnDef)
 - #107633 (Fix suggestion for coercing Option<&String> to Option<&str>)

Failed merges:

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

15 months agoRollup merge of #107633 - clubby789:option-string-coerce-fix, r=Nilstrieb
Dylan DPC [Fri, 3 Feb 2023 17:34:52 +0000 (23:04 +0530)]
Rollup merge of #107633 - clubby789:option-string-coerce-fix, r=Nilstrieb

Fix suggestion for coercing Option<&String> to Option<&str>

Fixes #107604

This also makes the diagnostic `MachineApplicable`, and runs `rustfix` to check we're not producing incorrect code.

``@rustbot`` label +A-diagnostics

15 months agoRollup merge of #107585 - compiler-errors:fndef-sig-cycle, r=oli-obk
Dylan DPC [Fri, 3 Feb 2023 17:34:52 +0000 (23:04 +0530)]
Rollup merge of #107585 - compiler-errors:fndef-sig-cycle, r=oli-obk

Don't cause a cycle when formatting query description that references a FnDef

When a function returns `-> _`, we use typeck to compute what the resulting type of the body _should_ be. If we call another query inside of typeck and hit a cycle error, we attempt to report the cycle error which requires us to compute all of the query descriptions for the stack.

However, if one of the queries in that cycle has a query description that references this function as a FnDef type, we'll cause a *second* cycle error from within the cycle error reporting code, since rendering a FnDef requires us to compute its signature. This causes an unwrap to ICE, since during the *second* cycle reporting code, we try to look for a job that isn't in the active jobs list.

We can avoid this by using `with_no_queries!` when computing these query descriptions.

Fixes #107089

The only drawback is that the rendering of opaque types in cycles regresses a bit :| I'm open to alternate suggestions about how we may handle this...

15 months agoRollup merge of #107544 - nnethercote:improve-TokenCursor, r=petrochenkov
Dylan DPC [Fri, 3 Feb 2023 17:34:51 +0000 (23:04 +0530)]
Rollup merge of #107544 - nnethercote:improve-TokenCursor, r=petrochenkov

Improve `TokenCursor`.

Some small improvements, for things that were bugging me.

Best reviewed one commit at a time.

r? ``@petrochenkov``

15 months agoRollup merge of #107539 - PossiblyAShrub:unused-parens-in-index, r=lcnr
Dylan DPC [Fri, 3 Feb 2023 17:34:51 +0000 (23:04 +0530)]
Rollup merge of #107539 - PossiblyAShrub:unused-parens-in-index, r=lcnr

Emit warnings on unused parens in index expressions

Fixes: #96606.
I am not sure what the best term for "index expression" is. Is there a better term we could use?

15 months agoRollup merge of #107427 - detrumi:builtin-impl-candidates, r=compiler-errors
Dylan DPC [Fri, 3 Feb 2023 17:34:50 +0000 (23:04 +0530)]
Rollup merge of #107427 - detrumi:builtin-impl-candidates, r=compiler-errors

Add candidates for DiscriminantKind builtin

Part of #107379

15 months agoRollup merge of #107082 - dtolnay:autotraits, r=lcnr
Dylan DPC [Fri, 3 Feb 2023 17:34:49 +0000 (23:04 +0530)]
Rollup merge of #107082 - dtolnay:autotraits, r=lcnr

Autotrait bounds on dyn-safe trait methods

This PR is a successor to #106604 implementing the approach encouraged by https://github.com/rust-lang/rust/pull/106604#issuecomment-1387353737.

**I propose making it legal to use autotraits as trait bounds on the `Self` type of trait methods in a trait object.** https://github.com/rust-lang/rust/issues/51443#issuecomment-1374847313 justifies why this use case is particularly important in the context of the async-trait crate.

```rust
#![feature(auto_traits)]
#![deny(where_clauses_object_safety)]

auto trait AutoTrait {}

trait MyTrait {
    fn f(&self) where Self: AutoTrait;
}

fn main() {
    let _: &dyn MyTrait;
}
```

Previously this would fail with:

```console
error: the trait `MyTrait` cannot be made into an object
 --> src/main.rs:7:8
  |
7 |     fn f(&self) where Self: AutoTrait;
  |        ^
  |
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
  = note: for more information, see issue #51443 <https://github.com/rust-lang/rust/issues/51443>
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
 --> src/main.rs:7:8
  |
6 | trait MyTrait {
  |       ------- this trait cannot be made into an object...
7 |     fn f(&self) where Self: AutoTrait;
  |        ^ ...because method `f` references the `Self` type in its `where` clause
  = help: consider moving `f` to another trait
```

In order for this to be sound without hitting #50781, **I further propose that we disallow handwritten autotrait impls that apply to trait objects.** Both of the following were previously allowed (_on nightly_) and no longer allowed in my proposal:

```rust
auto trait AutoTrait {}

trait MyTrait {}
impl AutoTrait for dyn MyTrait {}  // NOT ALLOWED

impl<T: ?Sized> AutoTrait for T {}  // NOT ALLOWED
```

(`impl<T> AutoTrait for T {}` remains allowed.)

After this change, traits with a default impl are implemented for a trait object **if and only if** the autotrait is one of the trait object's trait bounds (or a supertrait of a bound). In other words `dyn Trait + AutoTrait` always implements AutoTrait while `dyn Trait` never implements AutoTrait.

Fixes https://github.com/dtolnay/async-trait/issues/228.

r? `@lcnr`

15 months agoAutotrait bounds on dyn-safe trait methods
David Tolnay [Thu, 19 Jan 2023 09:24:45 +0000 (01:24 -0800)]
Autotrait bounds on dyn-safe trait methods

15 months agoDisallow impl autotrait for trait object
David Tolnay [Thu, 19 Jan 2023 06:43:05 +0000 (22:43 -0800)]
Disallow impl autotrait for trait object

15 months agoFix #103320, add explanatory message for [#must_use]
yukang [Sat, 29 Oct 2022 13:14:02 +0000 (21:14 +0800)]
Fix #103320, add explanatory message for [#must_use]

15 months agoReplace nbsp in all rustdoc code blocks
Michael Howell [Thu, 2 Feb 2023 22:10:41 +0000 (15:10 -0700)]
Replace nbsp in all rustdoc code blocks

Co-Authored-By: David Tolnay <dtolnay@gmail.com>
15 months agoReplace `ConstFnMutClosure` with const closures
Deadbeef [Wed, 1 Feb 2023 05:56:04 +0000 (05:56 +0000)]
Replace `ConstFnMutClosure` with const closures

15 months agoAuto merge of #107599 - clubby789:debug-less-ref, r=nnethercote
bors [Fri, 3 Feb 2023 14:22:42 +0000 (14:22 +0000)]
Auto merge of #107599 - clubby789:debug-less-ref, r=nnethercote

Don't generate unecessary `&&self.field` in deriving Debug

Since unsized fields may only be the last one in a struct, we only need to generate a double reference (`&&self.field`) for the  final one.

cc `@nnethercote`

15 months agoFix suggestion for coercing Option<&String> to Option<&str>
clubby789 [Fri, 3 Feb 2023 11:10:24 +0000 (11:10 +0000)]
Fix suggestion for coercing Option<&String> to Option<&str>

15 months agoAuto merge of #107569 - petrochenkov:optattr, r=nnethercote
bors [Fri, 3 Feb 2023 11:19:03 +0000 (11:19 +0000)]
Auto merge of #107569 - petrochenkov:optattr, r=nnethercote

ast: Optimize list and value extraction primitives for attributes

It's not necessary to convert the whole attribute into a meta item to extract something specific.

15 months agoloudly tell people when `Cargo.lock` changes
Boxy [Fri, 3 Feb 2023 10:42:37 +0000 (10:42 +0000)]
loudly tell people when `Cargo.lock` changes

15 months agoUse new helper inside probe
Wilco Kusee [Fri, 3 Feb 2023 09:04:15 +0000 (10:04 +0100)]
Use new helper inside probe

15 months agoAuto merge of #107625 - matthiaskrgr:rollup-xr9oldy, r=matthiaskrgr
bors [Fri, 3 Feb 2023 08:07:47 +0000 (08:07 +0000)]
Auto merge of #107625 - matthiaskrgr:rollup-xr9oldy, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #106575 (Suggest `move` in nested closure when appropriate)
 - #106805 (Suggest `{var:?}` when finding `{?:var}` in inline format strings)
 - #107500 (Add tests to assert current behavior of large future sizes)
 - #107598 (Fix benchmarks in library/core with black_box)
 - #107602 (Parse and recover from type ascription in patterns)
 - #107608 (Use triple rather than arch for fuchsia test-runner)

Failed merges:

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

15 months agoRollup merge of #107608 - P1n3appl3:master, r=tmandry
Matthias Krüger [Fri, 3 Feb 2023 05:30:25 +0000 (06:30 +0100)]
Rollup merge of #107608 - P1n3appl3:master, r=tmandry

Use triple rather than arch for fuchsia test-runner

This allows the user of the test-runner script to specify a full triple rather than just an architecture which helps with the transition from the two component to three component target triples for fuchsia.

15 months agoRollup merge of #107602 - estebank:anon-enum-access, r=compiler-errors
Matthias Krüger [Fri, 3 Feb 2023 05:30:24 +0000 (06:30 +0100)]
Rollup merge of #107602 - estebank:anon-enum-access, r=compiler-errors

Parse and recover from type ascription in patterns

Reintroduce part of #106960, which was reverted in #107478.

r? `@compiler-errors`

15 months agoRollup merge of #107598 - chenyukang:yukang/fix-core-bench, r=thomcc
Matthias Krüger [Fri, 3 Feb 2023 05:30:24 +0000 (06:30 +0100)]
Rollup merge of #107598 - chenyukang:yukang/fix-core-bench, r=thomcc

Fix benchmarks in library/core with black_box

Fixes #107590

15 months agoRollup merge of #107500 - bryangarza:future-sizes-baseline-test, r=compiler-errors
Matthias Krüger [Fri, 3 Feb 2023 05:30:23 +0000 (06:30 +0100)]
Rollup merge of #107500 - bryangarza:future-sizes-baseline-test, r=compiler-errors

Add tests to assert current behavior of large future sizes

Based on a couple of sources:
- https://swatinem.de/blog/future-size/
- https://github.com/rust-lang/rust/issues/62958

15 months agoRollup merge of #106805 - madsravn:master, r=compiler-errors
Matthias Krüger [Fri, 3 Feb 2023 05:30:23 +0000 (06:30 +0100)]
Rollup merge of #106805 - madsravn:master, r=compiler-errors

Suggest `{var:?}` when finding `{?:var}` in inline format strings

Link to issue: https://github.com/rust-lang/rust/issues/106572

This is my first PR to this project, so hopefully I can get some good pointers with me from the first PR.

Currently my idea was to test out whether or not this is the correct solution to this issue and then hopefully expand upon the idea to not only work for Debug formatting but for all of  them. If this is a valid solution, I will create a new issue to give a better error message to a broader range of wrong-order formatting.

15 months agoRollup merge of #106575 - estebank:issue-64008, r=pnkfelix
Matthias Krüger [Fri, 3 Feb 2023 05:30:22 +0000 (06:30 +0100)]
Rollup merge of #106575 - estebank:issue-64008, r=pnkfelix

Suggest `move` in nested closure when appropriate

Fix #64008.

15 months agoAuto merge of #107543 - ehuss:protocol-sparse, r=jyn514
bors [Fri, 3 Feb 2023 04:49:50 +0000 (04:49 +0000)]
Auto merge of #107543 - ehuss:protocol-sparse, r=jyn514

Enable Cargo's sparse protocol in CI

This enables the sparse protocol in CI in order to exercise and dogfood it. This is intended test the production server in a real-world situation.

Closes #107342

15 months agoAuto merge of #107241 - clubby789:bootstrap-lto-off, r=simulacrum
bors [Fri, 3 Feb 2023 01:19:04 +0000 (01:19 +0000)]
Auto merge of #107241 - clubby789:bootstrap-lto-off, r=simulacrum

Add `rust.lto=off` to bootstrap and set as compiler/library default

Closes #107202

The issue mentions `embed-bitcode=on`, but here https://github.com/rust-lang/rust/blob/c8e6a9e8b6251bbc8276cb78cabe1998deecbed7/src/bootstrap/compile.rs#L379-L381
it appears that this is always set for std stage 1+, so I'm unsure if changes are needed here.

`@rustbot` label +A-bootstrap

15 months agoAdd a linker argument back to boostrap.py
Chris Wailes [Fri, 3 Feb 2023 00:10:43 +0000 (16:10 -0800)]
Add a linker argument back to boostrap.py

In https://github.com/rust-lang/rust/pull/101783 I accidentally removed
a load-bearing linker argument.  This PR adds it back in.

15 months agoBless 32bit.
Camille GILLOT [Wed, 1 Feb 2023 19:08:53 +0000 (19:08 +0000)]
Bless 32bit.

15 months agoIntroduce write_aggregate.
Camille GILLOT [Wed, 1 Feb 2023 18:59:27 +0000 (18:59 +0000)]
Introduce write_aggregate.

15 months agoAdd partial propagation test.
Camille GILLOT [Sun, 29 Jan 2023 12:50:27 +0000 (12:50 +0000)]
Add partial propagation test.

15 months agoBless tests.
Camille GILLOT [Wed, 25 Jan 2023 18:34:35 +0000 (18:34 +0000)]
Bless tests.

15 months agoStop deaggegating MIR.
Camille GILLOT [Wed, 25 Jan 2023 18:34:19 +0000 (18:34 +0000)]
Stop deaggegating MIR.

15 months agoStop deaggregating enums in MIR.
Camille GILLOT [Wed, 25 Jan 2023 18:34:19 +0000 (18:34 +0000)]
Stop deaggregating enums in MIR.

15 months agoHandle aggregates in DataflowConstProp.
Camille GILLOT [Tue, 24 Jan 2023 17:43:07 +0000 (17:43 +0000)]
Handle aggregates in DataflowConstProp.

15 months agoCodegen SetDiscriminant after field assignment.
Camille GILLOT [Sun, 29 Jan 2023 13:00:32 +0000 (13:00 +0000)]
Codegen SetDiscriminant after field assignment.

This matches the order in which deaggregation was performed.

15 months agoInterpret aggregates.
Camille GILLOT [Mon, 23 Jan 2023 22:15:55 +0000 (22:15 +0000)]
Interpret aggregates.

15 months agoPut a DefId in AggregateKind.
Camille GILLOT [Mon, 23 Jan 2023 22:15:33 +0000 (22:15 +0000)]
Put a DefId in AggregateKind.

15 months agoRename `Cursor`/`CursorRef` as `TokenTreeCursor`/`RefTokenTreeCursor`.
Nicholas Nethercote [Wed, 1 Feb 2023 01:58:04 +0000 (12:58 +1100)]
Rename `Cursor`/`CursorRef` as `TokenTreeCursor`/`RefTokenTreeCursor`.

This makes it clear they return token trees, and makes for a nice
comparison against `TokenCursor` which returns tokens.

15 months agoRemove `TokenCursorFrame`.
Nicholas Nethercote [Wed, 1 Feb 2023 01:43:13 +0000 (12:43 +1100)]
Remove `TokenCursorFrame`.

The motivation here is to eliminate the `Option<(Delimiter,
DelimSpan)>`, which is `None` for the outermost token stream and `Some`
for all other token streams.

We are already treating the innermost frame specially -- this is the
`frame` vs `stack` distinction in `TokenCursor`. We can push that
further so that `frame` only contains the cursor, and `stack` elements
contain the delimiters for their children. When we are in the outermost
token stream `stack` is empty, so there are no stored delimiters, which
is what we want because the outermost token stream *has* no delimiters.

This change also shrinks `TokenCursor`, which shrinks `Parser` and
`LazyAttrTokenStreamImpl`, which is nice.

15 months agoMake clear that `TokenTree::Token` shouldn't contain a delimiter.
Nicholas Nethercote [Wed, 1 Feb 2023 00:21:28 +0000 (11:21 +1100)]
Make clear that `TokenTree::Token` shouldn't contain a delimiter.

15 months agoImprove doc comment desugaring.
Nicholas Nethercote [Tue, 31 Jan 2023 23:53:00 +0000 (10:53 +1100)]
Improve doc comment desugaring.

Sometimes the parser needs to desugar a doc comment into `#[doc =
r"foo"]`. Currently it does this in a hacky way: by pushing a "fake" new
frame (one without a delimiter) onto the `TokenCursor` stack.

This commit changes things so that the token stream itself is modified
in place. The nice thing about this is that it means
`TokenCursorFrame::delim_sp` is now only `None` for the outermost frame.

15 months agoTweak misleading comment
Michael Goulet [Thu, 2 Feb 2023 23:02:21 +0000 (15:02 -0800)]
Tweak misleading comment

15 months agoDon't generate unecessary `&&self.field` in deriving Debug
clubby789 [Thu, 2 Feb 2023 15:39:00 +0000 (15:39 +0000)]
Don't generate unecessary `&&self.field` in deriving Debug

15 months agoUse triple rather than arch for fuchsia test runner
Joseph Ryan [Thu, 2 Feb 2023 19:23:48 +0000 (11:23 -0800)]
Use triple rather than arch for fuchsia test runner