Commit Graph

220378 Commits

Author SHA1 Message Date
Dylan DPC
70918ecf06
Rollup merge of #109280 - compiler-errors:no-vec-map, r=Mark-Simulacrum
Remove `VecMap`

Not sure what the use of this data structure is over just using `FxIndexMap` or a `Vec`.

r? ```@ghost```
2023-03-23 00:00:32 +05:30
Dylan DPC
d8543abc55
Rollup merge of #109187 - clubby789:askama-source, r=GuillaumeGomez
Render source page layout with Askama

~~I was looking at making `code_html` render into the buffer instead of in advance, but it turned out to need a pretty big refactor, so starting with rearranging the high-level layout.~~
Found another approach which required much less changes

cc #108868
2023-03-23 00:00:32 +05:30
Dylan DPC
14d06467f0
Rollup merge of #109179 - llogiq:intrinsically-option-as-slice, r=eholk
move Option::as_slice to intrinsic

````@scottmcm```` suggested on #109095 I use a direct approach of unpacking the operation in MIR lowering, so here's the implementation.

cc ````@nikic```` as this should hopefully unblock #107224 (though perhaps other changes to the prior implementation, which I left for bootstrapping, are needed).
2023-03-23 00:00:31 +05:30
Dylan DPC
59d9cbfa14
Rollup merge of #108997 - tgross35:patch-1, r=JohnTitor
Change text -> rust highlighting in sanitizer.md

Not sure why this has syntax highlighting turned off, but it doesn't need to be

Relevant page: https://doc.rust-lang.org/beta/unstable-book/compiler-flags/sanitizer.html
2023-03-23 00:00:30 +05:30
Dylan DPC
d694f47baa
Rollup merge of #100311 - xfix:lines-fix-handling-of-bare-cr, r=ChrisDenton
Fix handling of trailing bare CR in str::lines

Continuing from #91191.

Fixes #94435.
2023-03-23 00:00:30 +05:30
bors
439292bc79 Auto merge of #109163 - hi-rustin:rustin-patch-dockerfile, r=Mark-Simulacrum
Add RANLIB_x86_64_unknown_illumos env for dist-x86_64-illumos dockerfile

close https://github.com/rust-lang/cc-rs/issues/798

We already set `AR_x86_64_unknown_illumos` in the dockerfile. So it is reasonable to set the `RANLIB_x86_64_unknown_illumos`.
2023-03-22 11:45:52 +00:00
bors
6502613a81 Auto merge of #109073 - michaelwoerister:limit-mingw-llvm-link-jobs, r=Mark-Simulacrum
Limit the number of parallel link jobs during LLVM build for mingw.

This PR is an attempt to unblock https://github.com/rust-lang/rust/pull/108355, which keeps failing while trying to link various LLVM artifacts on mingw runners. It looks like doing too many linking jobs might put too much load on the system? (Although I don't understand why the jobs are only failing for #108355 while they seem to pass for others)

r? infra-ci
2023-03-22 09:15:00 +00:00
bors
9bdb4881c7 Auto merge of #109119 - lcnr:trait-system-cleanup, r=compiler-errors
a general type system cleanup

removes the helper functions `traits::fully_solve_X` as they add more complexity then they are worth. It's confusing which of these helpers should be used in which context.

changes the way we deal with overflow to always add depth in `evaluate_predicates_recursively`. It may make sense to actually fully transition to not have `recursion_depth` on obligations but that's probably a bit too much for this PR.

also removes some other small - and imo unnecessary - helpers.

r? types
2023-03-22 05:33:18 +00:00
Trevor Gross
df034b06b7 Change text -> rust,ignore highlighting in sanitizer.md
Marked ignore due to difficulty getting doctests to pass cross-platform
2023-03-22 01:11:39 -04:00
bors
5fa73a75ce Auto merge of #109087 - cjgillot:sparse-bb-clear, r=davidtwco
Only clear written-to locals in ConstProp

This aims to revert the regression in https://github.com/rust-lang/rust/pull/108872

Clearing all locals at the end of each bb is very costly.
This PR goes back to the original implementation of recording which locals are modified.
2023-03-22 02:49:04 +00:00
bors
6dc3999c26 Auto merge of #109463 - weihanglo:update-cargo, r=weihanglo
Update cargo

11 commits in 4a3c588b1f0a8e2dc8dd8789dbf3b6a71b02ed49..15d090969743630bff549a1b068bcaa8174e5ee3
2023-03-14 14:05:36 +0000 to 2023-03-21 17:54:28 +0000
- docs(contrib): Move higher level resolver docs into doc comments (rust-lang/cargo#11870)
- docs(contrib): Pull impl info out of architecture (rust-lang/cargo#11869)
- Update curl-sys (rust-lang/cargo#11871)
- Poll loop fixes (rust-lang/cargo#11624)
- clippy: warn `disallowed_methods` for `std::env::var` and friends (rust-lang/cargo#11828)
- Add --ignore-rust-version flag to cargo install (rust-lang/cargo#11859)
- Handle case mismatches when looking up env vars in the Config snapshot (rust-lang/cargo#11824)
- align semantics of generated vcs ignore files (rust-lang/cargo#11855)
- Add more information to wait-for-publish (rust-lang/cargo#11713)
- docs: Address warnings (rust-lang/cargo#11856)
- docs(contrib): Create a file overview in the nightly docs (rust-lang/cargo#11850)
2023-03-22 00:18:44 +00:00
Weihang Lo
30cef3a292
Update cargo 2023-03-22 07:22:51 +08:00
bors
1db9c061d3 Auto merge of #109453 - matthiaskrgr:rollup-odn02wu, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #96391 (Windows: make `Command` prefer non-verbatim paths)
 - #108164 (Drop all messages in bounded channel when destroying the last receiver)
 - #108729 (fix: modify the condition that `resolve_imports` stops)
 - #109336 (Constrain const vars to error if const types are mismatched)
 - #109403 (Avoid ICE of attempt to add with overflow in emitter)
 - #109415 (Refactor `handle_missing_lit`.)
 - #109441 (Only implement Fn* traits for extern "Rust" safe function pointers and items)
 - #109446 (Do not suggest bounds restrictions for synthesized RPITITs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-21 20:56:38 +00:00
bors
77d50a8870 Auto merge of #109092 - compiler-errors:local-key, r=cjgillot
Make local query providers receive local keys

When a query is marked `separate_provide_extern`, we can map a query key to a "local" form of the key, e.g. `DefId` -> `LocalDefId`. This simplifies a ton of code which either has to assert or use something like `expect_local` to assert that the query key is local.
2023-03-21 18:24:44 +00:00
Matthias Krüger
94d2028abd
Rollup merge of #109446 - spastorino:new-rpitit-17, r=compiler-errors
Do not suggest bounds restrictions for synthesized RPITITs

Before this PR we were getting ...

```
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
 --> tests/ui/async-await/in-trait/missing-send-bound.rs:5:12
  |
5 | #![feature(async_fn_in_trait)]
  |            ^^^^^^^^^^^^^^^^^
  |
  = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
  = note: `#[warn(incomplete_features)]` on by default

error: future cannot be sent between threads safely
  --> tests/ui/async-await/in-trait/missing-send-bound.rs:17:20
   |
17 |     assert_is_send(test::<T>());
   |                    ^^^^^^^^^^^ future returned by `test` is not `Send`
   |
   = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `impl Future<Output = ()>`
note: future is not `Send` as it awaits another future which is not `Send`
  --> tests/ui/async-await/in-trait/missing-send-bound.rs:13:5
   |
13 |     T::bar().await;
   |     ^^^^^^^^ await occurs here on type `impl Future<Output = ()>`, which is not `Send`
note: required by a bound in `assert_is_send`
  --> tests/ui/async-await/in-trait/missing-send-bound.rs:21:27
   |
21 | fn assert_is_send(_: impl Send) {}
   |                           ^^^^ required by this bound in `assert_is_send`
help: consider further restricting the associated type
   |
16 | fn test2<T: Foo>() where impl Future<Output = ()>: Send {
   |                    ++++++++++++++++++++++++++++++++++++

error: aborting due to previous error; 1 warning emitted
```

and we want this output ...

```
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
  --> $DIR/missing-send-bound.rs:5:12
   |
LL | #![feature(async_fn_in_trait)]
   |            ^^^^^^^^^^^^^^^^^
   |
   = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
   = note: `#[warn(incomplete_features)]` on by default

error: future cannot be sent between threads safely
  --> $DIR/missing-send-bound.rs:17:20
   |
LL |     assert_is_send(test::<T>());
   |                    ^^^^^^^^^^^ future returned by `test` is not `Send`
   |
   = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `impl Future<Output = ()>`
note: future is not `Send` as it awaits another future which is not `Send`
  --> $DIR/missing-send-bound.rs:13:5
   |
LL |     T::bar().await;
   |     ^^^^^^^^ await occurs here on type `impl Future<Output = ()>`, which is not `Send`
note: required by a bound in `assert_is_send`
  --> $DIR/missing-send-bound.rs:21:27
   |
LL | fn assert_is_send(_: impl Send) {}
   |                           ^^^^ required by this bound in `assert_is_send`

error: aborting due to previous error; 1 warning emitted
```

r? `@compiler-errors`
2023-03-21 19:00:15 +01:00
Matthias Krüger
fef1fc4349
Rollup merge of #109441 - oli-obk:fn_trait_new_solver, r=compiler-errors
Only implement Fn* traits for extern "Rust" safe function pointers and items

Since calling the function via an `Fn` trait will assume `extern "Rust"` ABI and not do any safety checks, only safe `extern "Rust"` function can implement the `Fn` traits. This syncs the logic between the old solver and the new solver.

r? `@compiler-errors`
2023-03-21 19:00:14 +01:00
Matthias Krüger
96f35ed720
Rollup merge of #109415 - nnethercote:refactor-handle_missing_lit, r=petrochenkov
Refactor `handle_missing_lit`.

A small code readability improvement.

r? ```@petrochenkov```
2023-03-21 19:00:14 +01:00
Matthias Krüger
25b062d586
Rollup merge of #109403 - chenyukang:yukang/fix-109396, r=estebank
Avoid ICE of attempt to add with overflow in emitter

Fixes #109396
r? ```@estebank```
2023-03-21 19:00:13 +01:00
Matthias Krüger
081c607b0a
Rollup merge of #109336 - compiler-errors:constrain-to-ct-err, r=BoxyUwU
Constrain const vars to error if const types are mismatched

When equating two consts of different types, if either are const variables, constrain them to the correct const error kind.

This helps us avoid "successfully" matching a const against an impl signature but leaving unconstrained const vars, which will lead to incremental ICEs when we call const-eval queries during const projection.

Fixes #109296

The second commit in the stack fixes a regression in the first commit where we end up mentioning `[const error]` in an impl overlap error message. I think the error message changes for the better, but I could implement alternative strategies to avoid this without delaying the overlap error message...

r? `@BoxyUwU`
2023-03-21 19:00:12 +01:00
Matthias Krüger
ee330a3ff5
Rollup merge of #108729 - bvanjoi:fix-issue-97534, r=petrochenkov
fix: modify the condition that `resolve_imports` stops

close #97534
2023-03-21 19:00:12 +01:00
Matthias Krüger
93a82a44a1
Rollup merge of #108164 - joboet:discard_messages_mpmc_array, r=Amanieu
Drop all messages in bounded channel when destroying the last receiver

Fixes #107466 by splitting the `disconnect` function for receivers/transmitters and dropping all messages in `disconnect_receivers` like the unbounded channel does. Since all receivers must be dropped before the channel is, the messages will already be discarded at that point, so the `Drop` implementation for the channel can be removed.

``@rustbot`` label +T-libs +A-concurrency
2023-03-21 19:00:11 +01:00
Matthias Krüger
1a43859a74
Rollup merge of #96391 - ChrisDenton:command-non-verbatim, r=joshtriplett
Windows: make `Command` prefer non-verbatim paths

When spawning Commands, the path we use can end up being queried using `env::current_exe` (or the equivalent in other languages). Not all applications handle these paths properly therefore we should have a stronger preference for non-verbatim paths when spawning processes.
2023-03-21 19:00:10 +01:00
clubby789
4212c1b067 Add safe to number rendering 2023-03-21 17:51:21 +00:00
Santiago Pastorino
3b04ad2753
Do not suggest bounds restrictions for synthesized RPITITs 2023-03-21 13:18:32 -03:00
Michael Goulet
b1a957b0b9 query_keys_local is conditional on separate_provide_if_extern 2023-03-21 15:38:52 +00:00
Michael Goulet
d213114cb5 LocalCrate key 2023-03-21 15:38:52 +00:00
Michael Goulet
dcaf956de0 AsLocalKey trait 2023-03-21 15:38:52 +00:00
Michael Goulet
7e6506764b IdentitySubsts::identity_for_item takes Into<DefId> 2023-03-21 15:38:52 +00:00
Michael Goulet
979ef5981f Use LocalDefId in ItemCtxt 2023-03-21 15:38:52 +00:00
Michael Goulet
2eb1c08e43 Use local key in providers 2023-03-21 15:38:51 +00:00
bors
66676820eb Auto merge of #108659 - ferrocene:pa-test-metrics, r=Mark-Simulacrum
Include executed tests in the build metrics (and use a custom test display impl)

The main goal of this PR is to include all tests executed in CI inside the build metrics JSON files. I need this for Ferrocene, and `@Mark-Simulacrum` expressed desire to have this as well to ensure all tests are executed at least once somewhere in CI.

Unfortunately implementing this required rewriting inside of bootstrap all of the code to render the test output to console. libtest supports outputting JSON instead of raw text, which we can indeed use to populate the build metrics. Doing that suppresses the console output though, and compared to rustc and Cargo the console output is not included as a JSON field.

Because of that, this PR had to reimplement both the "pretty" format (one test per line, with `rust.verbose-tests = true`), and the "terse" format (the wall of dots, with `rust.verbose-tests = false`). The current implementation should have the exact same output as libtest, except for the benchmark output. libtest's benchmark output is broken in the "terse" format, so since that's our default I slightly improved how it's rendered.

Also, to bring parity with libtest I had to introduce support for coloring output from bootstrap, using the same dependencies `annotate-snippets` uses. It's now possible to use `builder.color_for_stdout(Color::Red, "text")` and `builder.color_for_stderr(Color::Green, "text")` across all of bootstrap, automatically respecting the `--color` flag and whether the stream is a terminal or not.

I recommend reviewing the PR commit-by-commit.
r? `@Mark-Simulacrum`
2023-03-21 14:33:14 +00:00
Pietro Albini
aacbd8671b
handle tests timing out 2023-03-21 15:07:05 +01:00
bors
a01b4cc9f3 Auto merge of #109442 - Nilstrieb:rollup-seb5xsa, r=Nilstrieb
Rollup of 10 pull requests

Successful merges:

 - #106434 (Document `Iterator::sum/product` for Option/Result)
 - #108326 (Implement read_buf for a few more types)
 - #108842 (Enforce non-lifetime-binders in supertrait preds are not object safe)
 - #108896 (new solver: make all goal evaluation able to be automatically rerun )
 - #109124 (Add `dist.compression-profile` option to control compression speed)
 - #109240 (Walk un-shifted nested `impl Trait` in trait when setting up default trait method assumptions)
 - #109385 (fix typo)
 - #109386 (add myself to mailmap)
 - #109390 (Custom MIR: Support aggregate expressions)
 - #109408 (not *all* retags might be explicit in Runtime MIR)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-21 12:06:26 +00:00
nils
925fbcdf8a
Rollup merge of #109408 - RalfJung:retags, r=compiler-errors
not *all* retags might be explicit in Runtime MIR

In https://github.com/rust-lang/rust/pull/105317 I made Miri treat `Rvalue::Ref/AddrOf` as implicit retagging sites. This updates the MIR docs accordingly.

For `Rvalue::Ref` I think this makes a lot more sense: creating a new reference is their entire point, so we can avoid bloating the MIR with retags. Also this seems to be the best way to handle cases like `*ptr = &[mut] ...`, where doing a retag is somewhat questionable since maybe `*ptr` points to another place now?

For `Rvalue::AddrOf`, Stacked Borrows needs this because even raw ptrs need some retagging, but Tree Borrows doesn't do ant retagging here and I hope we'll end up with a model where raw pointers don't get retagged.
2023-03-21 13:00:25 +01:00
nils
b2e48edded
Rollup merge of #109390 - cbeuw:aggregate-lit, r=oli-obk
Custom MIR: Support aggregate expressions

Add support for tuple, array and ADT expressions in custom mir

r? `````@oli-obk````` or `````@tmiasko````` or `````@JakobDegen`````
2023-03-21 13:00:25 +01:00
nils
15000ec607
Rollup merge of #109386 - aDotInTheVoid:mailmap, r=WaffleLapkin
add myself to mailmap

CC https://github.com/rust-lang/team/pull/951
2023-03-21 13:00:24 +01:00
nils
c0adce567e
Rollup merge of #109385 - lcnr:typo, r=Dylan-DPC
fix typo
2023-03-21 13:00:24 +01:00
nils
66ba60a445
Rollup merge of #109240 - compiler-errors:dont-binder-twice, r=oli-obk
Walk un-shifted nested `impl Trait` in trait when setting up default trait method assumptions

Fixes a double subtraction in some binder math in return-position `impl Trait` in trait handling code.

Fixes #109239
2023-03-21 13:00:23 +01:00
nils
09b1254eb2
Rollup merge of #109124 - ferrocene:pa-compression-mode, r=Mark-Simulacrum
Add `dist.compression-profile` option to control compression speed

PR #108534 reduced the size of compressed archives, but (as expected) it also resulted in way longer compression times and memory usage during compression.

It's desirable to keep status quo (smaller archives but more CI usage), but it should also be configurable so that downstream users don't have to waste that much time on CI. As a data point, this resulted in doubling the time of Ferrocene's dist jobs, and required us to increase the RAM allocation for one of such jobs.

This PR adds a new `config.toml` setting, `dist.compression-profile`. The values can be:

* `fast`: equivalent to the gzip and xz preset of "1"
* `balanced`: equivalent to the gzip and xz preset of "6" (the CLI defaults as far as I'm aware)
* `best`: equivalent to the gzip present of "9", and our custom xz profile

The default has also been moved back to `balanced`, to try and avoid the compression time regression for downstream users. I don't feel too strongly on the default, and I'm open to changing it.

Also, for the `best` profile the XZ settings do not match the "9" preset used by the CLI, and it might be confusing. Should we create a `custom-rustc-ci`/`ultra` profile for that?

r? ``@Mark-Simulacrum``
2023-03-21 13:00:23 +01:00
nils
e79b182fca
Rollup merge of #108896 - BoxyUwU:new_solver_add_goal_fn, r=lcnr
new solver: make all goal evaluation able to be automatically rerun

It is generally wrong to call `evaluate_goal` multiple times or `evaluate_goal` and `evaluate_all` for the same `QueryResult` without correctly handling rerunning the goals when inference makes progress. Not doing so will result in the assertion in `evaluate_goal` firing because rerunning the goal will lead to a more accurate `QueryResult`.

Currently there are lots of places that get this wrong and generally it is complex and error prone to handle correctly everywhere. This PR introduces a way to add goals to the `EvalCtxt` and then run all the added goals in a loop so that `evaluate_goal`/`evaluate_all` is not necessary to call manually.

There are a few complications for making everything work "right":
1. the `normalizes-to` hack that replaces the rhs with an unconstrained infer var requires special casing in the new `try_evaluate_added_goals` function similar to how `evaluate_goal`'s assertion special cases that hack.

2. `assemble_candidates_after_normalizing_self_ty`'s normalization step needs to be reran for each candidate otherwise the found candidates will potentially get a more accurate `QueryResult` when rerunning the projection/trait goal which can effect the `QueryResult` of the projection/trait goal.
This is implemented via `EvalCtxt::probe`'s closure's `EvalCtxt` inheriting the added goals of the `EvalCtxt` that `probe` is called on, allowing us to add goals in a probe, and then enter a nested probe for each candidate and evaluate added goals which include the normalization step's goals.

I made `make_canonical_response` evaluate added goals so that it will be hard to mess up the impl of the solver by forgetting to evaluate added goals. Right now the only way to mess this up would be to call `response_no_constraints` (which from the name is obviously weird).

The visibility of `evaluate_goal` means that it can be called from various `compute_x_goal` or candidate assembly functions, this is generally wrong and we should never call `evaluate_goal` manually, instead we should be calling `add_goal`/`add_goals`. This is solved by moving `evaluate_goal` `evaluate_canonical_goal` and `compute_goal` into `eval_ctxt`'s module and making them private so they cannot be called from elsewhere, forcing people to call `add_goal/s` and `evaluate_added_goals_and_make_canonical_resposne`/`try_evaluate_added_goals`

---

Other changes:
- removed the `&& false` that was introduced to the assertion in `evaluate_goal` in #108839
- remove a `!self.did_overflow()` requirement in `search_graph.is_empty()` which causes goals that overflow to ICE
- made `EvalCtxt::eq` take `&mut self` and add all the nested goals via `add_goals` instead of returning them as 99% of call sites just immediately called `EvalCtxt::add_goals` manually.

r? `````@lcnr`````
2023-03-21 13:00:22 +01:00
nils
0ef4da126a
Rollup merge of #108842 - compiler-errors:non_lifetime_binders-object-safe, r=b-naber
Enforce non-lifetime-binders in supertrait preds are not object safe

We can't construct vtables for these supertraits.
2023-03-21 13:00:22 +01:00
nils
82dc127d7b
Rollup merge of #108326 - tmiasko:read-buf, r=thomcc
Implement read_buf for a few more types

Implement read_buf for TcpStream, Stdin, StdinLock, ChildStdout,
ChildStderr (and internally for AnonPipe, Handle, Socket), so
that it skips buffer initialization.

The other provided methods like read_to_string and read_to_end are
implemented in terms of read_buf and so benefit from the optimization
as well.

This commit also implements read_vectored and is_read_vectored where
applicable.
2023-03-21 13:00:21 +01:00
nils
caae551ecb
Rollup merge of #106434 - clubby789:document-sum-result, r=the8472
Document `Iterator::sum/product` for Option/Result

Closes #105266

We already document the similar behavior for `collect()` so I believe it makes sense to add this too. The Option/Result implementations *are* documented on their respective pages and the page for `Sum`, but buried amongst many other trait impls which doesn't make it very discoverable.

`````@rustbot````` label +A-docs
2023-03-21 13:00:21 +01:00
Oli Scherer
a00413f680 Also check function items' signatures for Fn* trait compatibility 2023-03-21 11:50:14 +00:00
Oli Scherer
91d913168c Deduplicate fn trait compatibility checks 2023-03-21 11:38:13 +00:00
Oli Scherer
fb9e171ab7 Only implement Fn* traits for extern "Rust" safe function pointers. 2023-03-21 11:11:32 +00:00
lcnr
b8541eb767 use the correct param env 2023-03-21 09:57:22 +01:00
lcnr
c63861b9d5 evaluate: improve and fix recursion depth handling 2023-03-21 09:57:22 +01:00
lcnr
791ce0b7b5 remove some trait solver helpers
they add more complexity then they are worth. It's confusing
which of these helpers should be used in which context.
2023-03-21 09:57:20 +01:00
Pietro Albini
01771762cd
change default to fast for everyone but the user profile 2023-03-21 09:44:42 +01:00