Commit Graph

25259 Commits

Author SHA1 Message Date
Matthias Krüger
17cc282880
Rollup merge of #112323 - compiler-errors:dont-mention-set-fields, r=WaffleLapkin
Don't mention already-set fields in struct constructor missing field error

Fixes #111149
2023-06-09 08:15:55 +02:00
bors
68c8fdaac0 Auto merge of #108293 - Jarcho:mut_analyses, r=eholk
Take MIR dataflow analyses by mutable reference

The main motivation here is any analysis requiring dynamically sized scratch memory to work. One concrete example would be pointer target tracking, where tracking the results of a dereference can result in multiple possible targets. This leads to processing multi-level dereferences requiring the ability to handle a changing number of potential targets per step. A (simplified) function for this would be `fn apply_deref(potential_targets: &mut Vec<Target>)` which would use the scratch space contained in the analysis to send arguments and receive the results.

The alternative to this would be to wrap everything in a `RefCell`, which is what `MaybeRequiresStorage` currently does. This comes with a small perf cost and loses the compiler's guarantee that we don't try to take multiple borrows at the same time.

For the implementation:
* `AnalysisResults` is an unfortunate requirement to avoid an unconstrained type parameter error.
* `CloneAnalysis` could just be `Clone` instead, but that would result in more work than is required to have multiple cursors over the same result set.
* `ResultsVisitor` now takes the results type on in each function as there's no other way to have access to the analysis without cloning it. This could use an associated type rather than a type parameter, but the current approach makes it easier to not care about the type when it's not necessary.
* `MaybeRequiresStorage` now no longer uses a `RefCell`, but the graphviz formatter now does. It could be removed, but that would require even more changes and doesn't really seem necessary.
2023-06-08 23:58:44 +00:00
bors
a77659a1e1 Auto merge of #112420 - matthiaskrgr:rollup-spiavw5, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #109953 (Use 128 bits for TypeId hash)
 - #112333 (Don't hold the active queries lock while calling `make_query`)
 - #112339 (Fix rust-analyzer proc macro server)
 - #112410 (Do `fix_*_builtin_expr` hacks on the writeback results)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-08 13:30:52 +00:00
Matthias Krüger
909bfa31ed
Rollup merge of #112410 - compiler-errors:writeback, r=lcnr
Do `fix_*_builtin_expr` hacks on the writeback results

During writeback, we do `fix_{scalar,index}_builtin_expr` so that during MIR build we generate built-in MIR instructions instead of method calls for certain built-in arithmetic operations. We do this by checking the types of these built-in operations are scalar types, and remove the method def-id to essentially mark the operation as built-in and not "overloaded".

For lazy norm and the new trait solver, this is a problem, because we don't actually normalize all the types we end up seeing in the typeck results until they're copied over writeback's copy of the typeck results. To fix this, delay these fixup calls until after this normalization has been done.

This doesn't affect the old trait solver, but does simplify the code a bit IMO, since we can remove a few sets of calls to `resolve_vars_if_possible` and some `borrow_mut`s.

r? `@lcnr`
2023-06-08 12:36:19 +02:00
Matthias Krüger
4f2e1df29d
Rollup merge of #112333 - Zoxc:try_collect_active_jobs-deadlock, r=cjgillot
Don't hold the active queries lock while calling `make_query`

This moves the call to `make_query` outside the parts that holds the active queries lock in `try_collect_active_jobs`. This should help removed the deadlock and borrow panic that has been observed when printing the query stack during an ICE.

cc `@SparrowLii`
r? `@cjgillot`
2023-06-08 12:36:18 +02:00
Matthias Krüger
8747c0ebea
Rollup merge of #109953 - thomcc:thomcc/typeid128, r=WaffleLapkin
Use 128 bits for TypeId hash

Preliminary/Draft impl of https://github.com/rust-lang/compiler-team/issues/608

Prior art (probably incomplete list)
- https://github.com/rust-lang/rust/pull/75923
- https://github.com/rust-lang/rust/pull/95845
2023-06-08 12:36:17 +02:00
bors
e7409258db Auto merge of #112415 - GuillaumeGomez:rollup-5pa9frd, r=GuillaumeGomez
Rollup of 9 pull requests

Successful merges:

 - #112034 (Migrate `item_opaque_ty` to Askama)
 - #112179 (Avoid passing --cpu-features when empty)
 - #112309 (bootstrap: remove dependency `is-terminal`)
 - #112388 (Migrate GUI colors test to original CSS color format)
 - #112389 (Add a test for #105709)
 - #112392 (Fix ICE for while loop with assignment condition with LHS place expr)
 - #112394 (Remove accidental comment)
 - #112396 (Track more diagnostics in `rustc_expand`)
 - #112401 (Don't `use compile_error as print`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-08 10:31:52 +00:00
Guillaume Gomez
cf5e0b0618
Rollup merge of #112401 - WaffleLapkin:dont_compile_error, r=Nilstrieb
Don't `use compile_error as print`

I've spent **1.5 hours** debugging this while trying to compile #112400, if we use `compile_error!`, we should not just forward user input to it, but issue a reasonable error message.

The better solution would be to use a lint like `clippy::print_stdout`, but since we don't have clippy in CI, let's at least make the macro error better.

Also note that some functions called here actually do use `println` (see for example `print_type_sizes` function).
2023-06-08 10:15:13 +02:00
Guillaume Gomez
b3d1a83311
Rollup merge of #112396 - WaffleLapkin:track_more_diagnostics, r=compiler-errors
Track more diagnostics in `rustc_expand`

I wish we could lint this somehow...
2023-06-08 10:15:13 +02:00
Guillaume Gomez
80c26483ba
Rollup merge of #112394 - clubby789:remove-comment, r=petrochenkov
Remove accidental comment

Left this in in #110092 while debugging, thanks to `@WaffleLapkin` for spotting
2023-06-08 10:15:12 +02:00
Guillaume Gomez
80829ceaa7
Rollup merge of #112392 - jieyouxu:issue-112385, r=compiler-errors
Fix ICE for while loop with assignment condition with LHS place expr

Fixes #112385.
2023-06-08 10:15:12 +02:00
Guillaume Gomez
ad9d7e3ed5
Rollup merge of #112179 - tamird:no-empty-cpu-features, r=petrochenkov
Avoid passing --cpu-features when empty

Added in 12ac719b99, this logic always
passed --cpu-features, even when the value was the empty string.
2023-06-08 10:15:09 +02:00
bors
a0df04c0f2 Auto merge of #110040 - ndrewxie:issue-84447-partial-1, r=lcnr,michaelwoerister
Removed use of iteration through a HashMap/HashSet in rustc_incremental and replaced with IndexMap/IndexSet

This allows for the `#[allow(rustc::potential_query_instability)]` in rustc_incremental to be removed, moving towards fixing #84447 (although a LOT more modules have to be changed to fully resolve it). Only HashMaps/HashSets that are being iterated through have been modified (although many structs and traits outside of rustc_incremental had to be modified as well, as they had fields/methods that involved a HashMap/HashSet that would be iterated through)

I'm making a PR for just 1 module changed to test for performance regressions and such, for future changes I'll either edit this PR to reflect additional modules being converted, or batch multiple modules of changes together and make a PR for each group of modules.
2023-06-08 07:30:03 +00:00
Andrew Xie
54d7b327e5 Removed stable/unstable sort arg from into_sorted_stable_ord, fixed a few misc issues, added collect to UnordItems 2023-06-08 00:38:50 -04:00
Michael Goulet
8efcb28d3c Do fix_*_builtin_expr hacks on the writeback results 2023-06-08 03:21:13 +00:00
bors
f383703e32 Auto merge of #111698 - Amanieu:force-static-lib, r=petrochenkov
Force all native libraries to be statically linked when linking a static binary

Previously, `#[link]` without an explicit `kind = "static"` would confuse the linker and end up producing a dynamically linked library because of the `-Bdynamic` flag. However this binary would not work correctly anyways since it was linked with startup code for a static binary.

This PR solves this by forcing all native libraries to be statically linked when the output is a static binary that cannot link to dynamic libraries anyways.

Fixes #108878
Fixes #102993
2023-06-07 22:02:24 +00:00
Maybe Waffle
c38d80ee9f Track more diagnostics in rustc_expand 2023-06-07 19:08:50 +00:00
Maybe Waffle
fbe3a475f2 Don't use compile_error as print 2023-06-07 18:59:31 +00:00
许杰友 Jieyou Xu (Joe)
adbfd0da68
Fix ICE for while loop with assignment condition with LHS place expr 2023-06-08 02:38:12 +08:00
Amanieu d'Antras
0304e0a5b0 Force all native libraries to be statically linked when linking a static binary 2023-06-07 19:30:37 +01:00
bors
a97c36dd2e Auto merge of #109005 - Nilstrieb:dont-forgor-too-much-from-cfg, r=petrochenkov
Remember names of `cfg`-ed out items to mention them in diagnostics

# Examples

## `serde::Deserialize` without the `derive` feature (a classic beginner mistake)

I had to slightly modify serde so that it uses explicit re-exports instead of a glob re-export. (Update: a serde PR was merged that adds the manual re-exports)

```
error[E0433]: failed to resolve: could not find `Serialize` in `serde`
   --> src/main.rs:1:17
    |
1   | #[derive(serde::Serialize)]
    |                 ^^^^^^^^^ could not find `Serialize` in `serde`
    |
note: crate `serde` has an item named `Serialize` but it is inactive because its cfg predicate evaluated to false
   --> /home/gh-Nilstrieb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.160/src/lib.rs:343:1
    |
343 | #[cfg(feature = "serde_derive")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
344 | pub use serde_derive::{Deserialize, Serialize};
    |                                     ^^^^^^^^^
    = note: the item is gated behind the `serde_derive` feature
    = note: see https://doc.rust-lang.org/cargo/reference/features.html for how to activate a crate's feature
```
(the suggestion is not ideal but that's serde's fault)

I already tested the metadata size impact locally by compiling the `windows` crate without any features. `800k`  -> `809k`

r? `@ghost`
2023-06-07 17:38:57 +00:00
clubby789
053e6b80c7 Remove accidental comment 2023-06-07 17:16:34 +00:00
Dylan DPC
1dc4b4001f
Rollup merge of #112359 - Nilstrieb:i-can-only-handle-so-many-backtraces, r=compiler-errors
Respect `RUST_BACKTRACE` for delayed bugs

Sometimes, especially with MIR validation, the backtraces from delayed bugs are noise and make it harder to look at them. Respect the environment variable and don't print it when the user doesn't want it.
2023-06-07 18:01:30 +05:30
Dylan DPC
42cf6da6af
Rollup merge of #112345 - bvanjoi:fix-112342, r=nilstrieb,est31
fix(expand): prevent infinity loop in macro containing only "///"

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

Issue #112342 was caused by an infinity loop in `parse_tt_inner`, and the state of it is as follows:

- `matcher`: `[Sequence, Token(Doc), SequenceKleeneOpNoSep(op: ZeroOrMore), Eof]`

-  loop:

| Iteration | Action |
| - | - |
| 0   |  enter `Sequence`|
| 1    |  enter `Token(Doc)` and `mp.idx += 1` had been executed |
| 2   |  enter `SequenceKleeneOpNoSep` and reset `mp.idx` to `1` |
| 3   | enter `Token(Doc)` again|

To prevent the infinite loop, a check for whether it only contains `DocComment` in `check_lhs_no_empty_seq` had been added.
2023-06-07 18:01:30 +05:30
Dylan DPC
0b002eb906
Rollup merge of #112122 - compiler-errors:next-coherence, r=lcnr
Add `-Ztrait-solver=next-coherence`

Flag that conditionally uses the trait solver *only* during coherence, for more testing and/or eventual partial-migration onto the trait solver (in the medium- to long-term).

* This still uses the selection context in some of the coherence methods I think, so it's not "complete". Putting this up for review and/or for further work in-tree.
* I probably need to spend a bit more time making sure that we don't sneakily create any other infcx's during coherence that also need the new solver enabled.

r? `@lcnr`
2023-06-07 18:01:29 +05:30
Dylan DPC
cbe429c7a5
Rollup merge of #112076 - compiler-errors:bidirectional-alias-eq, r=lcnr
Fall back to bidirectional normalizes-to if no subst-relate candidate in alias-relate goal

Sometimes we get into the case where the choice of normalizes-to branch in alias-relate are both valid, but we cannot make a choice of which one to take because they are different -- either returning equivalent but permuted region constraints, or equivalent opaque type definitions but differing modulo normalization.

In this case, we can make progress by considering a fourth candidate where we compute both normalizes-to branches together and canonicalize that as a response. This is essentially the AND intersection of both normalizes-to branches. In an ideal world, we'd be returning something more like the OR intersection of both branches, but we have no way of representing that either for regions (maybe eventually) or opaques (don't see that happening ever).

This is incomplete, so like the subst-relate fallback it's only considered outside of coherence. But it doesn't seem like a dramatic strengthening of inference or anything, and is useful for helping opaque type inference succeed when the hidden type is a projection.

## Example

Consider the goal - `AliasRelate(Tait, <[i32; 32] as IntoIterator>::IntoIter)`.

We have three ways of currently solving this goal:
1. SubstRelate - fails because we can't directly equate the substs of different alias kinds.
2. NormalizesToRhs - `Tait normalizes-to <[i32; 32] as IntoIterator>::IntoIter`
    * Ends up infering opaque definition - `Tait := <[i32; 32] as IntoIterator>::IntoIter`
3. NormalizesToLhs - `<[i32; 32] as IntoIterator>::IntoIter normalizes-to Tait`
    * Find impl candidate, substitute the associated type - `std::array::IntoIter<i32, 32>`
    * Equate `std::array::IntoIter<i32, 32>` and `Tait`
        * Ends up infering opaque definition - `Tait := std::array::IntoIter<i32, 32>`

The problem here is that 2 and 3 are essentially both valid, since we have aliases that normalize on both sides, but due to lazy norm, they end up inferring different opaque type definitions that are only equal *after* normalizing them further.

---

r? `@lcnr`
2023-06-07 18:01:28 +05:30
bors
e94bda3bf1 Auto merge of #111047 - compiler-errors:rtn-no-ty-ct-params, r=spastorino
Emit an error when return-type-notation is used with type/const params

These are not intended to be supported initially, even though the compiler supports them internally...
2023-06-07 09:03:33 +00:00
bors
b3dd578767 Auto merge of #111819 - nikarh:vita-improved, r=Amanieu
Improved std support for ps vita target

Fixed a couple of things in std support for ps vita via Vita SDK newlib oss implementation:

- Added missing hardware features to target spec
- Compile in thumb by default (newlib is also compiled in thumb)
- Fixed fs calls. Vita newlib has a not-very-posix dirent. Also vita does not expose inodes, it's stubbed as 0 in stat, and I'm stubbing it here for dirent (because vita newlibs's dirent doesn't even have that field)
- Enabled signal handlers for panic unwinding
- Dropped static link requirement from the platform support md. Also, rearranged sections to better stick with the template.
2023-06-07 03:20:15 +00:00
bohan
5eafab30ba feat(expand): emit note for doc comment in macro matcher 2023-06-07 10:20:36 +08:00
bors
afab3662eb Auto merge of #112361 - matthiaskrgr:rollup-39zxrw1, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #111250 (Add Terminator conversion from MIR to SMIR, part #2)
 - #112310 (Add new Tier-3 targets: `loongarch64-unknown-none*`)
 - #112334 (Add myself to highfive rotation)
 - #112340 (remove `TyCtxt::has_error_field` helper method)
 - #112343 (Prevent emitting `missing_docs` for `pub extern crate`)
 - #112350 (Avoid duplicate type sanitization of local decls in borrowck)
 - #112356 (Fix comment for `get_region_var_origins`)
 - #112358 (Remove default visitor impl in region constraint generation)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-06 21:28:34 +00:00
Matthias Krüger
63e0423cde
Rollup merge of #112358 - Nilstrieb:fancy-more-borrowck-cleanups, r=compiler-errors
Remove default visitor impl in region constraint generation

I wanted to group it together with other possibly minor borrowck cleanups but that's all I have right now so I rather put it up than forget about it before doing something else.

r? `@compiler-errors`
2023-06-06 22:00:21 +02:00
Matthias Krüger
53881f91b0
Rollup merge of #112356 - Nilstrieb:get-region-var-origins, r=compiler-errors
Fix comment for `get_region_var_origins`

#109753 changed the logic but not the comment.

r? `@compiler-errors`
2023-06-06 22:00:21 +02:00
Matthias Krüger
fd6efcf960
Rollup merge of #112350 - Nilstrieb:borrow-me-some-cleanups, r=compiler-errors
Avoid duplicate type sanitization of local decls in borrowck

The type of the local decl is already sanitized in `visit_local_decl`.
2023-06-06 22:00:20 +02:00
Matthias Krüger
38ddff516c
Rollup merge of #112343 - GuillaumeGomez:extern-crate-missing-docs, r=notriddle
Prevent emitting `missing_docs` for `pub extern crate`

Fixes #112308.

r? `@notriddle`
2023-06-06 22:00:20 +02:00
Matthias Krüger
e937fa49dd
Rollup merge of #112340 - lcnr:tyctxt-cleanup, r=compiler-errors
remove `TyCtxt::has_error_field` helper method
2023-06-06 22:00:20 +02:00
Matthias Krüger
157d0f03ab
Rollup merge of #112310 - loongarch-rs:bare-metal, r=WaffleLapkin
Add new Tier-3 targets: `loongarch64-unknown-none*`

This PR adds new Tier-3 targets `loongarch64-unknown-none*` that are introduced by MCP rust-lang/compiler-team#628
2023-06-06 22:00:19 +02:00
Matthias Krüger
1788d49789
Rollup merge of #111250 - spastorino:smir-terminator-2, r=oli-obk
Add Terminator conversion from MIR to SMIR, part #2

r? `@oli-obk`
2023-06-06 22:00:18 +02:00
Nilstrieb
70980929b4 Respect RUST_BACKTRACE for delayed bugs
Sometimes, especially with MIR validation, the backtraces from delayed
bugs are noise and make it harder to look at them. Respect the
environment variable and don't print it when the user doesn't want it.
2023-06-06 19:24:33 +00:00
Nilstrieb
459bd2cbde Remove default visitor impl in region constraint generation 2023-06-06 19:00:47 +00:00
Nilstrieb
5593e7e2ba Avoid duplicate type sanitization of local decls
The type of the local decl is already sanitized in `visit_local_decl`.
2023-06-06 18:52:47 +00:00
Nilstrieb
0e01088f07 Fix comment for get_region_var_origins 2023-06-06 18:50:38 +00:00
Michael Goulet
3ea7c512bd Fall back to bidirectional normalizes-to if no subst-eq in alias-eq goal 2023-06-06 18:44:22 +00:00
Michael Goulet
7a2cdf20e4 Move alias-relate to its own module 2023-06-06 18:44:22 +00:00
Michael Goulet
3d4da98273 Make TraitEngine::new use the right solver, add compare mode 2023-06-06 18:43:20 +00:00
Michael Goulet
b637048a89 Add -Ztrait-solver=next-coherence 2023-06-06 18:43:20 +00:00
Michael Goulet
e0acff796a New trait solver is a property of inference context 2023-06-06 18:43:06 +00:00
bohan
c927743b7b fix(expand): prevent infinity loop in macro containing only "///" 2023-06-06 23:11:08 +08:00
Matthias Krüger
38c92cca65
Rollup merge of #112325 - notriddle:notriddle/issue-111932, r=compiler-errors
diagnostics: do not suggest type name tweaks on type-inferred closure args

Fixes #111932
2023-06-06 12:00:34 +02:00
Matthias Krüger
7c76f3b9d8
Rollup merge of #112220 - kylematsuda:earlybinder-fix, r=compiler-errors
Cleanup some `EarlyBinder::skip_binder()` -> `EarlyBinder::subst_identity()`

fix some incorrect `skip_binder()`'s as identified in https://github.com/rust-lang/rust/pull/112006#pullrequestreview-1448369203

r? ``@compiler-errors`` ``@lcnr`` ``@jackh726``

(hope it's alright to just tag everyone who commented 😅)
2023-06-06 12:00:34 +02:00
Matthias Krüger
71a72ee34a
Rollup merge of #112199 - jieyouxu:issue-112188, r=compiler-errors
Fix suggestion for matching struct with `..` on both ends

### Before This PR

```
error: expected `}`, found `,`
 --> src\main.rs:8:17
  |
8 |         Foo { .., x, .. } => (),
  |               --^
  |               | |
  |               | expected `}`
  |               `..` must be at the end and cannot have a trailing comma
  |
help: move the `..` to the end of the field list
  |
8 -         Foo { .., x, .. } => (),
8 +         Foo { .., x,  , .. } => (),
  |
```

### After This PR

```
error: expected `}`, found `,`
  --> tests/ui/parser/issue-112188.rs:11:17
   |
11 |     let Foo { .., x, .. } = f; //~ ERROR expected `}`, found `,`
   |               --^-
   |               | |
   |               | expected `}`
   |               `..` must be at the end and cannot have a trailing comma
   |               help: remove the starting `..`
```

Fixes #112188.
2023-06-06 12:00:33 +02:00