Commit Graph

493 Commits

Author SHA1 Message Date
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
bors
6153d3cbe6 Auto merge of #101212 - eholk:dyn-star, r=compiler-errors
Initial implementation of dyn*

This PR adds extremely basic and incomplete support for [dyn*](https://smallcultfollowing.com/babysteps//blog/2022/03/29/dyn-can-we-make-dyn-sized/). The goal is to get something in tree behind a flag to make collaboration easier, and also to make sure the implementation so far is not unreasonable. This PR does quite a few things:

* Introduce `dyn_star` feature flag
* Adds parsing for `dyn* Trait` types
* Defines `dyn* Trait` as a sized type
* Adds support for explicit casts, like `42usize as dyn* Debug`
  * Including const evaluation of such casts
* Adds codegen for drop glue so things are cleaned up properly when a `dyn* Trait` object goes out of scope
* Adds codegen for method calls, at least for methods that take `&self`

Quite a bit is still missing, but this gives us a starting point. Note that this is never intended to become stable surface syntax for Rust, but rather `dyn*` is planned to be used as an implementation detail for async functions in dyn traits.

Joint work with `@nikomatsakis` and `@compiler-errors.`

r? `@bjorn3`
2022-09-14 18:10:51 +00:00
Jack Huey
aae37f8763 Use Predicate ConstraintCategory when normalizing 2022-09-13 20:18:49 -04:00
Jack Huey
c75817b0a7 Better errors for implied static bound 2022-09-13 20:18:04 -04:00
Jack Huey
ff623ffc39 Cleanup retrieve_closure_constraint_info 2022-09-13 19:58:53 -04:00
Jack Huey
2be6301857 Remove unused body args 2022-09-13 19:58:53 -04:00
Camille GILLOT
494af379c4 Use def_span for external requirements. 2022-09-13 19:18:24 +02:00
Camille GILLOT
1f370d9437 Use tcx.hir() utils for spans in MIR building.
This corrects the `span_with_body` in the case of closures, which was
incorrectly shortened to the `def_span`.
2022-09-13 19:18:23 +02:00
Camille GILLOT
ffe20d61d6 Only keep one version of ImplicitSelfKind. 2022-09-13 19:18:23 +02:00
Michael Goulet
b2ed2dcaae Rename some variants 2022-09-12 16:55:59 -07:00
Eric Holk
549c105bb3 dyn* through more typechecking and MIR 2022-09-12 16:55:56 -07:00
KaDiWa
66211d83f9
Avoid Iterator::last 2022-09-11 17:23:00 +02:00
bors
2287107588 Auto merge of #98559 - jackh726:remove-reempty, r=oli-obk
Remove ReEmpty

r? rust-lang/types
2022-09-10 20:54:01 +00:00
Camille GILLOT
05812df603 Handle generic parameters. 2022-09-09 01:31:46 +00:00
Jack Huey
1ca9eb8ec3 Remove ReEmpty 2022-09-08 20:55:55 -04:00
Jack Huey
e7e5feb637 In ReverseMapper, don't fallback to ReEmpty, instead ReStatic 2022-09-08 17:57:34 -04:00
Jack Huey
f29c91bf12 Create VarValue::Empty 2022-09-08 17:57:32 -04:00
Dylan DPC
720a82dd52
Rollup merge of #101545 - TaKO8Ki:remove-unnecessary-partialord-ord, r=oli-obk
Remove unnecessary `PartialOrd` and `Ord`
2022-09-08 20:48:38 +05:30
Takayuki Maeda
bdc865d8f7 remove unnecessary PartialOrd and Ord 2022-09-08 06:15:33 +09:00
Oli Scherer
a0130e62ec Check all operands, they may contain indirections in their place 2022-09-06 15:32:35 +00:00
Oli Scherer
b7413511dc Generalize the Assume intrinsic statement to a general Intrinsic statement 2022-09-06 14:18:32 +00:00
Oli Scherer
3f07645120 Lower the assume intrinsic to a MIR statement 2022-09-06 14:18:32 +00:00
bors
6c358c67d4 Auto merge of #101241 - camsteffen:refactor-binding-annotations, r=cjgillot
`BindingAnnotation` refactor

* `ast::BindingMode` is deleted and replaced with `hir::BindingAnnotation` (which is moved to `ast`)
* `BindingAnnotation` is changed from an enum to a tuple struct e.g. `BindingAnnotation(ByRef::No, Mutability::Mut)`
* Associated constants added for convenience `BindingAnnotation::{NONE, REF, MUT, REF_MUT}`

One goal is to make it more clear that `BindingAnnotation` merely represents syntax `ref mut` and not the actual binding mode. This was especially confusing since we had `ast::BindingMode`->`hir::BindingAnnotation`->`thir::BindingMode`.

I wish there were more symmetry between `ByRef` and `Mutability` (variant) naming (maybe `Mutable::Yes`?), and I also don't love how long the name `BindingAnnotation` is, but this seems like the best compromise. Ideas welcome.
2022-09-06 03:16:29 +00:00
bors
b44197abb0 Auto merge of #101261 - TaKO8Ki:separate-receiver-from-arguments-in-hir, r=cjgillot
Separate the receiver from arguments in HIR

Related to #100232

cc `@cjgillot`
2022-09-05 16:21:40 +00:00
Takayuki Maeda
9cde34e180 use propagate_through_exprs instead of propagate_through_expr
fix `ExprKind` static_assert_size

fix hir-stats
2022-09-05 23:11:34 +09:00
bors
2dc703fd6e Auto merge of #101228 - nnethercote:simplify-hir-PathSegment, r=petrochenkov
Simplify `hir::PathSegment`

r? `@petrochenkov`
2022-09-05 13:36:54 +00:00
Takayuki Maeda
fea1c5f5c8 refactor: remove unnecessary variables 2022-09-05 22:31:02 +09:00
Takayuki Maeda
87c6da363f separate the receiver from arguments in HIR 2022-09-05 22:25:49 +09:00
Michael Goulet
41d4ea2314 Don't suggest reborrow if usage is inside a closure 2022-09-05 04:27:07 +00:00
Nicholas Nethercote
bb0ae3c446 Make hir::PathSegment::hir_id non-optional. 2022-09-05 14:20:25 +10:00
Cameron Steffen
02ba216e3c Refactor and re-use BindingAnnotation 2022-09-02 12:55:05 -05:00
Matthias Krüger
1bafe0b020
Rollup merge of #101285 - TaKO8Ki:do-not-suggest-adding-move-when-closure-is-already-marked-as-move, r=oli-obk
Do not suggest adding `move` to closure when `move` is already used

Fixes #101227
2022-09-01 21:37:21 +02:00
Oli Scherer
1fc9ef1edd tracing::instrument cleanup 2022-09-01 14:54:27 +00:00
Oli Scherer
ee3c835018 Always import all tracing macros for the entire crate instead of piecemeal by module 2022-09-01 14:54:27 +00:00
Oli Scherer
d3b22c7267 Directly use the instrument macro instead of its full path 2022-09-01 14:53:46 +00:00
Takayuki Maeda
78e9bea598 do not suggest adding move to closure when move is already used 2022-09-01 23:50:51 +09:00
bors
a0d07093f8 Auto merge of #100812 - Nilstrieb:revert-let-chains-nightly, r=Mark-Simulacrum
Revert let_chains stabilization

This is the revert against master, the beta revert was already done in #100538.

Bumps the stage0 compiler which already has it reverted.
2022-08-30 05:48:22 +00:00
Matthias Krüger
7b84298f1b
Rollup merge of #101146 - jackh726:borrowck-logging, r=compiler-errors
Various changes to logging of borrowck-related code

Cleanups found when doing other changes

r? `@compiler-errors`
2022-08-29 21:12:59 +02:00
Nilstrieb
d1ef8180f9 Revert let_chains stabilization
This reverts commit 3266460749.

This is the revert against master, the beta revert was already done in #100538.
2022-08-29 19:34:11 +02:00
Jack Huey
8033c3c27d Various changes to logging of borrowck-related code 2022-08-29 10:59:21 -04:00
Matthias Krüger
d182081de1
Rollup merge of #99027 - tmiasko:basic-blocks, r=oli-obk
Replace `Body::basic_blocks()` with field access

Since the refactoring in #98930, it is possible to borrow the basic blocks
independently from other parts of MIR by accessing the `basic_blocks` field
directly.

Replace unnecessary `Body::basic_blocks()` method with a direct field access,
which has an additional benefit of borrowing the basic blocks only.
2022-08-29 06:34:43 +02:00
Matthias Krüger
c5770219f2
Rollup merge of #101002 - estebank:hashmap-idx, r=davidtwco
Provide structured suggestion for `hashmap[idx] = val`
2022-08-28 09:35:18 +02:00
Tomasz Miąsko
b48870b451 Replace Body::basic_blocks() with field access 2022-08-26 14:27:08 +02:00
AndyJado
622217da59 diag-mig 2022-08-26 10:32:59 +08:00
Esteban Küber
752902957b Provide structured suggestion for hashmap[idx] = val 2022-08-25 08:44:36 -07:00
Matthias Krüger
75b1b69171
Rollup merge of #100940 - TaKO8Ki:do-not-suggest-adding-bound-to-opaque-type, r=fee1-dead
Do not suggest adding a bound to a opaque type

fixes #100442
2022-08-24 18:20:20 +02:00
Matthias Krüger
95135bed61
Rollup merge of #100906 - ChayimFriedman2:map-index-mut, r=davidtwco
Suggest alternatives when trying to mutate a `HashMap`/`BTreeMap` via indexing

The error can be quite confusing to newcomers.

Fixes #100873.

I'm not so sure about the message, open to wording suggestions.
2022-08-24 18:20:13 +02:00
Matthias Krüger
1c0f60f904
Rollup merge of #100901 - TaKO8Ki:make-some-methods-private, r=sanxiyn
Make some methods private
2022-08-24 18:20:12 +02:00
Takayuki Maeda
3855e039a2 do not suggest adding a bound to a opaque type 2022-08-24 11:34:14 +09:00
Chayim Refael Friedman
b0255a1849 Suggest alternatives when trying to mutate a HashMap/BTreeMap via indexing
The error can be quite confusing to newcomers.
2022-08-23 15:15:34 +00:00