Commit Graph

25866 Commits

Author SHA1 Message Date
Maybe Waffle
ccb71ff424 hir: Add Become expression kind 2023-06-26 08:56:32 +00:00
Eric Mark Martin
c07c10d1e4 use PlaceRef abstractions more consistently 2023-06-25 20:38:01 -04:00
Nicholas Nethercote
666b1b68a7 Tweak thread names for CGU processing.
For non-incremental builds on Unix, currently all the thread names look
like `opt regex.f10ba03eb5ec7975-cgu.0`. But they are truncated by
`pthread_setname` to `opt regex.f10ba`, hiding the numeric suffix that
distinguishes them. This is really annoying when using a profiler like
Samply.

This commit changes these thread names to a form like `opt cgu.0`, which
is much better.
2023-06-26 09:14:45 +10:00
Nicholas Nethercote
487bdeb519 Improve ordering and naming of CGUs for non-incremental builds.
Currently there are two problems.

First, the CGUS don't end up in size order. The merging loop does sort
by size on each iteration, but we don't sort after the final merge, so
typically there is one CGU out of place. (And sometimes we don't enter
the merging loop at all, in which case they end up in random order.)

Second, we then assign names that differ only by a numeric suffix, and
then we sort them lexicographically by name, giving us an order like
this:

regex.f10ba03eb5ec7975-cgu.1
regex.f10ba03eb5ec7975-cgu.10
regex.f10ba03eb5ec7975-cgu.11
regex.f10ba03eb5ec7975-cgu.12
regex.f10ba03eb5ec7975-cgu.13
regex.f10ba03eb5ec7975-cgu.14
regex.f10ba03eb5ec7975-cgu.15
regex.f10ba03eb5ec7975-cgu.2
regex.f10ba03eb5ec7975-cgu.3
regex.f10ba03eb5ec7975-cgu.4
regex.f10ba03eb5ec7975-cgu.5
regex.f10ba03eb5ec7975-cgu.6
regex.f10ba03eb5ec7975-cgu.7
regex.f10ba03eb5ec7975-cgu.8
regex.f10ba03eb5ec7975-cgu.9

These two problems are really annoying when debugging and profiling the
CGUs.

This commit ensures CGUs are sorted by name *and* reverse sorted by
size. This involves (a) one extra sort by size operation, and (b)
padding the numeric indices with zeroes, e.g.
`regex.f10ba03eb5ec7975-cgu.01`.

(Note that none of this applies for incremental builds, where a
different hash-based CGU naming scheme is used.)
2023-06-26 09:14:11 +10:00
Matthias Krüger
6c7575721f
Rollup merge of #113036 - TaKO8Ki:fix-112094, r=compiler-errors
Accept `ReStatic` for RPITIT

Fixes #112094

Regression in 8216b7f229

If there is a better suggestion, I will go with that.
2023-06-25 22:34:32 +02:00
Takayuki Maeda
83722c62b0 accept ReStatic for RPITIT
add an ui test for #112094
2023-06-26 01:11:44 +09:00
Matthias Krüger
75f6a7aa00
Rollup merge of #113007 - compiler-errors:dont-structural-resolve-byte-str-pat, r=oli-obk
Revert "Structurally resolve correctly in check_pat_lit"

This reverts commit 54fb5a48b9. Also adds a couple of tests, and downgrades the existing `-Ztrait-solver=next` test to a known-bug.

Fixes #112993
2023-06-25 13:48:36 +02:00
Guillaume Gomez
758adf64e7
Rollup merge of #113011 - Nilstrieb:can_access_statics, r=oli-obk
Add enum for `can_access_statics` boolean

`/*can_access_statics:*/ false` is one of the ways to do this, but not the one I like.

r? oli-obk
2023-06-25 10:46:15 +02:00
Tom Martin
b7d6032082
Add translatable diagnostic for import resolution strings
Add translatable diagnostic for cannot be reexported error
also added for subdiagnostics

Add translatable diagnostics for resolve_glob_import errors

Add translatable diag for unable to determine import resolution

Add translatable diag for is not directly importable
2023-06-25 08:29:28 +01:00
bors
3c5d71a99d Auto merge of #112476 - chenyukang:yukang-fix-109991, r=compiler-errors
Do not emit coerce_suggestions for expr from destructuring assignment desugaring

Fixes #109991
2023-06-25 04:45:52 +00:00
yukang
33f73c2e93 Do not offer any of the suggestions in emit_coerce_suggestions for expr from destructuring assignment desugaring 2023-06-25 09:26:17 +08:00
Nilstrieb
70b6a74c3c Add enum for can_access_statics boolean
`/*can_access_statics:*/ false` is one of the ways to do this, but not
the one I like.
2023-06-24 20:40:40 +00:00
Michael Goulet
e304a1f13b Revert "Structurally resolve correctly in check_pat_lit"
This reverts commit 54fb5a48b9.
2023-06-24 18:41:27 +00:00
Guillaume Gomez
a1f2f23f0f
Rollup merge of #112854 - bvanjoi:fix-112674, r=Nilstrieb
fix: add cfg diagnostic for unresolved import error

Fixes #112674

An easy fix, r? `@Nilstrieb`
2023-06-24 20:26:44 +02:00
Guillaume Gomez
696d722169
Rollup merge of #112703 - aliemjay:next-solver-root-var, r=compiler-errors
[-Ztrait-solver=next, mir-typeck] instantiate hidden types in the root universe

Fixes an ICE in the test `member-constraints-in-root-universe`.

Main motivation is to make #112691 pass under the new solver.

r? ``@compiler-errors``
2023-06-24 20:26:43 +02:00
He1pa
8af8a95a64 Migrate some rustc_builtin_macros to SessionDiagnostic 2023-06-25 01:32:30 +08:00
bohan
8c8c7ef78a fix: add cfg diagnostic for unresolved import error 2023-06-24 21:45:17 +08:00
Ali MJ Al-Nasrawy
a72013f7f0 instantiate hidden types in root universe 2023-06-24 13:00:15 +00:00
bors
ed1ce580ec Auto merge of #112802 - lukas-code:fancy-bool, r=Nilstrieb
use ErrorGuaranteed instead of booleans in rustc_builtin_macros

implements https://github.com/rust-lang/rust/pull/112366#discussion_r1233821873

No functional changes.

Best reviewed with whitespace diff disabled.

r? `@Nilstrieb`
2023-06-24 11:43:41 +00:00
Michael Goulet
bfe6e5c418
Rollup merge of #112983 - spastorino:new-rpitit-23, r=compiler-errors
Fix return type notation associated type suggestion when -Zlower-impl-trait-in-trait-to-assoc-ty

This avoid suggesting the associated types generated for RPITITs when the one the code refers to doesn't exist and rustc looks for a suggestion.

r? `@compiler-errors`
2023-06-23 19:47:22 -07:00
Michael Goulet
4a175523b1
Rollup merge of #112981 - spastorino:new-rpitit-22, r=compiler-errors
Fix return type notation errors with -Zlower-impl-trait-in-trait-to-assoc-ty

This just adjust the way we check for RPITITs and uses the new helper method to do the "old" and "new" check at once.

r? `@compiler-errors`
2023-06-23 19:47:21 -07:00
Michael Goulet
3148bcf0a9
Rollup merge of #112973 - compiler-errors:oops-forgot-ftl, r=jyn514
Make sure to include default en-US ftl resources for `rustc_error` crate

Fixes #112928
2023-06-23 19:47:21 -07:00
Michael Goulet
766db8161b
Rollup merge of #112965 - compiler-errors:circular-wf, r=aliemjay
Don't emit same goal as input during `wf::unnormalized_obligations`

r? `@aliemjay` cc `@lcnr`

I accidentally pruned the logic to handle `WF(?0)` when writing `wf::unnormalized_obligations`.

idk if you wanted to construct a test first, but this is an obvious fix. Copied the comment from above.

Fixes rust-lang/trait-system-refactor-initiative#36
2023-06-23 19:47:21 -07:00
Michael Goulet
fdce450eb5
Rollup merge of #112963 - oli-obk:tait_solver_decoupling, r=compiler-errors
Stop bubbling out hidden types from the eval obligation queries

r? `@compiler-errors`

I don't know why these were added, but they are not needed anymore. The relevant test is unaffected and I didn't see anything interesting in logging that would have justified it.

This PR has no effect on the new solver behaviour of cf2dff2b1e/tests/ui/impl-trait/issue-99642.rs (which is overflow) and cf2dff2b1e/tests/ui/impl-trait/issue-99642-2.rs (which is "unstable certainty ICE")
2023-06-23 19:47:20 -07:00
bors
1d67eba687 Auto merge of #112891 - oli-obk:impl_trait_in_assoc_tys_cleanup, r=compiler-errors
Various impl trait in assoc tys cleanups

r? `@compiler-errors`

All commits except for the last are pure refactorings. 274dab5bd658c97886a8987340bf50ae57900c39 allows struct fields to participate in deciding whether a function has an opaque in its signature.

best reviewed commit by commit
2023-06-23 23:26:38 +00:00
Santiago Pastorino
6d997876c1
Fix associated type suggestion when -Zlower-impl-trait-in-trait-to-assoc-ty 2023-06-23 18:23:52 -03:00
bors
22e9fe644e Auto merge of #112974 - matthiaskrgr:rollup-hnk7ans, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #112616 (Improve tests on targets without unwinding)
 - #112643 (Always register sized obligation for argument)
 - #112740 (Add link to rustdoc book search chapter in help popover)
 - #112810 (Don't ICE on unnormalized struct tail in layout computation)
 - #112870 (Migrate `item_bounds` to `ty::Clause`)
 - #112925 (Stop hiding const eval limit in external macros)
 - #112960 ([tests/rustdoc] Add `@files` command)
 - #112962 (Fix rustdoc gui tester)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-23 20:45:23 +00:00
Santiago Pastorino
d77e55bbb9
Fix return type notation errors with -Zlower-impl-trait-in-trait-to-assoc-ty 2023-06-23 17:34:33 -03:00
Michael Goulet
2cc7782cfd Add suggestion for bad block fragment error 2023-06-23 19:18:20 +00:00
Matthias Krüger
c9139521e7
Rollup merge of #112925 - oli-obk:timeout_lint, r=cjgillot
Stop hiding const eval limit in external macros

fixes #112748

We don't emit a hard error if there was a previous deny lint triggering with the same message. If that lint ends up not being emitted, we ICE and don't emit an error either.
2023-06-23 19:39:59 +02:00
Matthias Krüger
4e8983050e
Rollup merge of #112870 - compiler-errors:clause-2, r=oli-obk
Migrate `item_bounds` to `ty::Clause`

Should be simpler than the next PR that's coming up. Last three commits are the relevant ones.

r? ``@oli-obk`` or ``@lcnr``
2023-06-23 19:39:59 +02:00
Matthias Krüger
cea5ae00d2
Rollup merge of #112810 - compiler-errors:dont-ice-on-bad-layout, r=wesleywiser
Don't ICE on unnormalized struct tail in layout computation

1. We try to compute a `SizeSkeleton` even if a layout error occurs, but we really only need to do this if we get `LayoutError::Unknown`, since that means our type is too polymorphic to actually compute the full layout. If we have other errors, like `LayoutError::NormalizationError` or `LayoutError::Cycle`, then we can't really make any progress, since this represents an actual error.
2. Avoid using `normalize_erasing_regions` and `struct_tail_erasing_lifetimes` since those ICE on normalization errors, and since we may call `layout_of` in HIR typeck, we don't know for certain that we're on the happy path.

Fixes #112736
2023-06-23 19:39:58 +02:00
Matthias Krüger
27ae068de3
Rollup merge of #112643 - compiler-errors:sized-obl-for-arg, r=wesleywiser
Always register sized obligation for argument

Removes a "hack" that skips registering sized obligations for parameters that are simple identifiers. This doesn't seem to affect diagnostics because we're probably already being smart enough about deduplicating identical error messages anyways.

Fixes #112608
2023-06-23 19:39:57 +02:00
Michael Goulet
0710040648 Make sure to include default en-US ftl resources for rustc_error crate 2023-06-23 17:22:07 +00:00
bors
c79d6be6a2 Auto merge of #109982 - durin42:plt-no-x86_64-only, r=nikic
rustc_session: default to -Z plt=yes on non-x86_64

Per the discussion in #106380 plt=no isn't a great default, and rust-lang/compiler-team#581 decided that the default should be PLT=yes for everything except x86_64. Not everyone agrees about the x86_64 part of this change, but this at least is an improvement in the state of things without changing the x86_64 situation, so I've attempted making this change in the name of not letting the perfect be the enemy of the good.

Please let me know if I've messed this up somehow - I'm not wholly confident I got this right.

r? `@nikic`
2023-06-23 16:50:37 +00:00
Gary Guo
c462291e0c Make UnwindAction::Continue explicit in MIR dump 2023-06-23 17:48:54 +01:00
Michael Goulet
2eb7d69309 Resolve vars when reporting WF error 2023-06-23 16:26:22 +00:00
Michael Goulet
f12695b53b Don't emit same goal as input during wf obligations 2023-06-23 16:23:27 +00:00
Oli Scherer
c996cfec80 Stop bubbling out hidden types from the eval obligation queries 2023-06-23 14:53:31 +00:00
Matthias Krüger
c5fd53774f
Rollup merge of #112948 - bkrl:trait-impl-suggestion, r=compiler-errors
Avoid guessing unknown trait implementation in suggestions

When a trait is used without specifying the implementation (e.g. calling a non-member associated function without fully-qualified syntax) and there are multiple implementations available, use a placeholder comment for the implementation type in the suggestion instead of picking a random implementation.

Example:

```
fn main() {
    let _ = Default::default();
}
```

Previous output:

```
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
 --> test.rs:2:13
  |
2 |     let _ = Default::default();
  |             ^^^^^^^^^^^^^^^^ cannot call associated function of trait
  |
help: use a fully-qualified path to a specific available implementation (273 found)
  |
2 |     let _ = <FileTimes as Default>::default();
  |             +++++++++++++        +
```

New output:

```
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
 --> test.rs:2:13
  |
2 |     let _ = Default::default();
  |             ^^^^^^^^^^^^^^^^ cannot call associated function of trait
  |
help: use a fully-qualified path to a specific available implementation (273 found)
  |
2 |     let _ = </* self type */ as Default>::default();
  |             +++++++++++++++++++        +
```

Fixes #112897
2023-06-23 13:18:16 +02:00
Matthias Krüger
4e96aba8f6
Rollup merge of #112933 - TaKO8Ki:avoid-&format-in-error-message-code, r=oli-obk
Avoid `&format` in error message code

follow-up of #111633
2023-06-23 13:18:14 +02:00
Matthias Krüger
01cc9caffe
Rollup merge of #111747 - compiler-errors:structural-probe-side-effects, r=fee1-dead
Don't structurally resolve during method ambiguity in probe

See comment in UI test for reason for the failure. This is all on the error path anyways, not really sure what the assertion is there to achieve anyways...

Fixes #111739
2023-06-23 13:18:12 +02:00
bors
fe37f37e4b Auto merge of #112827 - nnethercote:codegen-cleanups, r=tmiasko
Codegen cleanups

Some cleanups I found while looking closely at this code.

r? `@tmiasko`
2023-06-23 03:51:49 +00:00
Alexander Zhang
48167bd4bd Avoid guessing unknown trait impl in suggestions
When a trait is used without specifying the implementation (e.g. calling
a non-member associated function without fully-qualified syntax) and
there are multiple implementations available, use a placeholder comment
for the implementation type in the suggestion instead of picking a
random implementation.

Example:

```
fn main() {
    let _ = Default::default();
}
```

Previous output:

```
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
 --> test.rs:2:13
  |
2 |     let _ = Default::default();
  |             ^^^^^^^^^^^^^^^^ cannot call associated function of trait
  |
help: use a fully-qualified path to a specific available implementation (273 found)
  |
2 |     let _ = <FileTimes as Default>::default();
  |             +++++++++++++        +
```

New output:

```
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
 --> test.rs:2:13
  |
2 |     let _ = Default::default();
  |             ^^^^^^^^^^^^^^^^ cannot call associated function of trait
  |
help: use a fully-qualified path to a specific available implementation (273 found)
  |
2 |     let _ = </* self type */ as Default>::default();
  |             +++++++++++++++++++        +
```
2023-06-22 16:37:52 -07:00
Michael Goulet
afe36507e8 Don't structurally resolve during method ambiguity in probe 2023-06-22 23:31:06 +00:00
Michael Goulet
471830b3a4 migrate inferred_outlives_of to Clause 2023-06-22 18:34:24 +00:00
Michael Goulet
2fa796a3c7 Expect clause more 2023-06-22 18:34:24 +00:00
Michael Goulet
46a650f4e0 Migrate item_bounds to ty::Clause 2023-06-22 18:34:23 +00:00
Augie Fackler
34d0cffcdf switch to using a target property to control plt default 2023-06-22 14:29:22 -04:00
Augie Fackler
dfc5218dc8 rustc_session: default to -Z plt=yes on non-x86_64
Per the discussion in #106380 plt=no isn't a great default, and
rust-lang/compiler-team#581 decided that the default should be PLT=yes
for everything except x86_64. Not everyone agrees about the x86_64 part
of this change, but this at least is an improvement in the state of
things without changing the x86_64 situation, so I've attempted making
this change in the name of not letting the perfect be the enemy of the
good.
2023-06-22 14:29:21 -04:00
bors
04075b3202 Auto merge of #112686 - estebank:sealed-traits, r=petrochenkov
Account for sealed traits in privacy and trait bound errors

On trait bound errors caused by super-traits, identify if the super-trait is publicly accessibly and if not, explain "sealed traits".

```
error[E0277]: the trait bound `S: Hidden` is not satisfied
  --> $DIR/sealed-trait-local.rs:17:20
   |
LL | impl a::Sealed for S {}
   |                    ^ the trait `Hidden` is not implemented for `S`
   |
note: required by a bound in `Sealed`
  --> $DIR/sealed-trait-local.rs:3:23
   |
LL |     pub trait Sealed: self:🅱️:Hidden {
   |                       ^^^^^^^^^^^^^^^ required by this bound in `Sealed`
   = note: `Sealed` is a "sealed trait", because to implement it you also need to implelement `a:🅱️:Hidden`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it
```

Deduplicate privacy errors that point to the same path segment even if their deduplication span are different.

When encountering a path that is not reachable due to privacy constraints path segments other than the last, keep metadata for the last path segment's `Res` in order to look for alternative import paths for that item to suggest. If there are none, be explicit that the item is not accessible.

```
error[E0603]: module `b` is private
  --> $DIR/re-exported-trait.rs:11:9
   |
LL | impl a:🅱️:Trait for S {}
   |         ^ private module
   |
note: the module `b` is defined here
  --> $DIR/re-exported-trait.rs:5:5
   |
LL |     mod b {
   |     ^^^^^
help: consider importing this trait through its public re-export instead
   |
LL | impl a::Trait for S {}
   |      ~~~~~~~~
```

```
error[E0603]: module `b` is private
  --> $DIR/private-trait.rs:8:9
   |
LL | impl a:🅱️:Hidden for S {}
   |         ^  ------ trait `b` is not publicly reachable
   |         |
   |         private module
   |
note: the module `b` is defined here
  --> $DIR/private-trait.rs:2:5
   |
LL |     mod b {
   |     ^^^^^
```
2023-06-22 18:23:19 +00:00
Takayuki Maeda
c8960622a2 avoid &format in error message code 2023-06-23 02:17:39 +09:00
Esteban Küber
7dffd24da5 Tweak privacy errors to account for reachable items
Suggest publicly accessible paths for items in private mod:

  When encountering a path in non-import situations that are not reachable
  due to privacy constraints, search for any public re-exports that the
  user could use instead.

Track whether an import suggestion is offering a re-export.

When encountering a path with private segments, mention if the item at
the final path segment is not publicly accessible at all.

Add item visibility metadata to privacy errors from imports:

  On unreachable imports, record the item that was being imported in order
  to suggest publicly available re-exports or to be explicit that the item
  is not available publicly from any path.

  In order to allow this, we add a mode to `resolve_path` that will not
  add new privacy errors, nor return early if it encounters one. This way
  we can get the `Res` corresponding to the final item in the import,
  which is used in the privacy error machinery.
2023-06-22 16:50:31 +00:00
Esteban Küber
717c481739 Account for sealed traits in trait bound errors
When implementing a public trait with a private super-trait, we now emit
a note that the missing bound is not going to be able to be satisfied,
and we explain the concept of a sealed trait.
2023-06-22 16:50:21 +00:00
Oli Scherer
27b386ad17 Only walk the identity substituted version of struct fields 2023-06-22 15:51:20 +00:00
Oli Scherer
b323f587fc Handle weak type aliases by immediately resolving them to their aliased type 2023-06-22 15:51:19 +00:00
Oli Scherer
b0b4a07959 ICE on types that should not be defining opaque types 2023-06-22 15:51:19 +00:00
Oli Scherer
0af4a211be Document what is going on in opaque_types_defined_by 2023-06-22 15:51:19 +00:00
Oli Scherer
cb161e77ba Move some field extraction logic onto a method on Node 2023-06-22 15:51:19 +00:00
Oli Scherer
30ff127036 Re-use error code for duplicate error 2023-06-22 15:51:14 +00:00
Oli Scherer
a71628c114 Treat opaque types failing the signature defining scope check as defining, as we already errored and can hide subsequent errors this way. 2023-06-22 15:36:42 +00:00
Oli Scherer
41881aece2 Stop failing eagerly, and collect all opaque types even if some are erroneous. 2023-06-22 15:08:18 +00:00
bors
2efe091705 Auto merge of #112913 - nnethercote:avoid-Lrc-Box-dyn-CodegenBackend, r=compiler-errors
Avoid `Lrc<Box<dyn CodegenBackend>>`.

Because `Lrc<Box<T>>` is silly. (Clippy warns about `Rc<Box<T>>` and `Arc<Box<T>>`, and it would warn here if (a) we used Clippy with rustc, and (b) Clippy knew about `Lrc`.)

r? `@bjorn3`
2023-06-22 15:06:03 +00:00
Oli Scherer
12243ec415 Point to argument/return type instead of the whole function header 2023-06-22 15:00:12 +00:00
Oli Scherer
bae645451e Only create the opaque collector once and visit it many times 2023-06-22 14:31:15 +00:00
Oli Scherer
c8979e587b Move opaque_type_origin_unchecked onto TyCtxt and re-use it where it was open coded 2023-06-22 14:31:15 +00:00
Oli Scherer
aacd702895 Stop hiding const eval limit in external macros 2023-06-22 14:11:10 +00:00
bors
fa06a371b7 Auto merge of #112695 - nnethercote:inline-before-merging-cgus, r=wesleywiser
Inline before merging cgus

Because CGU merging relies on CGU sizes, but the CGU sizes before inlining aren't accurate.

This change doesn't have much effect on compile perf, but it makes follow-on changes that involve more sophisticated reasoning about CGU sizes much easier.

r? `@wesleywiser`
2023-06-22 08:34:32 +00:00
bors
0928a1f757 Auto merge of #112914 - matthiaskrgr:rollup-f0kdqh9, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #112876 (Don't substitute a GAT that has mismatched generics in `OpaqueTypeCollector`)
 - #112906 (rustdoc: render the body of associated types before the where-clause)
 - #112907 (Update cargo)
 - #112908 (Print def_id on EarlyBoundRegion debug)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-22 05:42:01 +00:00
Matthias Krüger
b13c9417cf
Rollup merge of #112908 - spastorino:add-def-id-to-early-bound-region-debug, r=compiler-errors
Print def_id on EarlyBoundRegion debug

It's not the first time that I can't make sense out of the default debug print on `EarlyBoundRegion`. As I was working on #112682 I needed this.

I was doing some git archeology and found that we used to print everything dfbc9608ce/src/librustc/util/ppaux.rs (L425-L430) but we lost the ability in some refactor midway.
2023-06-22 06:29:34 +02:00
Matthias Krüger
cc93c5fca0
Rollup merge of #112876 - compiler-errors:check-subst-compat-in-OpaqueTypeCollector, r=oli-obk
Don't substitute a GAT that has mismatched generics in `OpaqueTypeCollector`

Fixes #111828

I didn't put up minimized UI tests for #112510 or #112873 because they'd minimize to literally the same code, but with different substs on the trait/impl. I don't think that warrants duplicate tests given the nature of the fix.

r? `@oli-obk`

----

Side-note: I checked, and this isn't fixed by #112652 -- I think we discussed whether or not that PR fixed it either intentionally or by accident. The code here isn't really touched by that PR either as far as I can tell?

Also, sorry, did some other drive-bys. Hope it doesn't make rebasing #112652 too difficult 😅
2023-06-22 06:29:33 +02:00
bors
fba636a387 Auto merge of #112814 - antoyo:sync-cg_gcc-2023-06-19, r=bjorn3
Sync rustc_codegen_gcc 2023/06/19

Hi.
This is a sync of the rustc_codegen_gcc subtree.
Thanks.
2023-06-22 02:11:08 +00:00
Nicholas Nethercote
abde9ba527 Tweak CGU size estimate code.
- Rename `create_size_estimate` as `compute_size_estimate`, because that
  makes more sense for the second and subsequent calls for each CGU.
- Change `CodegenUnit::size_estimate` from `Option<usize>` to `usize`.
  We can still assert that `compute_size_estimate` is called first.
- Move the size estimation for `place_mono_items` inside the function,
  for consistency with `merge_codegen_units`.
2023-06-22 09:33:06 +10:00
Nicholas Nethercote
5dd7550a08 Avoid Lrc<Box<dyn CodegenBackend>>.
Because `Lrc<Box<T>>` is silly. (Clippy warns about `Rc<Box<T>>` and
`Arc<Box<T>>`, and it would warn here if (a) we used Clippy with rustc,
and (b) Clippy knew about `Lrc`.)
2023-06-22 09:18:09 +10:00
Nicholas Nethercote
fae4f45214 Remove unused fields from CodegenContext. 2023-06-22 09:07:19 +10:00
Nicholas Nethercote
3bbf9f0128 Introduce CodegenState.
The codegen main loop has two bools, `codegen_done` and
`codegen_aborted`. There are only three valid combinations: `(false,
false)`, `(true, false)`, `(true, true)`.

This commit replaces them with a single tri-state enum, which makes
things clearer.
2023-06-22 09:07:15 +10:00
bors
f272fc3a86 Auto merge of #103503 - thomcc:tvos-support, r=workingjubilee
Support Apple tvOS in libstd

This target has existed in the compiler for a while, was `no_std`-only previously (even requiring `#![feature(restricted_std)]`). Apple tvOS is essentially the same as iOS, down to using the same version numbering, so there's no reason for this to be a `no_std`-only target the way it is currently.

Not yet tested much (I have an Apple TV, but haven't tested that this can deploy and run programs on it, nor the simulator). Uses the implementation strategy as the watchOS support in https://github.com/rust-lang/rust/pull/98101 and etc. That is, no `std::os::` interfaces aside from those in `std::os::unix`.

Includes an update to libc in order to pull in https://github.com/rust-lang/libc/pull/2958.
2023-06-21 22:45:37 +00:00
Santiago Pastorino
3ef510ca80
Print def_id on EarlyBoundRegion debug 2023-06-21 19:34:21 -03:00
Nicholas Nethercote
105ac1c26d Merge root and inlined item placement.
There's no longer any need for them to be separate, and putting them
together reduces the amount of code.
2023-06-22 08:10:29 +10:00
Nicholas Nethercote
6f228e3420 Inline before merging CGUs.
Because CGU merging relies on CGU sizes, but the CGU sizes before
inlining aren't accurate.

This requires tweaking how the sizes are updated during merging: if CGU
A and B both have an inlined function F, then `size(A + B)` will be a
little less than `size(A) + size(B)`, because `A + B` will only have one
copy of F. Also, the minimum CGU size is increased because it now has to
account for inlined functions.

This change doesn't have much effect on compile perf, but it makes
follow-on changes that involve more sophisticated reasoning about CGU
sizes much easier.
2023-06-22 08:10:29 +10:00
Nicholas Nethercote
f6cadae163 Streamline some comments. 2023-06-22 08:10:29 +10:00
Nicholas Nethercote
a521ba400d Add comments to Message and WorkItem.
This is particularly useful for `Message`.
2023-06-22 08:07:59 +10:00
Nicholas Nethercote
88cd8f9324 Simplify Message.
`Message` is an enum with multiple variants. Four of those variants map
directly onto the four variants of `WorkItemResult`. This commit reduces
those four `Message` variants to a single variant containing a
`WorkItemResult`. This requires increasing `WorkItemResult`'s visibility
to `pub(crate)` visibility, but `WorkItem` and `Message` can also have
their visibility reduced to `pub(crate)`.

This change avoids some boilerplate enum translation code, and makes
`Message` easier to understand.
2023-06-22 08:07:59 +10:00
Nicholas Nethercote
757c290fba Move Message::CodegenItem to a separate type.
`Message` is an enum with multiple variants, for messages sent to the
coordinator thread. *Except* for `Message::CodegenItem`, which is
entirely disjoint, being for messages sent from the coordinator thread
to the main thread.

This commit move `Message::CodegenItem` into a separate type,
`CguMessage`, which makes the code much clearer.
2023-06-22 08:07:59 +10:00
Thom Chiovoloni
b80e0b7f53
Reorder tvos_* functions in apple_base.rs to avoid breaking sorted order 2023-06-21 14:59:40 -07:00
Thom Chiovoloni
b18ff59690
Fix rustc_target::spec:🍎:tests 2023-06-21 14:59:40 -07:00
Thom Chiovoloni
abb1911682
Fix the tvOS targets to use the right LLVM target and respect the deployment target environment variables 2023-06-21 14:59:39 -07:00
Thom Chiovoloni
3785a17dd9
Fix busted data_layout (mismatch vs LLVM) in x86_64 tvOS simulator target 2023-06-21 14:59:39 -07:00
Guillaume Gomez
d938be153c
Rollup merge of #112892 - petrochenkov:cleanres, r=oli-obk
resolve: Minor cleanup to `fn resolve_path_with_ribs`

A single-use closure is inlined and one unnecessary enum is removed.

Noticed when reviewing https://github.com/rust-lang/rust/pull/112686.
2023-06-21 20:00:50 +02:00
Guillaume Gomez
5ed75a9628
Rollup merge of #112868 - compiler-errors:liberate-afit-sugg, r=WaffleLapkin
Liberate bound vars properly when suggesting missing async-fn-in-trait

Fixes #112848
2023-06-21 20:00:50 +02:00
Guillaume Gomez
a5561eb4d5
Rollup merge of #112538 - ndrewxie:issue-84447-partial-1, r=compiler-errors
Removed unnecessary &String -> &str, now that &String implements StableOrd as well

Applied a few nits suggested by lcnr to PR #110040 (nits can be found [here](https://github.com/rust-lang/rust/pull/110040#pullrequestreview-1469452191).)

Making a new PR because the old one was already merged, and given that this just applies changes that were already suggested, reviewing it should be fairly open-and-shut.
2023-06-21 20:00:49 +02:00
Michael Goulet
5344ed23fa Don't substitute a GAT that has mismatched generics in OpaqueTypeCollector 2023-06-21 16:33:17 +00:00
Michael Goulet
7563909a28 Liberate bound vars properly when suggesting missing AFIT 2023-06-21 16:32:26 +00:00
Vadim Petrochenkov
c007293e29 resolve: Minor cleanup to fn resolve_path_with_ribs
A single-use closure is inlined and one unnecessary enum is removed.
2023-06-21 17:48:04 +03:00
bors
536635c89b Auto merge of #112890 - GuillaumeGomez:rollup-7e01q69, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #99587 (Document memory orderings of `thread::{park, unpark}`)
 - #112836 ([rustdoc] partially fix invalid files creation)
 - #112853 (Add `lazy_type_alias` feature gate)
 - #112863 (Fix copy-paste typo in `eprint(ln)` docs)
 - #112883 (Make queries traceable again)
 - #112885 (Fix msg passed to span_bug)
 - #112886 (Revert 'Rename profile=user to profile=dist')

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-21 13:53:11 +00:00
Guillaume Gomez
82bd2e334f
Rollup merge of #112885 - imor:fix_span_bug_msg, r=cjgillot
Fix msg passed to span_bug
2023-06-21 15:45:18 +02:00
Guillaume Gomez
4f6c48b61b
Rollup merge of #112883 - oli-obk:tracing_queries, r=cjgillot
Make queries traceable again

This can't be tested without something along the lines of https://github.com/rust-lang/rust/pull/111924 unfortunately.

We could benchmark turning query tracing into an `info` level tracing statement, but let's get this fix landed first so we can actually debug properly again
2023-06-21 15:45:17 +02:00
Guillaume Gomez
009d72b3ae
Rollup merge of #112853 - GuillaumeGomez:type_alias_type, r=oli-obk
Add `lazy_type_alias` feature gate

Add the `type_alias_type` to be able to have the weak alias used without restrictions.

Part of #112792.

cc `@compiler-errors`
r? `@oli-obk`
2023-06-21 15:45:16 +02:00
Guillaume Gomez
60ec8405eb Add lazy_type_alias feature gate 2023-06-21 13:45:00 +02:00
Raminder Singh
91aef00e51 Fix msg passed to span_bug 2023-06-21 16:54:54 +05:30
bors
38b44eb233 Auto merge of #112834 - oli-obk:mir_opts_considered_unsound, r=cjgillot
Disable two mir opts that are known to be unsound

closes #112460 (does not fix the underlying issue)

r? `@cjgillot`
2023-06-21 10:53:30 +00:00
Oli Scherer
81e37743a5 Make queries traceable again 2023-06-21 10:25:25 +00:00
Oli Scherer
c409f05636 Disable two mir opts that are known to be unsound 2023-06-21 07:41:09 +00:00
Nilstrieb
82e6a16e33
Rollup merge of #112844 - Vanille-N:unique, r=RalfJung
Add retag in MIR transform: `Adt` for `Unique` may contain a reference

Following #112662 , `may_contain_reference` in `rustc_mir_transform::add_retag` underapproximates too much the types that require retagging.

r? ``@RalfJung``
2023-06-21 07:37:03 +02:00
Nilstrieb
904994e101
Rollup merge of #112830 - nnethercote:more-codegen-cleanups, r=oli-obk
More codegen cleanups

Some additional cleanups I found while looking closely at this code, following up from #112827.

r= `@oli-obk`
2023-06-21 07:37:03 +02:00
Nilstrieb
c6710d15f1
Rollup merge of #112790 - WaffleLapkin:syntactically, r=Nilstrieb
Syntactically accept `become` expressions (explicit tail calls experiment)

This adds `ast::ExprKind::Become`, implements parsing and properly gates the feature.

cc `@scottmcm`
2023-06-21 07:37:02 +02:00
Nilstrieb
a98c14f3a9
Rollup merge of #112772 - compiler-errors:clauses-1, r=lcnr
Add a fully fledged `Clause` type, rename old `Clause` to `ClauseKind`

Does two basic things before I put up a more delicate set of PRs (along the lines of #112714, but hopefully much cleaner) that migrate existing usages of `ty::Predicate` to `ty::Clause` (`predicates_of`/`item_bounds`/`ParamEnv::caller_bounds`).

1. Rename `Clause` to `ClauseKind`, so it's parallel with `PredicateKind`.
2. Add a new `Clause` type which is parallel to `Predicate`.
    * This type exposes `Clause::kind(self) -> Binder<'tcx, ClauseKind<'tcx>>` which is parallel to `Predicate::kind` 😸

The new `Clause` type essentially acts as a newtype wrapper around `Predicate` that asserts that it is specifically a `PredicateKind::Clause`. Turns out from experimentation[^1] that this is not negative performance-wise, which is wonderful, since this a much simpler design than something that requires encoding the discriminant into the alignment bits of a predicate kind, or something else like that...

r? ``@lcnr`` or ``@oli-obk``

[^1]: https://github.com/rust-lang/rust/pull/112714#issuecomment-1595653910
2023-06-21 07:37:01 +02:00
Nilstrieb
34c8e53d7a
Rollup merge of #112759 - cjgillot:closure-names, r=oli-obk
Make closure_saved_names_of_captured_variables a query.

As we will start removing debuginfo during MIR optimizations, we need to keep them somewhere.
2023-06-21 07:37:01 +02:00
bors
c55d1ee8d4 Auto merge of #112119 - zirconium-n:issue-113072-merge-borrow-kind, r=lcnr
Merge `BorrowKind::Unique` into `BorrowKind::Mut`

Fixes #112072

Might have conflict with #112070

r? `@lcnr`

I'm not sure what's the suitable change in a couple places.
2023-06-21 02:06:10 +00:00
Nicholas Nethercote
1da1348924 Remove Queries::ongoing_codegen.
There's no need to store it in `Queries`. We can just use a local
variable, because it's always used shortly after it's produced.

The commit also removes the `tcx.analysis()` call in `ongoing_codegen`,
because it's easy to ensure that's done beforehand.

All this makes the dataflow within `run_compiler` easier to follow, at
the cost of making one test slightly more verbose, which I think is a
good tradeoff.
2023-06-21 11:29:45 +10:00
Nicholas Nethercote
c696307a87 Inline and remove WorkItem::start_profiling and execute_work_item.
They both match on a `WorkItem`. It's simpler to do it all in one place.
2023-06-21 10:56:19 +10:00
Jacob Pratt
a1cd8c3a28
Add Span::{line, column} 2023-06-20 19:40:25 -04:00
Jacob Pratt
87ec0738ab
Span::{before, after}Span::{start, end} 2023-06-20 19:40:25 -04:00
Jacob Pratt
dc76991d2f
Remove LineColumn, Span::start, Span::end 2023-06-20 19:40:24 -04:00
Michael Goulet
7d0a5c31f5 yeet upcast_trait_def_id from ImplSourceObjectData 2023-06-20 23:33:02 +00:00
Michael Goulet
42571c4847 yeet ImplSource::TraitAlias too 2023-06-20 23:33:02 +00:00
Michael Goulet
db235a07f7 Remove unnecessary call to select_from_obligation
The only regression is one ambiguity in the new trait solver, having to
do with two param-env candidates that may apply. I think this is fine,
since the error message already kinda sucks.
2023-06-20 23:33:02 +00:00
bors
46514218f6 Auto merge of #112835 - lcnr:proof-tree-nits, r=BoxyUwU
proof tree nits

r? `@BoxyUwU`
2023-06-20 19:58:46 +00:00
bors
a34ceade11 Auto merge of #112847 - bvanjoi:fix-112831, r=Nilstrieb
Revert #112758 and add test case

Fixes #112831.

Cannot unwrap `update_resolution` for `resolution.single_imports.remove(&Interned::new_unchecked(import));` because there is a relationship between the `Import` and `&NameBinding` in `NameResolution`. This issue caused by my unfamiliarity with the data structure and I apologize for it.

This PR had been reverted, and test case have been added.

r? `@Nilstrieb`
cc `@petrochenkov`
2023-06-20 15:52:44 +00:00
bohan
629b50928c Revert "Rollup merge of #112758 - bvanjoi:clean-up-resolve, r=petrochenkov"
This reverts commit 3b059e0fdb, reversing
changes made to d70be67047.
2023-06-20 22:47:50 +08:00
Neven Villani
74aad5ce56
Adt for Unique may contain a reference 2023-06-20 16:30:44 +02:00
Ziru Niu
b8a250fc4f update comment on MutBorrowKind::ClosureCapture 2023-06-20 20:55:31 +08:00
Ziru Niu
a52cc0a8c9 address most easy comments 2023-06-20 20:55:31 +08:00
Ziru Niu
8fb4c41f35 merge BorrowKind::Unique into BorrowKind::Mut 2023-06-20 20:55:31 +08:00
Guillaume Gomez
0688182f9b
Rollup merge of #112794 - bjorn3:fix_lib_global_alloc, r=oli-obk
Fix linker failures when #[global_allocator] is used in a dependency

Fixes https://github.com/rust-lang/rust/issues/112715
2023-06-20 14:23:41 +02:00
Guillaume Gomez
73496fc5d5
Rollup merge of #112786 - lcnr:early-binder, r=Nilstrieb
change binders from tuple structs to named fields
2023-06-20 14:23:40 +02:00
Guillaume Gomez
6c5e212c17
Rollup merge of #112762 - chenyukang:yukang-fix-112507-argument-checking, r=compiler-errors
Sort the errors from arguments checking so that suggestions are handled properly

Fixes #112507

The algorithm of `find_issue` does not make sure the index comes out in order, which will make suggesting `remove` or `add` arguments broken in some cases.

Modifying the algorithm to obey order involves much more trivial change, so it's better to order the `errors` after iterations.
2023-06-20 14:23:40 +02:00
lcnr
e4b171a198 inspect nits 2023-06-20 14:01:03 +02:00
lcnr
f7472aa69e cleanup imports 2023-06-20 12:41:00 +02:00
lcnr
f5438d658f split probe into 2 functions for better readability 2023-06-20 12:40:43 +02:00
bors
6fc0273b5a Auto merge of #112320 - compiler-errors:do-not-impl-via-obj, r=lcnr
Add `implement_via_object` to `rustc_deny_explicit_impl` to control object candidate assembly

Some built-in traits are special, since they are used to prove facts about the program that are important for later phases of compilation such as codegen and CTFE. For example, the `Unsize` trait is used to assert to the compiler that we are able to unsize a type into another type. It doesn't have any methods because it doesn't actually *instruct* the compiler how to do this unsizing, but this is later used (alongside an exhaustive match of combinations of unsizeable types) during codegen to generate unsize coercion code.

Due to this, these built-in traits are incompatible with the type erasure provided by object types. For example, the existence of `dyn Unsize<T>` does not mean that the compiler is able to unsize `Box<dyn Unsize<T>>` into `Box<T>`, since `Unsize` is a *witness* to the fact that a type can be unsized, and it doesn't actually encode that unsizing operation in its vtable as mentioned above.

The old trait solver gets around this fact by having complex control flow that never considers object bounds for certain built-in traits:
2f896da247/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs (L61-L132)

However, candidate assembly in the new solver is much more lovely, and I'd hate to add this list of opt-out cases into the new solver. Instead of maintaining this complex and hard-coded control flow, instead we can make this a property of the trait via a built-in attribute. We already have such a build attribute that's applied to every single trait that we care about: `rustc_deny_explicit_impl`. This PR adds `implement_via_object` as a meta-item to that attribute that allows us to opt a trait out of object-bound candidate assembly as well.

r? `@lcnr`
2023-06-20 08:42:37 +00:00
Michael Goulet
ca68cf0d46 Merge attrs, better validation 2023-06-20 04:38:55 +00:00
Michael Goulet
91e5c3f2e5 Make rustc_deny_explicit_impl only local as well 2023-06-20 04:38:46 +00:00
Michael Goulet
657d3f43a9 Add rustc_do_not_implement_via_object 2023-06-20 04:38:46 +00:00
Michael Goulet
3171c989ef
Rollup merge of #112781 - compiler-errors:new-solver-tait-overlaps-hidden, r=lcnr
Don't consider TAIT normalizable to hidden ty if it would result in impossible item bounds

See test for example where we shouldn't consider it possible to alias-relate a TAIT and hidden type.

r? `@lcnr`
2023-06-19 17:53:35 -07:00
Michael Goulet
be68e9e336
Rollup merge of #112596 - compiler-errors:missing-sig-with-rpitit, r=b-naber
Suggest correct signature on missing fn returning RPITIT/AFIT

Add `async` and unpeel the future's output type if the function is async

Fixes #108195
2023-06-19 17:53:34 -07:00
Michael Goulet
935452b619
Rollup merge of #112499 - tgross35:py-ruff-fixes, r=Mark-Simulacrum
Fix python linting errors

These were flagged by `ruff`, run using the config in https://github.com/rust-lang/rust/pull/112482
2023-06-19 17:53:34 -07:00
Michael Goulet
31d1fbf8d2
Rollup merge of #112232 - fee1-dead-contrib:match-eq-const-msg, r=b-naber
Better error for non const `PartialEq` call generated by `match`

Resolves #90237
2023-06-19 17:53:33 -07:00
Antoni Boucher
f78096f57e Update Cargo.lock 2023-06-19 20:44:01 -04:00
Antoni Boucher
4d96893d85 Merge commit '1bbee3e217d75e7bc3bfe5d8c1b35e776fce96e6' into sync-cg_gcc-2023-06-19 2023-06-19 18:51:02 -04:00
bors
fe7454bf43 Auto merge of #112805 - matthiaskrgr:rollup-r5yrefu, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #109970 ([doc] `poll_fn`: explain how to `pin` captured state safely)
 - #112705 (Simplify `Span::source_callee` impl)
 - #112757 (Use BorrowFlag instead of explicit isize)
 - #112768 (Rewrite various resolve/diagnostics errors as translatable diagnostics)
 - #112777 (Continue folding in query normalizer on weak aliases)
 - #112780 (Treat TAIT equation as always ambiguous in coherence)
 - #112783 (Don't ICE on bound var in `reject_fn_ptr_impls`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-19 20:01:50 +00:00
Michael Goulet
32f83e18ab Better error message 2023-06-19 20:00:41 +00:00
Michael Goulet
dd620aa73a Don't ICE on unnormalized struct tail in layout computation 2023-06-19 20:00:41 +00:00
Lukas Markeffsky
d50875e24a use ErrorGuaranteed instead of booleans 2023-06-19 21:34:59 +02:00
bjorn3
206b951803 Fix linker failures when #[global_allocator] is used in a dependency 2023-06-19 17:31:54 +00:00
Matthias Krüger
68d3e0e3bd
Rollup merge of #112783 - compiler-errors:nlb-fnptr-reject-ice, r=fee1-dead
Don't ICE on bound var in `reject_fn_ptr_impls`

We may try to use an impl like `impl<T: FnPtr> PartialEq {}` to satisfy a predicate like `for<T> T: PartialEq` -- don't ICE in that case.

Fixes #112735
2023-06-19 19:26:28 +02:00
Matthias Krüger
263635b917
Rollup merge of #112780 - compiler-errors:tait-is-ambig, r=lcnr
Treat TAIT equation as always ambiguous in coherence

Not sure why we weren't treating all TAIT equality as ambiguous -- this behavior combined with `DefineOpaqueTypes::No` leads to coherence overlap failures, since we incorrectly consider impls as not overlapping because the obligation `T: From<Foo>` doesn't hold.

Fixes #112765
2023-06-19 19:26:28 +02:00
Matthias Krüger
68f2f1e32c
Rollup merge of #112777 - compiler-errors:normalize-weak-more, r=oli-obk
Continue folding in query normalizer on weak aliases

Fixes #112752
Fixes #112731 (same root cause, so didn't make a test for it)
fixes #112776

r? ```@oli-obk```
2023-06-19 19:26:27 +02:00
Matthias Krüger
6de869fd23
Rollup merge of #112768 - NotStirred:translatable_diag/resolve1, r=WaffleLapkin
Rewrite various resolve/diagnostics errors as translatable diagnostics

additional question:

For trivial strings is it ever accepted to use `fluent_generated::foo` in a `label` for example? Or is an empty struct `Diagnostic` preferred?
2023-06-19 19:26:27 +02:00
Matthias Krüger
af348a81a0
Rollup merge of #112705 - WaffleLapkin:simplify_source_callee_impl, r=cjgillot
Simplify `Span::source_callee` impl

Imo the iterator impl is easier to grasp.
2023-06-19 19:26:26 +02:00
bors
4051305389 Auto merge of #112238 - scottmcm:mir-add-unchecked, r=cjgillot
Promote unchecked integer math to MIR `BinOp`s

So slice indexing by a range gets down to one basic block, for example.

r? cjgillot
2023-06-19 17:14:21 +00:00
Camille GILLOT
689607e7a3 Remove duplicated comment. 2023-06-19 16:52:12 +00:00
Camille GILLOT
3a1edd8212 Store generator field names in GeneratorLayout. 2023-06-19 16:50:52 +00:00
Camille GILLOT
7d5b2e4926 Make closure_saved_names_of_captured_variables a query. 2023-06-19 16:50:52 +00:00
Michael Goulet
dcee3ab4f8 doc 2023-06-19 15:46:39 +00:00
Michael Goulet
21226eefb2 Fully fledged Clause type 2023-06-19 15:46:08 +00:00
Tom Martin
2027e989bc
Remove unreachable and untested suggestion for invalid span enum derive(Default) 2023-06-19 16:22:21 +01:00
Tom Martin
db613750a9
Reformatting 2023-06-19 16:21:33 +01:00
Michael Goulet
fca56a8d2c s/Clause/ClauseKind 2023-06-19 14:57:42 +00:00
Michael Goulet
2e8af07a8a Don't consider TAIT normalizable to hidden ty if it would result in impossible item bounds 2023-06-19 14:49:56 +00:00
bors
689511047a Auto merge of #112366 - lukas-code:test, r=Nilstrieb
`#[test]` function signature verification improvements

This PR contains two improvements to the expansion of the `#[test]` macro.

The first one fixes https://github.com/rust-lang/rust/issues/112360 by correctly recovering item statements if the signature verification fails.

The second one forbids non-lifetime generics on `#[test]` functions. These were previously allowed if the function returned `()`, but always caused an inference error:

before:
```text
error[E0282]: type annotations needed
 --> src/lib.rs:2:1
  |
1 | #[test]
  | ------- in this procedural macro expansion
2 | fn foo<T>() {}
  | ^^^^^^^^^^^^^^ cannot infer type
```

after:
```text
error: functions used as tests can not have any non-lifetime generic parameters
 --> src/lib.rs:2:1
  |
2 | fn foo<T>() {}
  | ^^^^^^^^^^^^^^
```

Also includes some basic tests for test function signature verification, because I couldn't find any (???) in the test suite.
2023-06-19 13:39:46 +00:00
Maybe Waffle
d7713feb99 Syntatically accept become expressions 2023-06-19 12:54:34 +00:00
lcnr
f2975810a5 change binders from tuple structs to named fields 2023-06-19 11:38:07 +02:00
Scott McMurray
c780e55995 Dedup some type checks in the MIR validator 2023-06-19 01:47:03 -07:00
Scott McMurray
3fd8501823 Remove unchecked_add/sub/mul/shl/shr from CTFE/cg_ssa/cg_clif 2023-06-19 01:47:03 -07:00
Scott McMurray
39788e07ba Promote unchecked_add/sub/mul/shl/shr to mir::BinOp 2023-06-19 01:47:03 -07:00
Boxy
3a6ce74c07 move to nested module 2023-06-19 09:08:03 +01:00
Boxy
9af7122b1d create module so that RUSTC_LOG can filter to just proof trees 2023-06-19 09:08:03 +01:00
Boxy
bb743f8635 allow caller to force proof tree generation 2023-06-19 09:08:03 +01:00
Boxy
51090b962f show normalizes-to hack and response instantiation goals 2023-06-19 09:06:16 +01:00
Boxy
e367c04dc6 introduce a separate set of types for finalized proof trees 2023-06-19 09:06:16 +01:00
Boxy
7a3665d016 dont use a trait 2023-06-19 09:01:37 +01:00
Boxy
3587d4ced8 say what kind of cache hit 2023-06-19 09:01:37 +01:00
Boxy
a2050ba12d add -Z flag 2023-06-19 09:01:37 +01:00
Boxy
3009b2c647 initial info dump 2023-06-19 09:01:37 +01:00
lcnr
46973c9c8a add FIXME's for a later refactoring 2023-06-19 09:16:26 +02:00
lcnr
0589cd0f0a mir opt: fix subtype handling 2023-06-19 09:06:42 +02:00
lcnr
46af169ec5 codegen: fix OperandRef subtype handling 2023-06-19 09:06:42 +02:00
lcnr
be33ad8848 fix types in shim building 2023-06-19 09:06:32 +02:00
Deadbeef
446db517af fix doc 2023-06-19 03:47:27 +00:00
yukang
aba1cf159f fix sort 2023-06-19 11:03:48 +08:00
Michael Goulet
29c74d5619 Don't ICE on bound var in reject_fn_ptr_impls 2023-06-19 02:52:03 +00:00
bors
c911e08514 Auto merge of #112617 - lqd:dump-mir-dataflow, r=tmiasko
make mir dataflow graphviz dumps opt-in

This should save some MIR traversals and allocations that are not really needed.

Small win but noticeable locally. Let's see what LTO/PGO say.

r? `@ghost`
2023-06-19 01:17:40 +00:00
Michael Goulet
d43683f2e9 Treat TAIT equation as always ambiguous in coherence 2023-06-18 22:52:30 +00:00
Michael Goulet
493b18b653 Continue folding in query normalizer on weak aliases 2023-06-18 20:56:30 +00:00
Michael Goulet
3b059e0fdb
Rollup merge of #112758 - bvanjoi:clean-up-resolve, r=petrochenkov
refactor(resolve): delete update_resolution function

The `{ resolution.single_imports.remove(); }` code block does not modify the `binding` of this `resolution`. Therefore, the result of `resolution.binding()` before and after `let t = f(self, resolution)` will remain the same, and it will always satisfy the result: `_ if old_binding.is_some() => return t` or `None => return t`.

And then we delete the `update_resolution` function because it only called once.

r? ``@petrochenkov``
2023-06-18 13:17:08 -07:00
Michael Goulet
b598ea101c
Rollup merge of #112710 - oli-obk:const_to_pat_cleanups2, r=cjgillot
Re-use the deref-pattern recursion instead of duplicating the logic

This essentially just removes code duplication
2023-06-18 13:17:07 -07:00
Michael Goulet
90e51f110c
Rollup merge of #112537 - compiler-errors:dont-record-adjustments-twice, r=cjgillot
Don't record adjustments twice in `note_source_of_type_mismatch_constraint`

We call `lookup_method` a few times in `note_source_of_type_mismatch_constraint`, but that function has side-effects to the typeck results. Replace it with a less side-effect-y variant of the function for use in diagnostics.

Specifically the ICE in #112532 happens because we're recording deref adjustments twice for a call receiver, which causes `ExprUseVisitor` to be angry.

Fixes #112532
2023-06-18 13:17:05 -07:00
bors
939786223f Auto merge of #112636 - clubby789:no-capture-array-ref, r=cjgillot
Don't capture `&[T; N]` when contents isn't read

Fixes the check in #111831
Fixes #112607, although I decided to test the root cause rather than including the example in the issue as a test.
cc `@BoxyUwU`
2023-06-18 15:48:08 +00:00
Tom Martin
c07b50a213
Fix tidy 2023-06-18 14:16:37 +01:00
bohan
894ab2ce7a refactor(resolve): delete update_resolution function 2023-06-18 21:03:59 +08:00
bors
677710eaf0 Auto merge of #112638 - lqd:rpo, r=cjgillot
Switch the BB CFG cache from postorder to RPO

The `BasicBlocks` CFG cache is interesting:
- it stores a postorder, but `traversal::postorder` doesn't use it
- `traversal::reverse_postorder` does traverse the postorder cache backwards
- we do more RPO traversals than postorder traversals (around 20x on the perf.rlo benchmarks IIRC) but it's not cached
- a couple places here and there were manually reversing the non-cached postorder traversal

This PR switches the order of the cache, and makes a bit more use of it. This is a tiny win locally, but it's also for consistency and aesthetics.

r? `@ghost`
2023-06-18 12:45:41 +00:00
Tom Martin
4b5a5a4529
Add translatable diagnostic for various strings in resolve::unresolved_macro_suggestions 2023-06-18 12:32:40 +01:00
Tom Martin
355a689542
Add translatable diagnostic for cannot find in this scope 2023-06-18 12:28:17 +01:00
Tom Martin
50c971a0b7
Add translatable diagnostic for invalid imports 2023-06-18 12:28:17 +01:00
Tom Martin
8fa9003621
Add translatable diagnostic for changing import binding 2023-06-18 12:28:16 +01:00
yukang
0b20096eff sort the errors from arguments checking so that suggestions are handled properly 2023-06-18 18:44:14 +08:00
Rémy Rakic
08a9f25245 remove redundant combinators between PO and RPO 2023-06-18 09:16:40 +00:00
Matthias Krüger
3436069c34
Rollup merge of #112734 - dswij:bounds-predicates-clause, r=compiler-errors
Make `Bound::predicates`  use `Clause`

Part of #107250

`Bound::predicates` returns an iterator over `Binder<_, Clause>` instead of `Predicate`.

I tried updating `explicit_predicates_of` as well, but it seems that it needs a lot more change than I thought. Will do it in a separate PR instead.
2023-06-18 08:06:43 +02:00
Matthias Krüger
8d3d3cc0ba
Rollup merge of #112667 - compiler-errors:wf-goal-is-clause, r=lcnr
Move WF/ConstEvaluatable goal to clause

It can show up in a param-env, so I think it needs to be a clause kind.

r? ```@lcnr``` or ```@oli-obk```
2023-06-18 08:06:41 +02:00