Commit graph

3099 commits

Author SHA1 Message Date
bors 6077b7cda4 Auto merge of #99013 - RalfJung:dont-poison-my-places, r=oli-obk
interpret: get rid of MemPlaceMeta::Poison

This is achieved by refactoring the projection code (`{mplace,place,operand}_{downcast,field,index,...}`) so that we no longer need to call `assert_mem_place` in the operand handling.
2022-07-15 08:57:59 +00:00
Dylan DPC 7b63058d13
Rollup merge of #99131 - compiler-errors:label-fn, r=cjgillot
Add label for generic arg (+ APIT) and RPIT callables in `label_fn_like`

Fixes #98308
2022-07-15 10:39:43 +05:30
bors 30243dd87e Auto merge of #98203 - kckeiks:gather-body-owners-in-hir-item-queries, r=cjgillot
gather body owners

Issue #96341
2022-07-15 01:03:55 +00:00
Michael Goulet d25abdc0c5 Point out custom Fn-family trait impl 2022-07-14 23:36:46 +00:00
bors 74621c764e Auto merge of #99242 - Dylan-DPC:rollup-34bqdh8, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #98072 (Add provider API to error trait)
 - #98580 (Emit warning when named arguments are used positionally in format)
 - #99000 (Move abstract const to middle)
 - #99192 (Fix spans for asm diagnostics)
 - #99222 (Better error message for generic_const_exprs inference failure)
 - #99236 (solaris: unbreak build on native platform)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-14 16:23:07 +00:00
Dylan DPC ecae3d74e2
Rollup merge of #99000 - JulianKnodt:allow_resolve_no_substs, r=lcnr
Move abstract const to middle

Moves AbstractConst (and all associated methods) to rustc middle for use in `rustc_infer`.
This allows for const resolution in infer to use abstract consts to walk consts and check if
they are resolvable.

This attempts to resolve the issue where `Foo<{ concrete const }, generic T>` is incorrectly marked as conflicting, and is independent from the other issue where nested abstract consts must be resolved.

r? `@lcnr`
2022-07-14 19:24:04 +05:30
bors 24699bcbad Auto merge of #95956 - yaahc:stable-in-unstable, r=cjgillot
Support unstable moves via stable in unstable items

part of https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/moving.20items.20to.20core.20unstably and a blocker of https://github.com/rust-lang/rust/pull/90328.

The libs-api team needs the ability to move an already stable item to a new location unstably, in this case for Error in core. Otherwise these changes are insta-stable making them much harder to merge.

This PR attempts to solve the problem by checking the stability of path segments as well as the last item in the path itself, which is currently the only thing checked.
2022-07-14 13:42:09 +00:00
bors f1a8854f9b Auto merge of #99231 - Dylan-DPC:rollup-0tl8c0o, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #97720 (Always create elided lifetime parameters for functions)
 - #98315 (Stabilize `core::ffi:c_*` and rexport in `std::ffi`)
 - #98705 (Implement `for<>` lifetime binder for closures)
 - #99126 (remove allow(rustc::potential_query_instability) in rustc_span)
 - #99139 (Give a better error when `x dist` fails for an optional tool)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-14 11:00:30 +00:00
kadmin 20fb8aba8f Fix overlapping impls 2022-07-14 09:01:17 +00:00
Dylan DPC e5a86d7358
Rollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillot
Implement `for<>` lifetime binder for closures

This PR implements RFC 3216 ([TI](https://github.com/rust-lang/rust/issues/97362)) and allows code like the following:

```rust
let _f = for<'a, 'b> |a: &'a A, b: &'b B| -> &'b C { b.c(a) };
//       ^^^^^^^^^^^--- new!
```

cc ``@Aaron1011`` ``@cjgillot``
2022-07-14 14:14:21 +05:30
bors 0ed9c64c3e Auto merge of #98975 - jyn514:unstable_opts, r=wesleywiser
Rename `debugging_opts` to `unstable_opts`

This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`).
Rename it to be more clear.

cc https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Codegen.20options.20.2F.20debugging.20options

r? `@Amanieu` cc `@nikic` `@joshtriplett`
2022-07-14 08:14:31 +00:00
Joshua Nelson 3c9765cff1 Rename debugging_opts to unstable_opts
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`).
Rename it to be more clear.
2022-07-13 17:47:06 -05:00
Ralf Jung e4593ef0f2 assigning to a union field can never drop now 2022-07-13 18:27:28 -04:00
Miguel Guarniz 2d265b6f75 collect module item-likes in visit_items
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-13 13:54:45 -04:00
bors c80dde43f9 Auto merge of #99210 - Dylan-DPC:rollup-879cp1t, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #98574 (Lower let-else in MIR)
 - #99011 (`UnsafeCell` blocks niches inside its nested type from being available outside)
 - #99030 (diagnostics: error messages when struct literals fail to parse)
 - #99155 (Keep unstable target features for asm feature checking)
 - #99199 (Refactor: remove an unnecessary `span_to_snippet`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-13 17:13:27 +00:00
Miguel Guarniz 275497c35e merge visitors in queries
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-13 12:22:49 -04:00
Miguel Guarniz b599cf45d6 inline associated_body
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-13 12:22:49 -04:00
Miguel Guarniz c6e7c0514f use gathered body_owners in par_body_owners
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-13 12:22:25 -04:00
bors 42bd138126 Auto merge of #98145 - ouz-a:some_branch, r=oli-obk
Pull Derefer before ElaborateDrops

_Follow up work to #97025 #96549 #96116 #95887 #95649_

This moves `Derefer` before `ElaborateDrops` and creates a new `Rvalue` called `VirtualRef` that allows us to bypass many constraints for `DerefTemp`.

r? `@oli-obk`
2022-07-13 14:32:33 +00:00
Ralf Jung 874a130ca0 get rid of MemPlaceMeta::Poison
MPlaceTy::dangling still exists, but now it is only called in places that
actually conceptually allocate something new, so that's fine.
2022-07-13 10:22:59 -04:00
Dylan DPC 1e7d04b23b
Rollup merge of #99011 - oli-obk:UnsoundCell, r=eddyb
`UnsafeCell` blocks niches inside its nested type from being available outside

fixes #87341

This implements the plan by `@eddyb` in https://github.com/rust-lang/rust/issues/87341#issuecomment-886083646

Somewhat related PR (not strictly necessary, but that cleanup made this PR simpler): #94527
2022-07-13 19:32:34 +05:30
Dylan DPC 0083cd2fd4
Rollup merge of #98574 - dingxiangfei2009:let-else-thir, r=oli-obk
Lower let-else in MIR

This MR will switch to lower let-else statements in MIR building instead.

To lower let-else in MIR, we build a mini-switch two branches. One branch leads to the matching case, and the other leads to the `else` block. This arrangement will allow temporary lifetime analysis running as-is so that the temporaries are properly extended according to the same rule applied to regular `let` statements.

cc https://github.com/rust-lang/rust/issues/87335

Fix #98672
2022-07-13 19:32:33 +05:30
Maybe Waffle df4fee9841 Add an indirection for closures in hir::ExprKind
This helps bring `hir::Expr` size down, `Closure` was the biggest
variant, especially after `for<>` additions.
2022-07-12 21:00:13 +04:00
Dylan DPC 01c24213cb
Rollup merge of #99154 - rosehuds:master, r=cjgillot
use PlaceRef::iter_projections to fix old FIXME

I added this function in 53481a5a8f
2022-07-12 17:06:35 +05:30
Dylan DPC c0bcbe8a6e
Rollup merge of #99038 - jackh726:earlybinder-cleanup, r=lcnr
Some more `EarlyBinder` cleanups

First commit has a couple unrelated cleanups, but otherwise each commit is self-explanatory

r? rust-lang/types
2022-07-12 17:06:34 +05:30
ouz-a cb0017f2f8 add new rval, pull deref early 2022-07-12 14:26:41 +03:00
kadmin e612e2603c Move abstract const to rustc_middle::ty 2022-07-12 02:21:31 +00:00
Ding Xiang Fei 1cd30e7b32
move else block into the Local struct 2022-07-11 23:20:37 +02:00
Ding Xiang Fei 6c529ded86
lower let-else in MIR instead 2022-07-11 23:20:36 +02:00
Rose Hudson d84f7394a4 use PlaceRef::iter_projections to fix old FIXME
I added this function in 53481a5a8f
2022-07-11 14:42:49 +01:00
Oli Scherer 984db78d77 Hide niches in SIMD types, too 2022-07-11 10:25:41 +00:00
Oli Scherer 423915590b More obvious closure name 2022-07-11 10:11:28 +00:00
Matthias Krüger 86af7135ae
Rollup merge of #99103 - TaKO8Ki:avoid-&str-to-string-conversions, r=oli-obk
Avoid some `&str` to `String` conversions

This patch removes some `&str` to `String` conversions.
2022-07-10 11:52:17 +02:00
Takayuki Maeda bda83e6543 avoid some &str to String conversions 2022-07-10 03:18:56 +09:00
bors f893495e3d Auto merge of #98957 - RalfJung:zst-are-different, r=lcnr,oli-obk
don't allow ZST in ScalarInt

There are several indications that we should not ZST as a ScalarInt:
- We had two ways to have ZST valtrees, either an empty `Branch` or a `Leaf` with a ZST in it.
  `ValTree::zst()` used the former, but the latter could possibly arise as well.
- Likewise, the interpreter had `Immediate::Uninit` and `Immediate::Scalar(Scalar::ZST)`.
- LLVM codegen already had to special-case ZST ScalarInt.

So I propose we stop using ScalarInt to represent ZST (which are clearly not integers). Instead, we can add new ZST variants to those types that did not have other variants which could be used for this purpose.

Based on https://github.com/rust-lang/rust/pull/98831. Only the commits starting from "don't allow ZST in ScalarInt" are new.

r? `@oli-obk`
2022-07-09 17:16:00 +00:00
Ralf Jung 4e7aaf1f44 tweak names and output and bless 2022-07-09 07:43:56 -04:00
Ralf Jung ac265cdc19 review feedback 2022-07-09 07:27:29 -04:00
Ralf Jung a422b42159 don't allow ZST in ScalarInt
There are several indications that we should not ZST as a ScalarInt:
- We had two ways to have ZST valtrees, either an empty `Branch` or a `Leaf` with a ZST in it.
  `ValTree::zst()` used the former, but the latter could possibly arise as well.
- Likewise, the interpreter had `Immediate::Uninit` and `Immediate::Scalar(Scalar::ZST)`.
- LLVM codegen already had to special-case ZST ScalarInt.

So instead add new ZST variants to those types that did not have other variants
which could be used for this purpose.
2022-07-09 07:27:29 -04:00
Matthias Krüger 140250c487
Rollup merge of #99050 - JakobDegen:storage-docs, r=tmiasko
Clarify MIR semantics of storage statements

Seems worthwhile to start closing out some of the less controversial open questions about MIR semantics. Hopefully this is fairly non-controversial - it's what we implement already, and I see no reason to do anything more restrictive. cc ``@tmiasko`` who commented on this when it was discussed in the original PR that added these docs.
2022-07-09 12:52:51 +02:00
bors 86b8dd5389 Auto merge of #99028 - tmiasko:inline, r=estebank
Miscellaneous inlining improvements

Add `#[inline]` to a few trivial non-generic methods from a perf report
that otherwise wouldn't be candidates for inlining.
2022-07-09 04:34:51 +00:00
Jakob Degen 4939f6c64b Clarify MIR semantics of storage statements 2022-07-08 16:58:24 -07:00
Jane Losare-Lusby e4e6b1ebc6 fixes post rebase 2022-07-08 21:18:16 +00:00
Jane Lusby e7fe5456c5 Support unstable moves via stable in unstable items 2022-07-08 21:18:13 +00:00
bors 052495d001 Auto merge of #98614 - oli-obk:take_unsound_opaque_types, r=wesleywiser
don't succeed `evaluate_obligation` query if new opaque types were registered

fixes #98608
fixes #98604

The root cause of all this is that in type flag computation we entirely ignore nongeneric things like struct fields and the signature of function items. So if a flag had to be set for a struct if it is set for a field, that will only happen if the field is generic, as only the generic parameters are checked.

I now believe we cannot use type flags to handle opaque types. They seem like the wrong tool for this.

Instead, this PR replaces the previous logic by adding a new variant of `EvaluatedToOk`: `EvaluatedToOkModuloOpaqueTypes`, which says that there were some opaque types that got hidden types bound, but that binding may not have been legal (because we don't know if the opaque type was in its defining scope or not).
2022-07-08 17:55:26 +00:00
Oli Scherer 69b1b3c011 Create a custom layout path for UnsafeCell instead of piggy backing on the layout_scalar_valid_range logic 2022-07-08 14:48:38 +00:00
Oli Scherer d6b93eb793 Only register hidden types for opaque types from the current crate, nothing else would work anyway. 2022-07-08 13:59:44 +00:00
Dylan DPC 54dde8678b
Rollup merge of #98794 - compiler-errors:conflicting-param-env, r=michaelwoerister
Highlight conflicting param-env candidates

This could probably be further improved by noting _why_ equivalent param-env candidates (modulo regions) leads to ambiguity.

Fixes #98786
2022-07-08 18:25:51 +05:30
Matthias Krüger e58c2d4f52
Rollup merge of #99019 - pierwill:doc-mir-statement, r=cjgillot
Add doc comments in `rustc_middle::mir`
2022-07-08 08:00:40 +02:00
Matthias Krüger 5dcd28cd19
Rollup merge of #98795 - jackh726:lexical_region_resolve_cleanup, r=compiler-errors
A few cleanups

Each commit is (mostly) self-explanatory. These changes have come as I try to remove `ReEmpty` (#98559).
2022-07-08 08:00:38 +02:00
Michael Goulet 08135254dc Highlight conflicting param-env candidates 2022-07-08 03:51:08 +00:00