Commit graph

861 commits

Author SHA1 Message Date
Matthias Krüger 22379779b5
Rollup merge of #105875 - matthiaskrgr:needless_borrowed_reference, r=oli-obk
don't destuct references just to reborrow
2022-12-18 18:57:05 +01:00
Matthias Krüger a108d55ce6 don't restuct references just to reborrow 2022-12-18 17:04:32 +01:00
Matthias Krüger 0aa4cde747 avoid .into() conversion to identical types 2022-12-18 16:20:32 +01:00
Ralf Jung 5a06b1e67c simplify alignment_check_failed a bit 2022-12-15 16:48:30 +00:00
Oli Scherer b05c790fd6 Reuse the ctfe error emitting logic for the future incompat lint 2022-12-15 16:48:24 +00:00
Oli Scherer dec05e9c73 Factor decorate closure out into a method 2022-12-15 16:25:50 +00:00
Oli Scherer d9d92ed7da Move alignment failure error reporting to machine 2022-12-15 16:07:35 +00:00
Oli Scherer d66824dbc4 Make alignment checks a future incompat lint 2022-12-15 16:07:28 +00:00
Oli Scherer ed71e32e14 Always pass alignment and handle checking lazily 2022-12-15 15:51:43 +00:00
Ralf Jung fa83763491 always check alignment during CTFE 2022-12-15 15:36:11 +00:00
Oli Scherer a5cd3bde95 Ensure no one constructs AliasTys themselves 2022-12-14 15:36:39 +00:00
bors 918d0ac38e Auto merge of #104986 - compiler-errors:opaques, r=oli-obk
Combine `ty::Projection` and `ty::Opaque` into `ty::Alias`

Implements https://github.com/rust-lang/types-team/issues/79.

This PR consolidates `ty::Projection` and `ty::Opaque` into a single `ty::Alias`, with an `AliasKind` and `AliasTy` type (renamed from `ty::ProjectionTy`, which is the inner data of `ty::Projection`) defined as so:

```
enum AliasKind {
  Projection,
  Opaque,
}

struct AliasTy<'tcx> {
  def_id: DefId,
  substs: SubstsRef<'tcx>,
}
```

Since we don't have access to `TyCtxt` in type flags computation, and because repeatedly calling `DefKind` on the def-id is expensive, these two types are distinguished with `ty::AliasKind`, conveniently glob-imported into `ty::{Projection, Opaque}`. For example:

```diff
  match ty.kind() {
-   ty::Opaque(..) =>
+   ty::Alias(ty::Opaque, ..) => {}
    _ => {}
  }
```

This PR also consolidates match arms that treated `ty::Opaque` and `ty::Projection` identically.

r? `@ghost`
2022-12-14 01:19:24 +00:00
Matthias Krüger e0e9f3a7b7
Rollup merge of #105659 - JakobDegen:storage-live-borrow, r=davidtwco
Don't require owned data in `MaybeStorageLive`

Small improvement that avoids a clone. I don't expect this to have any noticeable perf effects, but better to have it than not to.

r? ``@tmiasko``
2022-12-13 19:57:12 +01:00
Michael Goulet 96cb18e864 Combine identical alias arms 2022-12-13 17:48:55 +00:00
Michael Goulet 61adaf8187 Combine projection and opaque into alias 2022-12-13 17:48:55 +00:00
Michael Goulet c13bd83528 squash OpaqueTy and ProjectionTy into AliasTy 2022-12-13 17:40:27 +00:00
Michael Goulet 5c6afb850c ProjectionTy.item_def_id -> ProjectionTy.def_id 2022-12-13 17:34:44 +00:00
Michael Goulet 7f3af72606 Use ty::OpaqueTy everywhere 2022-12-13 17:29:26 +00:00
Jakob Degen 3522d48112 Don't require owned data in MaybeStorageLive 2022-12-13 04:22:47 -08:00
Oli Scherer 063b1675b2 Clarify what "this" means 2022-12-13 09:51:03 +00:00
Matthias Krüger 2daa3bcbc2
Rollup merge of #105537 - kadiwa4:remove_some_imports, r=fee1-dead
compiler: remove unnecessary imports and qualified paths

Some of these imports were necessary before Edition 2021, others were already in the prelude.

I hope it's fine that this PR is so spread-out across files :/
2022-12-11 09:51:57 +01:00
KaDiWa 9bc69925cb
compiler: remove unnecessary imports and qualified paths 2022-12-10 18:45:34 +01:00
Jakob Degen 9fb8da8f8f Remove unneeded field from SwitchTargets 2022-12-09 04:53:10 -08:00
bors 14ca83a04b Auto merge of #105486 - matthiaskrgr:rollup-o7c4l1c, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #105216 (Remove unused GUI test)
 - #105245 (attempt to clarify align_to docs)
 - #105387 (Improve Rustdoc scrape-examples UI)
 - #105389 (Enable profiler in dist-powerpc64le-linux)
 - #105427 (Dont silently ignore rustdoc errors)
 - #105442 (rustdoc: clean up docblock table CSS)
 - #105443 (Move some queries and methods)
 - #105455 (use the correct `Reveal` during validation)
 - #105470 (Clippy: backport ICE fix before beta branch)
 - #105474 (lib docs: fix typo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-09 09:19:26 +00:00
Matthias Krüger 04dac4285a
Rollup merge of #105455 - lcnr:correct-reveal-in-validate, r=jackh726
use the correct `Reveal` during validation

supersedes #105454. Deals with https://github.com/rust-lang/rust/issues/105009#issuecomment-1342395333, not closing #105009 as the ICE may leak into beta

The issue was the following:
- we optimize the mir, using `Reveal::All`
- some optimization relies on the hidden type of an opaque type
- we then validate using `Reveal::UserFacing` again which is not able to observe the hidden type

r? `@jackh726`
2022-12-09 07:25:47 +01:00
bors badd6a5a03 Auto merge of #104449 - oli-obk:unhide_unknown_spans, r=estebank,RalfJung
Start emitting labels even if their pointed to file is not available locally

r? `@estebank`

cc `@RalfJung`

fixes #97699
2022-12-09 06:24:28 +00:00
lcnr dd9d05cec4 validate: use the correct reveal during opts 2022-12-08 11:24:25 +01:00
Oli Scherer 99348a5330 Change CTFE backtraces to use note instead of label to preserve their order
labels are reordered within the file in which they are reported, which can mess up the stack trace
2022-12-06 18:59:46 +00:00
Oli Scherer 7782a2b70d Remove now-redundant file/line info from const backtraces 2022-12-06 18:59:46 +00:00
Ralf Jung 9397ea1368 make retagging work even with 'unstable' places 2022-12-06 10:33:34 +01:00
Yuki Okushi fa7d3ec630
Rollup merge of #105289 - Rageking8:fix-dupe-word-typos, r=cjgillot
Fix dupe word typos
2022-12-06 12:48:52 +09:00
Yuki Okushi aa0831092b
Rollup merge of #105207 - RalfJung:interpret-clobber-return, r=oli-obk
interpret: clobber return place when calling function

Makes sure the callee cannot observe the previous contents of the return place, and the caller cannot read any of the old return place contents even if the function unwinds.

I don't think we can test for this though, that would require some strange hand-written MIR.

r? `````@oli-obk`````
2022-12-06 12:48:50 +09:00
Rageking8 58110572fb fix dupe word typos 2022-12-05 16:42:36 +08:00
Ralf Jung 51ac2af99f interpret: clobber return place when calling function 2022-12-03 13:37:13 +01:00
Matthias Krüger 46c50af977
Rollup merge of #105136 - RalfJung:deref-promotion-comment, r=oli-obk
clarify comment on Deref promotion

r? `@oli-obk`
2022-12-02 08:28:10 +01:00
Ralf Jung b7f2b1cd5c clarify comment on Deref promotion 2022-12-01 16:42:33 +01:00
bors 24606deaf4 Auto merge of #104905 - compiler-errors:normalization-changes, r=spastorino
Some initial normalization method changes

1. Rename `AtExt::normalize` to `QueryNormalizeExt::query_normalize` (using the `QueryNormalizer`)
2. Introduce `NormalizeExt::normalize` to replace `partially_normalize_associated_types_in` (using the `AssocTypeNormalizer`)
3. Rename `FnCtxt::normalize_associated_types_in` to `FnCtxt::normalize`
4. Remove some unused other normalization fns in `Inherited` and `FnCtxt`

Also includes one drive-by where we're no longer creating a `FnCtxt` inside of `check_fn`, but passing it in. This means we don't need such weird `FnCtxt` construction logic.

Stacked on top of #104835 for convenience.

r? types
2022-11-30 11:13:09 +00:00
Michael Goulet 1e236acd05 Make ObligationCtxt::normalize take cause by borrow 2022-11-28 17:35:40 +00:00
Matthias Krüger 3aace9a641
Rollup merge of #104982 - RalfJung:norun, r=oli-obk
interpret: get rid of run() function

Miri needs its own loop anyway, so there's not much of a point in trying to share this code.
2022-11-28 17:25:49 +01:00
Matthias Krüger 86304f5149
Rollup merge of #104976 - WaffleLapkin:move_comments, r=cjgillot
Prefer doc comments over `//`-comments in compiler

Doc comments are generally nicer: they show up in the documentation, they are shown in IDEs when you hover other mentions of items, etc. Thus it makes sense to use them instead of `//`-comments.
2022-11-27 22:14:08 +01:00
Matthias Krüger 6e6c42c61c
Rollup merge of #104931 - Swatinem:async-pretty, r=eholk
Pretty-print generators with their `generator_kind`

After removing `GenFuture`, I special-cased async generators to pretty-print as `impl Future<Output = X>` mainly to avoid too much diagnostics changes originally.

This now reverses that change so that async fn/blocks are pretty-printed as `[$async-type@$source-position]` in various diagnostics, and updates the tests that this touches.
2022-11-27 16:03:08 +01:00
Ralf Jung 60d5d65a4d interpret: get rid of run() function 2022-11-27 15:20:26 +01:00
Maybe Waffle 1d42936b18 Prefer doc comments over //-comments in compiler 2022-11-27 11:19:04 +00:00
bors df04d28163 Auto merge of #103917 - oli-obk:layout_math, r=RalfJung,lcnr
Various cleanups around scalar layout restrictions

Pulled out of https://github.com/rust-lang/rust/pull/103724
2022-11-27 10:35:00 +00:00
Arpad Borsos c96d888bdf
Pretty-print generators with their generator_kind
After removing `GenFuture`, I special-cased async generators to pretty-print as `impl Future<Output = X>` mainly to avoid too much diagnostics changes originally.

This now reverses that change so that async fn/blocks are pretty-printed as `[$movability `async` $something@$source-position]` in various diagnostics, and updates the tests that this touches.
2022-11-26 20:42:50 +01:00
bors aff003becd Auto merge of #99798 - JulianKnodt:ac1, r=BoxyUwU
Add `ConstKind::Expr`

Starting to implement `ty::ConstKind::Abstract`, most of the match cases are stubbed out, some I was unsure what to add, others I didn't want to add until a more complete implementation was ready.

r? `@lcnr`
2022-11-25 22:56:59 +00:00
Boxy 430f7d16e6 add FIXME's 2022-11-25 09:28:44 +00:00
kadmin f9750c1554 Add empty ConstKind::Abstract
Initial pass at expr/abstract const/s

Address comments

Switch to using a list instead of &[ty::Const], rm `AbstractConst`

Remove try_unify_abstract_consts

Update comments

Add edits

Recurse more

More edits

Prevent equating associated consts

Move failing test to ui

Changes this test from incremental to ui, and mark it as failing and a known bug.
Does not cause the compiler to ICE, so should be ok.
2022-11-25 09:28:43 +00:00
Oli Scherer 2e79f5f9f8 Move a comment to the right place 2022-11-25 08:11:53 +00:00
Oli Scherer 9909cb902f Make the ICEs in the mir typechecker have more spans helpful 2022-11-25 08:01:12 +00:00