Commit graph

218573 commits

Author SHA1 Message Date
Matthias Krüger db4b3dd608
Rollup merge of #108667 - compiler-errors:issue-108664, r=estebank
Fix another ICE in `point_at_expr_source_of_inferred_type`

Types coming from method probes must only be investigated *structurally*, since they often contain escaping infer variables from generalization and autoderef. We already have a hack in this PR that erases variables from types, so just use that.

Fixes #108664

The note attached to this error is pretty bad:

```
here the type of `primes` is inferred to be `[_]`
```

But that's unrelated to the PR.

---

Side-note: This is a pretty easy to trigger beta regression, so I've nominated it. Alternatively, I'm slightly inclined to remove this code altogether until it can be reformulated to be more accurate and less ICEy.
2023-03-03 20:06:28 +01:00
Matthias Krüger 1fab0fc4a2
Rollup merge of #108599 - nikic:drop-init, r=cuviper
Remove legacy PM leftovers

This drops two leftovers of legacy PM usage:
 * We don't need to initialize passes anymore.
 * The pass listing was still using legacy PM passes. Replace it with the corresponding new PM listing.
2023-03-03 20:06:27 +01:00
Matthias Krüger 44e794f8ab
Rollup merge of #108553 - compiler-errors:non-lt-late-bound-in-anon-ct, r=petrochenkov
Deny capturing late-bound non-lifetime param in anon const

Introduce a new AnonConstBoundary so we can detect when we capture a late-bound non-lifetime param with `non_lifetime_binders` enabled.

In the future, we could technically do something like introduce an early-bound parameter on the anon const, and stick the late-bound param in its substs (kinda like how we turn late-bound lifetimes in opaques into early-bound ones). But for now, just deny it so we don't ICE.

Fixes #108191
2023-03-03 20:06:27 +01:00
Matthias Krüger 4f49352e92
Rollup merge of #107981 - lcnr:canonicalization-uwu, r=compiler-errors
new solver: implement canonicalization and region constraints

see the corresponding rustc-dev-guide chapter: https://rustc-dev-guide.rust-lang.org/solve/canonicalization.html

r? ``@compiler-errors``
2023-03-03 20:06:26 +01:00
bors 7a809ce899 Auto merge of #108677 - matthiaskrgr:rollup-i91cxuf, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #108022 (Support allocations with non-Box<[u8]> bytes)
 - #108367 (Re-apply "switch to the macos-12-xl builder")
 - #108557 (Point error span at Some constructor argument when trait resolution fails)
 - #108573 (Explain compile-time vs run-time difference in env!() error message)
 - #108584 (Put backtick content from rustdoc search errors into a `<code>` elements)
 - #108624 (Make `ExprKind` the first field in `thir::Expr`)
 - #108644 (Allow setting hashmap toml values in `./configure`)
 - #108672 (Feed queries on impl side for RPITITs when using lower_impl_trait_in_trait_to_assoc_ty)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-03 16:02:37 +00:00
lcnr a15abea931 canonicalization 2023-03-03 12:45:03 +01:00
Matthias Krüger e85df8d0fe
Rollup merge of #108672 - spastorino:new-rpitit-impl-side, r=compiler-errors
Feed queries on impl side for RPITITs when using lower_impl_trait_in_trait_to_assoc_ty

I've added a test for traits that were already working and what I think is probably the last bit of infrastructure work needed.
In following PRs I'm going to start adding things TDD style, tests and code that make it work.

r? `@compiler-errors`
2023-03-02 23:05:31 +01:00
Matthias Krüger 8a21bcee25
Rollup merge of #108644 - KittyBorgX:hashmap-toml, r=albertlarsan68
Allow setting hashmap toml values in `./configure`

Fixes https://github.com/rust-lang/rust/issues/108621
2023-03-02 23:05:30 +01:00
Matthias Krüger 7c4e9dd63d
Rollup merge of #108624 - Nilstrieb:move-it-up, r=WaffleLapkin
Make `ExprKind` the first field in `thir::Expr`

This makes its `Debug` impl print it first which is useful, as it's the most important part when looking at an expr.
2023-03-02 23:05:30 +01:00
Matthias Krüger 0dc12b9dec
Rollup merge of #108584 - GuillaumeGomez:rustdoc-search-background, r=notriddle
Put backtick content from rustdoc search errors into a <code> elements

Some screenshots of the result:

![Screenshot from 2023-02-28 22-37-09](https://user-images.githubusercontent.com/3050060/221990290-fa84f1cf-5a64-4ce5-8433-ee36cedf4c00.png)
![Screenshot from 2023-02-28 22-36-59](https://user-images.githubusercontent.com/3050060/221990298-f8177eeb-894b-4fce-a6fc-06d17c8b7ca2.png)
![Screenshot from 2023-02-28 22-36-51](https://user-images.githubusercontent.com/3050060/221990301-41bffd64-d041-41f1-995a-983925b1fbb1.png)

You can test it [here](https://rustdoc.crud.net/imperio/rustdoc-search-background/foo/index.html?search=%22).

r? ```@notriddle```
2023-03-02 23:05:29 +01:00
Matthias Krüger 13640e337a
Rollup merge of #108573 - kornelski:runtimeenvs, r=WaffleLapkin
Explain compile-time vs run-time difference in env!() error message

This PR is clarifying error message of `env!()` based on this user question: https://users.rust-lang.org/t/environment-variable-out-dir-is-undefined/90067

It makes it clear that `env!()` is for env variables defined at compile-time. There's special-case help text for common Cargo build script variables.

I've also rearranged the code to avoid allocating error message on the happy path when the env var is defined.
2023-03-02 23:05:29 +01:00
Matthias Krüger 564715a5b7
Rollup merge of #108557 - Nathan-Fenner:nathanf/adjust-error-span-fix-Some, r=WaffleLapkin
Point error span at Some constructor argument when trait resolution fails

This is a follow up to #108254 and #106477 which extends error span refinement to handle a case which I mistakenly believed was handled in #106477. The goal is to refine the error span depicted below:

```rs
trait Fancy {}
impl <T> Fancy for Option<T> where T: Iterator {}

fn want_fancy<F>(f: F) where F: Fancy {}

fn example() {
    want_fancy(Some(5));
//  (BEFORE)   ^^^^^^^ `{integer}` is not an iterator
//  (AFTER)         ^  `{integer}` is not an iterator
}
```

I had used a (slightly more complex) example as an illustrative example in #108254 , but hadn't actually turned it into a test, because I had (incorrectly) believed at the time it was covered by existing behavior. It turns out that `Some` is slightly "special" in that it resolves differently from the other `enum` constructors I had tried, and therefore this test was actually broken.

I've now updated the tests to include this example, and fixed the code to correctly resolve the `Some` constructor so that the span of the error is reduced.
2023-03-02 23:05:28 +01:00
Matthias Krüger a27a4e4c7a
Rollup merge of #108367 - compiler-errors:xl-builders-again, r=pietroalbini
Re-apply "switch to the macos-12-xl builder"

This reverts commit e63ec2e140, essentially re-applying fcbae989ae.

r? ````@pietroalbini````
2023-03-02 23:05:28 +01:00
Matthias Krüger f75f440bbf
Rollup merge of #108022 - CraftSpider:align-bytes, r=oli-obk
Support allocations with non-Box<[u8]> bytes

This is prep work for allowing miri to support passing pointers to C code, which will require `Allocation`s to be correctly aligned. Currently, it just makes `Allocation` generic and plumbs the necessary changes through the right places.

The follow-up to this will be adding a type in the miri interpreter which correctly aligns the bytes, using that for the Miri engine, then allowing Miri to pass pointers into these allocations to C calls.

Based off of #100467, credit to ```@emarteca``` for the code
2023-03-02 23:05:27 +01:00
Santiago Pastorino fa6bf2afdb
Feed queries on impl side for RPITITs when using lower_impl_trait_in_trait_to_assoc_ty 2023-03-02 16:48:49 -03:00
Santiago Pastorino 12b81a5734
Add simple trait test 2023-03-02 16:48:49 -03:00
Michael Goulet 4b01a1a07a Fix another ICE in point_at_expr_source_of_inferred_type 2023-03-02 18:27:06 +00:00
Nilstrieb e3d397a5f6 Make ExprKind the first field in thir::Expr
This makes its `Debug` impl print it first which is useful, as it's the
most important part when looking at an expr.
2023-03-02 18:21:44 +00:00
bors 13471d3b20 Auto merge of #108654 - LeSeulArtichaut:revert-99767, r=compiler-errors
Revert stabilization of `#![feature(target_feature_11)]`

This reverts #99767 due to the presence of bugs #108645 and #108646.

cc `@joshtriplett`
cc tracking issue #69098
r? `@ghost`
2023-03-02 17:38:31 +00:00
bors 7e966bcd03 Auto merge of #108640 - matthiaskrgr:rollup-rii4t5t, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #108516 (Restrict `#[rustc_box]` to `Box::new` calls)
 - #108575 (Erase **all** regions when probing for associated types on ambiguity in astconv)
 - #108585 (Run compiler test suite in parallel on Fuchsia)
 - #108606 (Add test case for mismatched open/close delims)
 - #108609 (Highlight whole expression for E0599)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-02 14:04:22 +00:00
KittyBorgX a6580baa6c Allow setting hashmap toml values in ./configure 2023-03-02 19:00:26 +05:30
Léo Lanteri Thauvin bfe5189904 Revert "Stabilize #![feature(target_feature_11)]"
This reverts commit b379d216ee.
2023-03-02 13:41:17 +01:00
Guillaume Gomez cfb4af87e3 Add GUI test for rustdoc search errors background 2023-03-02 12:59:04 +01:00
Guillaume Gomez 6b0b65424a Update rustdoc-js test tool 2023-03-02 12:59:04 +01:00
Guillaume Gomez 4e560d7d0b Put backtick content from rustdoc search errors into a <code> elements 2023-03-02 12:59:04 +01:00
Matthias Krüger 832987bb1e
Rollup merge of #108609 - clubby789:e0599-highlight, r=estebank
Highlight whole expression for E0599

Fixes #108603

This adds a secondary label to highlight the whole expression leading to the error. It also prevents empty labels being recognised as 'unexpected' by compiletest - otherwise, tests with NOTE annotations would pick up empty labels.

`@rustbot` label +A-diagnostics
2023-03-02 07:24:02 +01:00
Matthias Krüger c09a9a69e2
Rollup merge of #108606 - chenyukang:yukang/fix-104367, r=compiler-errors
Add test case for mismatched open/close delims

Fixes #104367
Fixes #105209

After landing https://github.com/rust-lang/rust/pull/108297, these issues are resolved.
2023-03-02 07:24:02 +01:00
Matthias Krüger 478d530af4
Rollup merge of #108585 - djkoloski:parallel_fuchsia_test_runner, r=tmandry
Run compiler test suite in parallel on Fuchsia

This also adds file locking around calls to `pm publish` as these calls are not thread-safe.
2023-03-02 07:24:01 +01:00
Matthias Krüger 91dafebc91
Rollup merge of #108575 - compiler-errors:erase, r=estebank
Erase **all** regions when probing for associated types on ambiguity in astconv

Fixes #108562
2023-03-02 07:24:01 +01:00
Matthias Krüger c9c9283c6a
Rollup merge of #108516 - clubby789:rustc-box-restrict, r=compiler-errors
Restrict `#[rustc_box]` to `Box::new` calls

Currently, `#[rustc_box]` can be applied to any call expression with a single argument. This PR only allows it to be applied to calls to `Box::new`
2023-03-02 07:24:00 +01:00
bors 18caf88956 Auto merge of #107879 - icedrocket:update-llvm, r=cuviper
Update LLVM submodule

Fixes #105626
2023-03-02 05:27:32 +00:00
clubby789 d845769557 Restrict #[rustc_box] to Box::new calls 2023-03-02 02:42:19 +00:00
bors 864b6258fc Auto merge of #106673 - flba-eb:add_qnx_nto_stdlib, r=workingjubilee
Add support for QNX Neutrino to standard library

This change:

- adds standard library support for QNX Neutrino (7.1).
- upgrades `libc` to version `0.2.139` which supports QNX Neutrino

`@gh-tr`

⚠️ Backtraces on QNX require https://github.com/rust-lang/backtrace-rs/pull/507 which is not yet merged! (But everything else works without these changes) ⚠️

Tested mainly with a x86_64 virtual machine (see qnx-nto.md) and partially with an aarch64 hardware (some tests fail due to constrained resources).
2023-03-02 02:41:42 +00:00
Rune Tynan f26b0a2948
Format 2023-03-01 20:27:03 -05:00
bors 0b4ba4cf0e Auto merge of #108483 - scottmcm:unify-bytewise-eq-traits, r=the8472
Merge two different equality specialization traits in `core`

Arrays and slices each had their own version of this, without a matching set of `impl`s.

Merge them into one (still-`pub(crate)`) `cmp::BytewiseEq` trait, so we can stop doing all these things twice.

And that means that the `[T]::eq` → `memcmp` specialization picks up a bunch of types where that previously only worked for arrays, so examples like <https://rust.godbolt.org/z/KjsG8MGGT> will use it now instead of emitting loops.

r? the8472
2023-03-01 23:34:37 +00:00
Scott McMurray 44eec1d9b0 Merge two different equality specialization traits in core 2023-03-01 14:42:06 -08:00
David Koloski c9f1a541b3 Run compiler test suite in parallel on Fuchsia 2023-03-01 15:35:00 -05:00
bors f77bfb7336 Auto merge of #108620 - Dylan-DPC:rollup-o5c4evy, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #108143 (rustdoc: search by macro when query ends with `!`)
 - #108394 (Make `x doc --open` work on every book)
 - #108427 (Recover from for-else and while-else)
 - #108462 (Fix `VecDeque::append` capacity overflow for ZSTs)
 - #108568 (Make associated_item_def_ids for traits use an unstable option to also return associated types for RPITITs)
 - #108604 (Add regression test for #107280)
 - #108605 (Add regression test for #105821)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-01 18:51:29 +00:00
Dylan DPC 02e4eefd88
Rollup merge of #108605 - JohnTitor:issue-105821, r=compiler-errors
Add regression test for #105821

Closes #105821
r? compiler-errors
2023-03-01 23:40:22 +05:30
Dylan DPC 0ed76b473f
Rollup merge of #108604 - JohnTitor:issue-107280, r=compiler-errors
Add regression test for #107280

Closes #107280
r? compiler-errors
2023-03-01 23:40:21 +05:30
Dylan DPC 9d132f77ae
Rollup merge of #108568 - spastorino:new-rpitit-flag, r=compiler-errors
Make associated_item_def_ids for traits use an unstable option to also return associated types for RPITITs

r? `@compiler-errors`
2023-03-01 23:40:21 +05:30
Dylan DPC 093a53f134
Rollup merge of #108462 - pommicket:fix-vecdeque-zst-overflow, r=Amanieu
Fix `VecDeque::append` capacity overflow for ZSTs

Fixes #108454.
2023-03-01 23:40:20 +05:30
Dylan DPC 27fa7b5e6d
Rollup merge of #108427 - y21:for-else-diagnostic, r=compiler-errors
Recover from for-else and while-else

This recovers from attempts at writing for-else or while-else loops, which might help users coming from e.g. Python.
```rs
for _ in 0..0 {
  // ...
} else {
  // ...
}
```
Combined with trying to store it in a let binding, the current diagnostic can be a bit confusing. It mentions let-else and suggests wrapping the loop in parentheses, which the user probably doesn't want. let-else doesn't make sense for `for` and `while` loops, as they are of type `()` (which already is an irrefutable pattern and doesn't need let-else).
<details>
<summary>Current diagnostic</summary>

```rs
error: right curly brace `}` before `else` in a `let...else` statement not allowed
 --> src/main.rs:4:5
  |
4 |     } else {
  |     ^
  |
help: wrap the expression in parentheses
  |
2 ~     let _x = (for _ in 0..0 {
3 |
4 ~     }) else {
  |
```
</details>

Some questions:
- Can the wording for the error message be improved? Would "for...else loops are not allowed" fit better?
- Should we be more "conservative" in case we want to support this in the future (i.e. say "for...else loops are **currently** not allowed/supported")?
- Is there a better way than storing a `&'static str` for the loop type? It is used for substituting the placeholder in the locale file (since it can emit either `for...else` or `while...else`). Maybe there is an enum I could use that I couldn't find
2023-03-01 23:40:19 +05:30
Dylan DPC 38461f8b8a
Rollup merge of #108394 - ferrocene:pa-open, r=ozkanonur
Make `x doc --open` work on every book

Before this PR, the `--open` flag had to be configured explicitly for every book, and most of them didn't configure it, resulting in the flag silently failing in all but two books.

In this PR, the code to check for the `--open` flag is in the underlying `RustbookSrc` step rather than all the individual steps. This is done by passing the parent step as a field of `RustbookSrc`, so that we can check for the correct step in `maybe_open_in_browser`.

This was part of a larger change that in the end wasn't worth it. Still, I think it could be useful as-is.
2023-03-01 23:40:19 +05:30
Dylan DPC f03e5345aa
Rollup merge of #108143 - notriddle:notriddle/filter-exclamation-macro, r=GuillaumeGomez
rustdoc: search by macro when query ends with `!`

Related to #96399

Note: the `never` type alias is tested in [`/tests/rustdoc-js-std/alias-3.js`](08ad401633/tests/rustdoc-js-std/alias-3.js)

## Before

![image](https://user-images.githubusercontent.com/1593513/219504192-54cc0753-ff97-4a37-ad4a-8ae915181325.png)

## After

![image](https://user-images.githubusercontent.com/1593513/219504251-589a7e11-1e7b-4b7b-879d-1b564080017c.png)
2023-03-01 23:40:18 +05:30
Santiago Pastorino 73e2fe0494
Properly implement should_encode_fn_impl_trait_in_trait using new unstable option 2023-03-01 14:13:41 -03:00
clubby789 6c2a952b56 Highlight whole expression for E0599 2023-03-01 16:57:11 +00:00
Santiago Pastorino 811a1cabda
Make associated_item_def_ids for traits use an unstable option to also return associated types for RPITITs 2023-03-01 12:56:39 -03:00
Santiago Pastorino be72beca68
Fix typo in docs 2023-03-01 12:56:39 -03:00
Santiago Pastorino e74f50ecc2
Add unstable option new_rpitit to be used for new RPITIT lowering system 2023-03-01 12:56:39 -03:00