Commit Graph

274 Commits

Author SHA1 Message Date
Arpad Borsos 9f36f988ad Avoid GenFuture shim when compiling async constructs
Previously, async constructs would be lowered to "normal" generators,
with an additional `from_generator` / `GenFuture` shim in between to
convert from `Generator` to `Future`.

The compiler will now special-case these generators internally so that
async constructs will *directly* implement `Future` without the need
to go through the `from_generator` / `GenFuture` shim.

The primary motivation for this change was hiding this implementation
detail in stack traces and debuginfo, but it can in theory also help
the optimizer as there is less abstractions to see through.
2022-11-24 10:04:27 +01:00
Maybe Waffle b80356a5ab Use tcx.require_lang_item instead of unwrapping 2022-11-22 17:19:19 +00:00
Oli Scherer 7658e0fccf Stop passing the self-type as a separate argument. 2022-11-21 20:39:46 +00:00
Oli Scherer ad57f88d3f Add helper to create the trait ref for a lang item 2022-11-21 20:35:17 +00:00
Oli Scherer ec8d01fdcc Allow iterators instead of requiring slices that will get turned into iterators 2022-11-21 20:33:55 +00:00
Oli Scherer 6f77c97b38 Assert that various types have the right amount of generic args and fix the sites that used the wrong amount 2022-11-21 20:31:59 +00:00
Matthias Krüger c571b2a964 Rollup merge of #104593 - compiler-errors:rpitit-object-safety-spans, r=fee1-dead
Improve spans for RPITIT object-safety errors

No reason why we can't point at the `impl Trait` that causes the object-safety violation.

Also [drive-by: Add is_async fn to hir::IsAsync](https://github.com/rust-lang/rust/pull/104593/commits/c4165f3a965e258531928180195637455299c6f3), which touches clippy too.
2022-11-19 15:35:23 +01:00
Dylan DPC 00876c68c4 Rollup merge of #104411 - lcnr:bivariance-nll, r=compiler-errors
nll: correctly deal with bivariance

fixes #104409

when in a bivariant context, relating stuff should always trivially succeed. Also changes the mir validator to correctly deal with higher ranked regions.

r? types cc ``@RalfJung``
2022-11-19 11:54:44 +05:30
Michael Goulet c4165f3a96 drive-by: Add is_async fn to hir::IsAsync 2022-11-19 02:22:24 +00:00
Matthias Krüger ed97f245f1 Rollup merge of #104483 - oli-obk:santa-clauses-make-goals, r=compiler-errors
Convert predicates into Predicate in the Obligation constructor

instead of having almost all callers do that.

This reduces a bit of boilerplate, and also paves the way for my work towards https://github.com/rust-lang/compiler-team/issues/531 (as it makes it easier to accept both goals and clauses where right now it only accepts predicates).
2022-11-17 22:33:19 +01:00
yukang 20ea083d87 fix #104390, fix ICE in in_operand for ty error 2022-11-16 17:48:13 +08:00
Oli Scherer 4f11f3b257 Convert predicates into Predicate in the Obligation constructor 2022-11-16 09:25:19 +00:00
lcnr 6aa611a84c mv utility methods into separate module 2022-11-15 13:50:13 +01:00
lcnr 45f441a7b4 nll: correctly deal with bivariance 2022-11-15 13:34:08 +01:00
Dylan DPC 77a44ab568 Rollup merge of #103865 - compiler-errors:fallback-has-occurred-tracking, r=eholk
Move `fallback_has_occurred` state tracking to `FnCtxt`

Removes a ton of callsites that defaulted to `false`
2022-11-08 11:23:51 +05:30
Michael Goulet bc345d7bd0 Move fallback_has_occurred to FnCtxt 2022-11-06 02:40:25 +00:00
bors a4ab2e0643 Auto merge of #103975 - oli-obk:tracing, r=jackh726
Some tracing and comment cleanups

Pulled out of https://github.com/rust-lang/rust/pull/101900 to see if that is the perf impact
2022-11-06 02:21:34 +00:00
Matthias Krüger ad01a37ca9 Rollup merge of #103868 - compiler-errors:trait-engine-less, r=jackh726
Use `TraitEngine` (by itself) less

Replace `TraitEngine` in favor of `ObligationCtxt` or `fully_solve_*`, improving code readability.
2022-11-05 00:02:04 +01:00
Oli Scherer 44d1936d00 Some tracing and comment cleanups 2022-11-04 17:10:07 +00:00
Matthias Krüger 61c6cdb5f4 Rollup merge of #103915 - chenyukang:yukang/fix-103874, r=lcnr
Improve use of ErrorGuaranteed and code cleanup

Part of #103874
2022-11-04 06:40:32 +01:00
yukang a21a055ca6 remove 'delay_span_bug' following 'references_error' 2022-11-03 09:22:08 +08:00
Michael Goulet 41e4218d2a Use TraitEngine less 2022-11-02 04:11:05 +00:00
Maybe Waffle a17ccfa621 Accept TyCtxt instead of TyCtxtAt in Ty::is_* functions
Functions in answer:

- `Ty::is_freeze`
- `Ty::is_sized`
- `Ty::is_unpin`
- `Ty::is_copy_modulo_regions`
2022-10-27 15:06:08 +04:00
bors bed4ad65bf Auto merge of #102340 - JakobDegen:pass-manager-simplification, r=oli-obk
Split phase change from `MirPass`

The main goal here is to simplify the pass manager logic. `MirPass` no longer contains the `phase_change` method, and `run_passes` instead accepts an `Option<PhaseChange>`. The hope is that this addresses the comments (and maybe perf regression) from #99102 .

r? `@oli-obk` cc `@RalfJung`
2022-10-25 15:55:39 +00:00
Dylan DPC 8ba2a651fb Rollup merge of #103122 - ouz-a:mir-technical-debt, r=oli-obk
Remove misc_cast and validate types when casting

Continuing our work in #102675

r? ````@oli-obk````
2022-10-25 14:43:14 +05:30
Jakob Degen be2401b8bf Split phase change from MirPass 2022-10-23 14:18:09 -07:00
ouz-a 4bd98443ed remove misc_cast and validate types 2022-10-23 18:47:16 +03:00
Gimgim 49f34bd814 Surround type with backticks 2022-10-15 15:28:29 +05:30
Michael Goulet af3c6f9a03 Delay intrinsic call until after we've determined the callee is a function 2022-10-13 03:10:00 +00:00
Matthias Krüger c731646d6a Rollup merge of #102675 - ouz-a:mir-technical-debt, r=oli-obk
Remove `mir::CastKind::Misc`

As discussed in #97649 `mir::CastKind::Misc` is not clear, this PR addresses that by creating a new enum variant for every valid cast.

r? ````@oli-obk````
2022-10-08 14:38:18 +02:00
Cameron Steffen 283abbf0e7 Change InferCtxtBuilder from enter to build 2022-10-07 07:10:40 -05:00
Cameron Steffen 4a68373217 Introduce TypeErrCtxt
TypeErrCtxt optionally has a TypeckResults so that InferCtxt doesn't
need to.
2022-10-07 07:06:16 -05:00
ouz-a d59c7ff000 Remove mir::CastKind::Misc 2022-10-06 15:32:41 +03:00
fee1-dead b7d9de72ac Rollup merge of #102194 - fee1-dead-contrib:improve-const-drop, r=oli-obk
Note the type when unable to drop values in compile time
2022-09-25 22:06:39 +08:00
Deadbeef 2ce1cd511f Note the type when unable to drop values in compile time 2022-09-24 20:32:51 +00:00
b-naber a705e65605 rename Unevaluated to UnevaluatedConst 2022-09-23 14:27:34 +02:00
b-naber 9f3784df89 introduce mir::Unevaluated 2022-09-22 12:35:28 +02:00
bors 7a8636c843 Auto merge of #100982 - fee1-dead-contrib:const-impl-requires-const-trait, r=oli-obk
Require `#[const_trait]` on `Trait` for `impl const Trait`

r? `@oli-obk`
2022-09-22 04:22:24 +00:00
bors 4136b59b7d Auto merge of #99806 - oli-obk:unconstrained_opaque_type, r=estebank
Allow patterns to constrain the hidden type of opaque types

fixes #96572

reverts a revert as original PR was a perf regression that was fixed by reverting it: https://github.com/rust-lang/rust/pull/99368#issuecomment-1186587864)

TODO:

* check if https://github.com/rust-lang/rust/issues/99685 is avoided
2022-09-20 12:09:52 +00:00
lcnr 647052fc04 remove the Subst trait, always use EarlyBinder 2022-09-19 11:37:27 +02:00
bors c524c7dd25 Auto merge of #98588 - b-naber:valtrees-cleanup, r=lcnr
Use only ty::Unevaluated<'tcx, ()> in type system

r? `@lcnr`
2022-09-17 03:04:22 +00:00
Oli Scherer 40e2de8c41 Revert "Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank""
This reverts commit 4a742a691e.
2022-09-16 11:36:39 +00:00
Deadbeef f8813cf10e do const trait method bounds check later in rustc_const_eval 2022-09-16 11:48:43 +08:00
b-naber 6af8fb7936 address review again 2022-09-14 17:30:25 +02:00
Eric Holk cf04547b0b Address code review comments 2022-09-13 14:50:12 -07:00
b-naber a7735cd329 fixes/working version 2022-09-13 17:41:02 +02:00
b-naber a4bbb8db5c use ty::Unevaluated<'tcx, ()> in type system 2022-09-13 17:40:59 +02:00
Eric Holk 549c105bb3 dyn* through more typechecking and MIR 2022-09-12 16:55:56 -07:00
bors 1120c5e01d Auto merge of #101437 - compiler-errors:erase-normalize-ordering, r=tmandry
Normalize before erasing late-bound regions in `equal_up_to_regions`

Normalize erasing regions **first**, before passing the type through a `BottomUpFolder` which erases late-bound regions too.

The root cause of this issue is due to 96d4137dee, which removes a `normalize_erasing_regions` that happens before this call to `equal_up_to_regions`. While reverting that commit might be a fix, I think it was suspicious to be erasing late-bound regions first _then_ normalizing types in the first place in `equal_up_to_regions`.

-----

I am tempted to ask the reviewer to review and `r+` this without a UI test, since the existing issues that I think this fixes are all incredibly difficult to minimize (anything hyper/warp related, given the nature of those libraries 😓) or impossible to reproduce locally (the miri test), namely:
* This recently reported issue with tokio + warp: #101430
* This issue from `@RalfJung` about Miri being broken: #101344
* This additional issue reported in a comment by `@tmandry` (issue with fuchsia + hyper): https://github.com/rust-lang/rust/issues/101344#issuecomment-1235974564

I have locally verified that the repro in #101430 is fixed with this PR, but after a couple of hours of attempting to minimize this error and either failing to actually repro the ICE, or being overwhelmed with the number of traits and functions I need to inline into a UI test, I have basically given up. Thoughts are appreciated on how best to handle this.

r? `@oli-obk` who is at the intersection of MIR and types-related stuff who may be able to give advice 😅
2022-09-08 19:01:39 +00:00
Oli Scherer b7413511dc Generalize the Assume intrinsic statement to a general Intrinsic statement 2022-09-06 14:18:32 +00:00