Commit Graph

24014 Commits

Author SHA1 Message Date
Maybe Waffle
e496fbec92 Split {Idx, IndexVec, IndexSlice} into their own modules 2023-04-24 13:53:35 +00:00
Matthias Krüger
2ce9b574a4
Rollup merge of #110714 - cjgillot:reveal-consts, r=oli-obk
Normalize types and consts in MIR opts.

Some passes were using a non-RevealAll param_env, which is needlessly restrictive in mir-opts.

As a drive-by, we normalize all constants, since just normalizing their types is not enough.
2023-04-24 07:53:25 +02:00
Matthias Krüger
3ecae2932c
Rollup merge of #110706 - scottmcm:transmute_unchecked, r=oli-obk
Add `intrinsics::transmute_unchecked`

This takes a whole 3 lines in `compiler/` since it lowers to `CastKind::Transmute` in MIR *exactly* the same as the existing `intrinsics::transmute` does, it just doesn't have the fancy checking in `hir_typeck`.

Added to enable experimenting with the request in <https://github.com/rust-lang/rust/pull/106281#issuecomment-1496648190> and because the portable-simd folks might be interested for dependently-sized array-vector conversions.

It also simplifies a couple places in `core`.

See also https://github.com/rust-lang/rust/pull/108442#issuecomment-1474777273, where `CastKind::Transmute` was added having exactly these semantics before the lang meeting (which I wasn't in) independently expressed interest.
2023-04-24 07:53:25 +02:00
Matthias Krüger
8aab707131
Rollup merge of #110566 - compiler-errors:bad-projection-term, r=cjgillot,BoxyUwU
Don't create projection ty for const projection

Fixes #110549
2023-04-24 07:53:24 +02:00
Matthias Krüger
d60c64a0c5
Rollup merge of #110514 - compiler-errors:remove-find_map_relevant_impl, r=b-naber
Remove `find_map_relevant_impl`

Fixes #108895
2023-04-24 07:53:24 +02:00
Matthias Krüger
0f271619e4
Rollup merge of #110255 - clubby789:proc-macro-test-help, r=jackh726
Suggest using integration tests for test crate using own proc-macro

cc #110247
2023-04-24 07:53:23 +02:00
bors
f65615f02d Auto merge of #109590 - Nilstrieb:copy-hir, r=oli-obk
Impl `Copy` for most HIR types

This simplifies the invocation of the `arena_types` macro and probably
makes working with HIR nicer in general.

Based on #109588
2023-04-24 03:10:55 +00:00
bors
8991768e67 Auto merge of #110736 - matthiaskrgr:rollup-gorv8zp, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #110661 (rustdoc: clean up settings.css and settings.js)
 - #110663 (Add note about change in bootstrap defaults)
 - #110664 (stop `x fmt` formatting untracked directories)
 - #110668 (Fix printing native CPU on cross-compiled compiler.)
 - #110689 (Fix grammar in core::hint::unreachable_unchecked() docs)
 - #110700 (Don't infer fn return type to return itself)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-24 00:05:59 +00:00
Michael Goulet
cde5bcafe8 Don't create projection ty for const projection 2023-04-23 18:09:30 +00:00
Matthias Krüger
12858d9a61
Rollup merge of #110700 - compiler-errors:fn-ret-fn, r=oli-obk
Don't infer fn return type to return itself

Fixes #110687
2023-04-23 20:06:33 +02:00
Matthias Krüger
12a539f484
Rollup merge of #110668 - ehuss:fix-native-cpu-list, r=cuviper
Fix printing native CPU on cross-compiled compiler.

If `rustc` is cross-compiled from a different host, then the "native" entry in `rustc --print=target-cpus` would not appear. There is a check in the printing code that will avoid printing the "native" entry if the user has passed `--target`. However, that check was comparing the `--target` value with the `LLVM_TARGET_TRIPLE` which is the triple of the host that `rustc` was built on (the "build" target in Rust lingo), not the target it was being built for (the "host" in Rust lingo). This fixes it to use the target that LLVM was built for (which I'm pretty sure this is the correct function to determine that).

This fixes the cpu listing for aarch64-apple-darwin which is built on CI using the x86_64-apple-darwin host.
2023-04-23 20:06:32 +02:00
bors
7f94b314ce Auto merge of #110281 - ozkanonur:multiarch-compatible-sysroot-finding, r=jackh726
make sysroot finding compatible with multiarch systems

Tested on Debian 11 multiarch, worked just fine.

resolves #109994
2023-04-23 18:03:00 +00:00
Eric Huss
e4e4110dc6 Fix printing native CPU on cross-compiled compiler. 2023-04-23 09:35:56 -07:00
bors
915aa06700 Auto merge of #110705 - saethlin:ignore-locals-cost, r=cjgillot
Remove the size of locals heuristic in MIR inlining

This heuristic doesn't necessarily correlate to complexity of the MIR Body. In particular, a lot of straight-line code in MIR tends to never reuse a local, even though any optimizer would effectively reuse the storage or just put everything in registers. So it doesn't even necessarily make sense that this would be a stack size heuristic.

So... what happens if we just delete the heuristic? The benchmark suite improves significantly. Less heuristics better?

r? `@cjgillot`
2023-04-23 15:41:45 +00:00
bors
3462f79e94 Auto merge of #108118 - oli-obk:lazy_typeck, r=cjgillot
Run various queries from other queries instead of explicitly in phases

These are just legacy leftovers from when rustc didn't have a query system. While there are more cleanups of this sort that can be done here, I want to land them in smaller steps.

This phased order of query invocations was already a lie, as any query that looks at types (e.g. the wf checks run before) can invoke e.g. const eval which invokes borrowck, which invokes typeck, ...
2023-04-23 13:34:31 +00:00
bors
9e540df793 Auto merge of #107404 - cjgillot:const-debuginfo, r=oli-obk
Turn on ConstDebugInfo pass.

Split from https://github.com/rust-lang/rust/pull/103657

Moving those constant into debuginfo allows to shrink the number of locals and the actual size of the MIR body.
2023-04-23 11:26:01 +00:00
Camille GILLOT
4fe51365d7 Use param_env_reveal_all_normalized in MIR opts. 2023-04-23 10:04:41 +00:00
Camille GILLOT
7efcf67a3b Also reveal constants before MIR opts. 2023-04-23 10:04:41 +00:00
bors
f12a7fa00f Auto merge of #110497 - cjgillot:span-ctxt, r=b-naber
Refactor `SyntaxContext::ctxt` logic.

I'm still trying to make a test from the issue.

cc `@deepink-mas` does this solve the issue?

Fixes https://github.com/rust-lang/rust/issues/110230
2023-04-23 09:13:33 +00:00
Scott McMurray
1de2257c3f Add intrinsics::transmute_unchecked
This takes a whole 3 lines in `compiler/` since it lowers to `CastKind::Transmute` in MIR *exactly* the same as the existing `intrinsics::transmute` does, it just doesn't have the fancy checking in `hir_typeck`.

Added to enable experimenting with the request in <https://github.com/rust-lang/rust/pull/106281#issuecomment-1496648190> and because the portable-simd folks might be interested for dependently-sized array-vector conversions.

It also simplifies a couple places in `core`.
2023-04-22 17:22:03 -07:00
Ben Kimock
173845ce0e Remove the size of locals heuristic in MIR inlining 2023-04-22 19:17:11 -04:00
bors
0af46a19b6 Auto merge of #110703 - clubby789:synstructure-remove, r=Nilstrieb
Remove unused `synstructure` dep

`synstructure` is no longer used now that this crate was split out from rustc_macros

`@rustbot` label +C-cleanup
2023-04-22 22:15:53 +00:00
Wesley Wiser
4e8b642646 Turn on ConstDebugInfo pass. 2023-04-22 23:41:48 +02:00
Camille GILLOT
4ad04ad841 Set debug location to debug operand spill. 2023-04-22 23:41:48 +02:00
clubby789
da5d01d53d Remove unused synstructure dep 2023-04-22 22:03:33 +01:00
Nilstrieb
74e31ec64c Also arena-allocate ast::MacroDef to make Item: Copy 2023-04-22 23:00:38 +02:00
Nilstrieb
ed8d67d8ba Impl Copy for almost all HIR types
This simplifies the invocation of the `arena_types` macro and probably
makes working with HIR nicer in general.
2023-04-22 23:00:28 +02:00
bors
b628260df0 Auto merge of #110523 - ecnelises:llvm_isa_fix, r=cuviper
Replace LLVM any_isa with any_cast

Per 585a6eb3eb/llvm/include/llvm/ADT/Any.h (L130) , `any_isa` has been deprecated in LLVM. Use `any_cast` instead to avoid warnings.
2023-04-22 20:03:44 +00:00
Michael Goulet
c8874e2445 Don't infer fn return type to return itself 2023-04-22 19:30:47 +00:00
bors
bb758cfc6d Auto merge of #110674 - compiler-errors:expect-projection-term-eq-succeeds, r=BoxyUwU
Expect that equating a projection term always succeeds in new solver

These should never fail. If they do, we have a problem with the logic that replaces a projection goal's term with an unconstrained infer var. Let's make sure we ICE in that case.
2023-04-22 17:59:16 +00:00
bors
4396ceca05 Auto merge of #109753 - compiler-errors:replenish-region-constraints, r=aliemjay
Clone region var origins instead of taking them in borrowck

Fixes an issue with the new solver where reporting a borrow-checker error ICEs because it calls `InferCtxt::evaluate_obligation`.

This also removes a handful of unnecessary `tcx.infer_ctxt().build()` calls that are only there to mitigate this same exact issue, but with the old solver.

Fixes compiler-errors/next-solver-hir-issues#12.

----

This implements `@aliemjay's` solution where we just don't *take* the region constraints, but clone them. This potentially makes it easier to write a bug about taking region constraints twice or never at all, but again, not many folks are touching this code.
2023-04-22 15:15:51 +00:00
bors
39cf520299 Auto merge of #109507 - Amanieu:panic-oom-payload, r=davidtwco
Report allocation errors as panics

OOM is now reported as a panic but with a custom payload type (`AllocErrorPanicPayload`) which holds the layout that was passed to `handle_alloc_error`.

This should be review one commit at a time:
- The first commit adds `AllocErrorPanicPayload` and changes allocation errors to always be reported as panics.
- The second commit removes `#[alloc_error_handler]` and the `alloc_error_hook` API.

ACP: https://github.com/rust-lang/libs-team/issues/192

Closes #51540
Closes #51245
2023-04-22 12:27:45 +00:00
bors
21fab435da Auto merge of #104844 - cjgillot:mention-eval-place, r=jackh726,RalfJung
Evaluate place expression in `PlaceMention`

https://github.com/rust-lang/rust/pull/102256 introduces a `PlaceMention(place)` MIR statement which keep trace of `let _ = place` statements from surface rust, but without semantics.

This PR proposes to change the behaviour of `let _ =` patterns with respect to the borrow-checker to verify that the bound place is live.

Specifically, consider this code:
```rust
let _ = {
    let a = 5;
    &a
};
```

This passes borrowck without error on stable. Meanwhile, replacing `_` by `_: _` or `_p` errors with "error[E0597]: `a` does not live long enough", [see playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=c448d25a7c205dc95a0967fe96bccce8).

This PR *does not* change how `_` patterns behave with respect to initializedness: it remains ok to bind a moved-from place to `_`.

The relevant test is `tests/ui/borrowck/let_underscore_temporary.rs`. Crater check found no regression.

For consistency, this PR changes miri to evaluate the place found in `PlaceMention`, and report eventual dangling pointers found within it.

r? `@RalfJung`
2023-04-22 09:54:21 +00:00
bors
ccb6290e43 Auto merge of #110567 - JohnBobbo96:monomorphize-dyn-dispatch, r=b-naber
Remove some uses of dynamic dispatch during monomorphization/partitioning.

This removes a few uses of dynamic dispatch and instead uses generics, as well as an enum to allow for other partitioning methods to be added later.
2023-04-22 07:43:43 +00:00
Michael Goulet
6041030c0f Expect that equating a projection term always succeeds in new solver 2023-04-22 06:07:18 +00:00
bors
3128fd8ddf Auto merge of #110666 - JohnTitor:rollup-3pwilte, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #109949 (rustdoc: migrate `document_type_layout` to askama)
 - #110622 (Stable hash tag (discriminant) of `GenericArg`)
 - #110635 (More `IS_ZST` in `library`)
 - #110640 (compiler/rustc_target: Raise m68k-linux-gnu baseline to 68020)
 - #110657 (nit: consistent naming for SimplifyConstCondition)
 - #110659 (rustdoc: clean up JS)
 - #110660 (Print ty placeholders pretty)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-22 05:35:08 +00:00
bors
37b22cf2d5 Auto merge of #110469 - compiler-errors:encode-lt-param-span, r=oli-obk
Encode lifetime param spans too

Fixes #110464
Fixes #110591
2023-04-22 03:28:13 +00:00
Yuki Okushi
16e2096f0f
Rollup merge of #110660 - compiler-errors:placeholders-pretty, r=wesleywiser,BoxyUwU
Print ty placeholders pretty

Makes anon placeholders print like `!0` instead of `Placeholder { ... }`.

```
rustc_trait_selection::solve::compute_well_formed_goal goal=Goal{
    predicate: !0,
    param_env: ParamEnv{
      caller_bounds: [
        Binder(TraitPredicate(<!0 as std::marker::Copy>, polarity: Positive), []),
        Binder(TraitPredicate(<!0 as std::clone::Clone>, polarity: Positive), []),
        Binder(TraitPredicate(<!0 as std::marker::Sized>, polarity: Positive), []),
      ],
      reveal: UserFacing,
      constness: NotConst,
    }
  }
```

cc `@BoxyUwU` who might care about this formatting decision
2023-04-22 10:33:59 +09:00
Yuki Okushi
617ecd2a7a
Rollup merge of #110657 - miguelraz:cleanup-simplifycfg-refactor, r=compiler-errors
nit: consistent naming for SimplifyConstCondition

Fixing a small naming inconsistency that `@JakobDegen` brought up in https://github.com/rust-lang/rust/pull/110477#discussion_r1170783823.

Please signal for rollup.
2023-04-22 10:33:58 +09:00
Yuki Okushi
18c16b506d
Rollup merge of #110640 - glaubitz:m68k-baseline, r=oli-obk
compiler/rustc_target: Raise m68k-linux-gnu baseline to 68020

Atomic operations require 68020 or later on m68k-linux-gnu.
2023-04-22 10:33:58 +09:00
Yuki Okushi
9a798e416c
Rollup merge of #110622 - WaffleLapkin:hashtag#, r=compiler-errors
Stable hash tag (discriminant) of `GenericArg`

This is a continuation of my quest of removing `transmute` if generic args and types (#110496, #110599).

r? `@compiler-errors`
2023-04-22 10:33:57 +09:00
Michael Goulet
1d7a2472bf Print ty placeholders pretty 2023-04-22 01:19:28 +00:00
Michael Goulet
24c2c075cc Encode lifetime param spans too 2023-04-22 01:13:54 +00:00
bors
80a2ec49a4 Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkin
Add offset_of! macro (RFC 3308)

Implements https://github.com/rust-lang/rfcs/pull/3308 (tracking issue #106655) by adding the built in macro `core::mem::offset_of`. Two of the future possibilities are also implemented:

* Nested field accesses (without array indexing)
* DST support (for `Sized` fields)

I wrote this a few months ago, before the RFC merged. Now that it's merged, I decided to rebase and finish it.

cc `@thomcc` (RFC author)
2023-04-22 00:10:44 +00:00
Oli Scherer
334423263a Run check_match and check_liveness when MIR is built instead of having an explicit phase for them 2023-04-21 22:32:38 +00:00
Oli Scherer
5bb58a68de Make check_match and check_liveness take a LocalDefId 2023-04-21 22:27:20 +00:00
Oli Scherer
1ce80e210d Allow LocalDefId as the argument to def_path_str 2023-04-21 22:27:20 +00:00
Oli Scherer
e18d1f8d2e Leave it to the query system to invoke the typeck query instead of invoking it eagerly.
Later queries that are run on all body owners will invoke typeck as they need information from its result to perform their own logic
2023-04-21 22:12:45 +00:00
miguelraz
6f29a3c980 nit: consistent naming for SimplifyConstCondition 2023-04-21 15:45:25 -06:00
Camille GILLOT
2870d269f5 Actually keep PlaceMention if requested. 2023-04-21 21:34:59 +00:00