Commit Graph

24142 Commits

Author SHA1 Message Date
Maybe Waffle
7d23b52376 const-ify some {IndexVec, IndexSlice} methods 2023-04-24 13:53:37 +00:00
Maybe Waffle
99ebfe2f15 move index code around 2023-04-24 13:53:37 +00:00
Maybe Waffle
e496fbec92 Split {Idx, IndexVec, IndexSlice} into their own modules 2023-04-24 13:53:35 +00:00
bors
b72460fe46 Auto merge of #110672 - Ezrashaw:allow-array-simd-in-inline-asm, r=workingjubilee
allow array-style simd in inline asm

Required for [MCP#621](https://github.com/rust-lang/compiler-team/issues/621) to be implemented.

r? `@workingjubilee`
2023-04-24 13:51:04 +00:00
Tim Neumann
047ed32148 [LLVM17] Adapt to ExplicitEmulatedTLS removal. 2023-04-24 08:45:15 +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
Scott McMurray
31531ce939 Add size asserts for MIR SourceScopeData & VarDebugInfo
There's vectors of both of these in `mir::Body`, so might as well track them.
2023-04-23 21:23:54 -07: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
Ben Kimock
1f67ba61a9 Rewrite MemDecoder around pointers not a slice 2023-04-23 17:25:11 -04: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
Camille GILLOT
15e5072147 Do not bother optimizing impossible functions. 2023-04-23 16:35:49 +00: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
Ezra Shaw
d31e8a499b
allow array-style simd in inline asm 2023-04-23 19:28:50 +12: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
Camille GILLOT
dd78b997b5 Reduce rightward drift. 2023-04-22 12:30:37 +00:00
Camille GILLOT
dd452ae70e Simplify logic. 2023-04-22 12:30:36 +00:00
Camille GILLOT
629cdb42d3 Move eval_discriminant. 2023-04-22 12:30:36 +00:00
Camille GILLOT
0e68cbd45d Remove useless special case. 2023-04-22 12:30:36 +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
klensy
3338ee3ca7 drop unused deps, gate libc under unix for one crate 2023-04-22 15:22:21 +03: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
Camille GILLOT
ddfa2463e2 Evaluate place expression in PlaceMention. 2023-04-21 21:34:59 +00:00
Bryan Garza
55e5a1d206 Create "AppendConstMessage" enum
This patch creates an enum to replace a nested `Option`.
2023-04-21 14:07:41 -07:00
Obei Sideg
06ff310cf9 Migrate rustc_hir_analysis to session diagnostic
Part 4: Finishing `check/mod.rs` file
2023-04-21 23:50:03 +03:00
bors
fec9adcdbc Auto merge of #110648 - Dylan-DPC:rollup-em3ovcq, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #110333 (rustc_metadata: Split `children` into multiple tables)
 - #110501 (rustdoc: fix ICE from rustc_resolve and librustdoc parse divergence)
 - #110608 (Specialize some `io::Read` and `io::Write` methods for `VecDeque<u8>` and `&[u8]`)
 - #110632 (Panic instead of truncating if the incremental on-disk cache is too big)
 - #110633 (More `mem::take` in `library`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-21 19:43:11 +00:00
bors
fa4cc63a6b Auto merge of #110107 - cjgillot:const-prop-lint-junk, r=oli-obk
Ensure mir_drops_elaborated_and_const_checked when requiring codegen.

mir_drops_elaborated_and_const_checked may emit errors while codegen has started, and the compiler would exit leaving object code files around.

Found by `@cuviper` in https://github.com/rust-lang/rust/issues/109731
2023-04-21 17:28:37 +00:00
Camille GILLOT
ed7e50e08b Ensure mir_drops_elaborated_and_const_checked when requiring codegen. 2023-04-21 16:14:43 +00:00
Bryan Garza
d0d40d2a40 Break up long function in trait selection error reporting
- Move blocks of code into their own functions
- Replace a few function argument types with their type aliases
2023-04-21 09:04:02 -07:00
Kyle Matsuda
5a69b5d0f9 Changes from review 2023-04-21 09:57:37 -06:00
bors
4a03f14b09 Auto merge of #110569 - saethlin:mir-pass-cooperation, r=cjgillot
Deduplicate unreachable blocks, for real this time

In https://github.com/rust-lang/rust/pull/106428 (in particular 41eda69516) we noticed that inlining `unreachable_unchecked` can produce duplicate unreachable blocks. So we improved two MIR optimizations: `SimplifyCfg` was given a simplify to deduplicate unreachable blocks, then `InstCombine` was given a combiner to deduplicate switch targets that point at the same block. The problem is that change doesn't actually work.

Our current pass order is
```
SimplifyCfg (does nothing relevant to this situation)
Inline (produces multiple unreachable blocks)
InstCombine (doesn't do anything here, oops)
SimplifyCfg (produces the duplicate SwitchTargets that InstCombine is looking for)
```

So in here, I have factored out the specific function from `InstCombine` and placed it inside the simplify that produces the case it is looking for. This should ensure that it runs in the scenario it was designed for.

Fixes https://github.com/rust-lang/rust/issues/110551
r? `@cjgillot`
2023-04-21 15:08:02 +00:00
Dylan DPC
1d1453a2f6
Rollup merge of #110632 - saethlin:panic-if-dep-graph-too-big, r=lcnr
Panic instead of truncating if the incremental on-disk cache is too big

It seems _unlikely_ that anyone would hit this truncation, but if this `as` does actually truncate, that seems incredibly bad.
2023-04-21 20:35:29 +05:30
Dylan DPC
fbc905e16a
Rollup merge of #110501 - notriddle:notriddle/ice-110495, r=petrochenkov
rustdoc: fix ICE from rustc_resolve and librustdoc parse divergence

Fixes #110495
2023-04-21 20:35:28 +05:30
Dylan DPC
ff4a5fbbe5
Rollup merge of #110333 - petrochenkov:notagain, r=compiler-errors
rustc_metadata: Split `children` into multiple tables

instead of merging everything into a single bag.

If it's acceptable from performance point of view, then it's more clear to keep this stuff organized more in accordance with its use.
2023-04-21 20:35:27 +05:30
bors
409661936f Auto merge of #110542 - petrochenkov:qcstore4, r=cjgillot
resolve: Remove `module_children_untracked`

One of the expensive spans in `ModChild` was removed in https://github.com/rust-lang/rust/pull/109772, so let's try again.
2023-04-21 12:57:31 +00:00
Vadim Petrochenkov
cbc6ccb191 rustc_metadata: Split children into multiple tables
instead of merging everything into a single bag.

If it's acceptable from performance point of view, then it's more clear to keep this stuff organized more in accordance with its use.
2023-04-21 14:38:59 +03:00
John Paul Adrian Glaubitz
b0692a626b compiler/rustc_target: Raise m68k-linux-gnu baseline to 68020
Atomic operations require 68020 or later on m68k-linux-gnu.
2023-04-21 13:27:13 +02:00
bors
1151ea6006 Auto merge of #109002 - michaelvanstraten:master, r=petrochenkov
Added byte position range for `proc_macro::Span`

Currently, the [`Debug`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#impl-Debug-for-Span) implementation for [`proc_macro::Span`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#) calls the debug function implemented in the trait implementation of `server::Span` for the type `Rustc` in the `rustc-expand` crate.

The current implementation, of the referenced function, looks something like this:
```rust
fn debug(&mut self, span: Self::Span) -> String {
    if self.ecx.ecfg.span_debug {
        format!("{:?}", span)
    } else {
        format!("{:?} bytes({}..{})", span.ctxt(), span.lo().0, span.hi().0)
    }
}
```

It returns the byte position of the [`Span`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#) as an interpolated string.

Because this is currently the only way to get a spans position in the file, I might lead someone, who is interested in this information, to parsing this interpolated string back into a range of bytes, which I think is a very non-rusty way.

The proposed `position()`, method implemented in this PR, gives the ability to directly get this info.
It returns a [`std::ops::Range`](https://doc.rust-lang.org/std/ops/struct.Range.html#) wrapping the lowest and highest byte of the [`Span`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#).

I put it behind the `proc_macro_span` feature flag because many of the other functions that have a similar footprint also are annotated with it, I don't actually know if this is right.

It would be great if somebody could take a look at this, thank you very much in advanced.
2023-04-21 10:47:27 +00:00
DrMeepster
3206960ec6 minor tweaks 2023-04-21 02:14:04 -07:00
DrMeepster
2bcb018253 fmt 2023-04-21 02:14:03 -07:00
DrMeepster
631ea7cc15 use P<[Ident]> instead of Vec<Ident> 2023-04-21 02:14:03 -07:00
DrMeepster
b92c2f792c fix incorrect param env in dead code lint 2023-04-21 02:14:03 -07:00
DrMeepster
b95852b93c test improvements 2023-04-21 02:14:03 -07:00
DrMeepster
61f23e0003 intern offsetof fields 2023-04-21 02:14:03 -07:00
DrMeepster
511e457c4b offset_of 2023-04-21 02:14:02 -07:00
bors
1f5768bc67 Auto merge of #96840 - cjgillot:query-feed, r=oli-obk
Allow to feed a value in another query's cache and remove `WithOptConstParam`

I used it to remove `WithOptConstParam` queries, as an example.

The idea is that a query (here `typeck(function)`) can write into another query's cache (here `type_of(anon const)`). The dependency node for `type_of` would depend on all the current dependencies of `typeck`.

There is still an issue with cycles: if `type_of(anon const)` is accessed before `typeck(function)`, we will still have the usual cycle.  The way around this issue is to `ensure` that `typeck(function)` is called before accessing `type_of(anon const)`.

When replayed, we may the following cases:
- `typeck` is green, in that case `type_of` is green too, and all is right;
- `type_of` is green, `typeck` may still be marked as red (it depends on strictly more things than `type_of`) -> we verify that the saved value and the re-computed value of `type_of` have the same hash;
- `type_of` is red, then `typeck` is red -> it's the caller responsibility to ensure `typeck` is recomputed *before* `type_of`.

As `anon consts` have their own `DefPathData`, it's not possible to have the def-id of the anon-const point to something outside the original function, but the general case may have to be resolved before using this device more broadly.

There is an open question about loading from the on-disk cache.  If `typeck` is loaded from the on-disk cache, the side-effect does not happen. The regular `type_of` implementation can go and fetch the correct value from the decoded `typeck` results, and the dep-graph will check that the hashes match, but I'm not sure we want to rely on this behaviour.

I specifically allowed to feed the value to `type_of` from inside a call to `type_of`.  In that case, the dep-graph will check that the fingerprints of both values match.

This implementation is still very sensitive to cycles, and requires that we call `typeck(function)` before `typeck(anon const)`.  The reason is that `typeck(anon const)` calls `type_of(anon const)`, which calls `typeck(function)`, which feeds `type_of(anon const)`, and needs to build the MIR so needs `typeck(anon const)`.  The latter call would not cycle, since `type_of(anon const)` has been set, but I'd rather not remove the cycle check.
2023-04-21 08:04:58 +00:00
Matthias Krüger
77de5f0754
Rollup merge of #110618 - compiler-errors:eval-ctxt-tainted, r=BoxyUwU
Track if EvalCtxt has been tainted, make sure it can't be used to make query responses after

Just some additional protection against missing probes or strange candidate assembly behavior in the new solver.

For background, we don't ever want to call `evaluate_added_goals_and_make_canonical_response` if a previous call to `try_evaluate_added_goals` has bailed with `NoSolution`, since our nested goals are left in an undefined state at that point. This most commonly suggests a missing `EvalCtxt::probe`, but could also signify some other shenanigans like dropping a `QueryResult` on the floor without properly `?`'ing it.

r? `@lcnr`
2023-04-21 06:44:31 +02:00
Matthias Krüger
a8e239468b
Rollup merge of #110597 - lcnr:not-pin-via-negative-bound, r=compiler-errors
remove unused ftl messages

r? `@davidtwco`

does it make sense to check via tidy that there exist no ftl message names which are never mentioned in `compiler/**.rs`
2023-04-21 06:44:30 +02:00
Matthias Krüger
637d9ddc35
Rollup merge of #110578 - bvanjoi:fix-issue-110547, r=jackh726
fix(error): normalize whitespace during msg_to_buffer

close https://github.com/rust-lang/rust/issues/110547
2023-04-21 06:44:30 +02:00
Matthias Krüger
7d046551a7
Rollup merge of #110555 - compiler-errors:subst-missing-trait-items, r=cjgillot
Substitute missing trait items suggestion correctly

Properly substitute missing item suggestions, so that when they reference generics from their parent trait they actually have the right time for the impl.

Also, some other minor tweaks like using `/* Type */` to signify a GAT's type is actually missing, and fixing generic arg suggestions for GATs in general.
2023-04-21 06:44:29 +02:00
Ben Kimock
010deb5ba3 Panic instead of truncating if the dep graph is too big 2023-04-20 21:12:39 -04:00
Ben Kimock
8ec49ad19a Run combine_duplicate_switch_targets after the simplification that produces them 2023-04-20 20:40:01 -04:00
bohan
a2f275da51 fix(error): normalize whitespace during msg_to_buffer 2023-04-21 08:40:00 +08:00
Michael Goulet
964600b38e Clone region var origins instead of taking in borrowck 2023-04-21 00:31:43 +00:00
bors
d19b64fb54 Auto merge of #109999 - m-ou-se:flatten-format-args, r=oli-obk
Enable flatten-format-args by default.

Part of https://github.com/rust-lang/rust/issues/99012.

This enables the `flatten-format-args` feature that was added by https://github.com/rust-lang/rust/pull/106824:

> This change inlines string literals, integer literals and nested format_args!() into format_args!() during ast lowering, making all of the following pairs result in equivalent hir:
>
> ```rust
> println!("Hello, {}!", "World");
> println!("Hello, World!");
> ```
>
> ```rust
> println!("[info] {}", format_args!("error"));
> println!("[info] error");
> ```
>
> ```rust
> println!("[{}] {}", status, format_args!("error: {}", msg));
> println!("[{}] error: {}", status, msg);
> ```
>
> ```rust
> println!("{} + {} = {}", 1, 2, 1 + 2);
> println!("1 + 2 = {}", 1 + 2);
> ```
>
> And so on.
>
> This is useful for macros. E.g. a `log::info!()` macro could just pass the tokens from the user directly into a `format_args!()` that gets efficiently flattened/inlined into a `format_args!("info: {}")`.
>
> It also means that `dbg!(x)` will have its file, line, and expression name inlined:
>
> ```rust
> eprintln!("[{}:{}] {} = {:#?}", file!(), line!(), stringify!(x), x); // before
> eprintln!("[example.rs:1] x = {:#?}", x); // after
> ```
>
> Which can be nice in some cases, but also means a lot more unique static strings than before if dbg!() is used a lot.

This is mostly an optimization, except that it will be visible through [`fmt::Arguments::as_str()`](https://doc.rust-lang.org/nightly/std/fmt/struct.Arguments.html#method.as_str).

In https://github.com/rust-lang/rust/pull/106823, there was already a libs-api FCP about the documentation of `fmt::Arguments::as_str()` to allow it to give `Some` rather than `None` depending on optimizations like this. That was just a documentation update though. This PR is the one that actually makes the user visible change:

```rust
assert_eq!(format_args!("abc").as_str(), Some("abc")); // Unchanged.
assert_eq!(format_args!("ab{}", "c").as_str(), Some("abc")); // Was `None` before!
```
2023-04-20 23:19:19 +00:00
bors
8bdcc62cb0 Auto merge of #110616 - m-ou-se:fmt-lang-items, r=jyn514
Remove public doc(hidden) core::fmt::rt::v1

All the types used by format_arg!() are now lang items, so they are no longer required as publicly exported items.

Part of #99012

After this change, the `rt` module is private, and contains only three lang items used by format_args (`Placeholder`, `Alignment`, and `Count`): 441682cca9/library/core/src/fmt/rt.rs
2023-04-20 21:11:54 +00:00
Maybe Waffle
ad8c7b6705 Simplify bits_for_tags impl 2023-04-20 19:54:10 +00:00
Maybe Waffle
4375af53af Derive HashStable on GenericArgKind instead of implementing it by hand 2023-04-20 19:52:37 +00:00
Maybe Waffle
7cfecf26f7 Remove confusing comment 2023-04-20 19:07:57 +00:00
Camille GILLOT
76d573b656 Add info for no_hash panic. 2023-04-20 18:56:12 +00:00
Maybe Waffle
96905d568a Use impl Tag for $T syntax for impl_tag! 2023-04-20 18:49:40 +00:00
Michael Goulet
3206100ed9 Result is just bool but special 2023-04-20 18:40:34 +00:00
Kyle Matsuda
e54854f6a9 add subst_identity_iter and subst_identity_iter_copied methods on EarlyBinder; use this to simplify some EarlyBinder noise around explicit_item_bounds calls 2023-04-20 12:36:50 -06:00
Kyle Matsuda
f3b279fcc5 add EarlyBinder to output of explicit_item_bounds; replace bound_explicit_item_bounds usages; remove bound_explicit_item_bounds query 2023-04-20 12:36:50 -06:00
Kyle Matsuda
0892a7380b change usages of explicit_item_bounds to bound_explicit_item_bounds 2023-04-20 12:36:50 -06:00
Camille GILLOT
a395d2a5de Give more descriptive names to queries. 2023-04-20 18:01:07 +00:00
Camille GILLOT
f65f506d60 Remove opt_const_param_of. 2023-04-20 17:48:52 +00:00
Camille GILLOT
b275d2c30b Remove WithOptconstParam. 2023-04-20 17:48:32 +00:00
Maybe Waffle
77c83c0965 Add impl_tag! macro to implement Tag for tagged pointer easily 2023-04-20 17:14:32 +00:00
Camille GILLOT
0e017fc94a Feed type_of query instead of using WithOptconstParam. 2023-04-20 17:13:39 +00:00
Camille GILLOT
4224b4b1f5 Re-allow computing fed queries. 2023-04-20 17:09:26 +00:00
Michael Goulet
4fd7739aac Track if EvalCtxt has been tainted, make sure it can't be used to make query responses after 2023-04-20 16:54:39 +00:00
Mara Bos
441682cca9 Update comments in format args lowering.
These lang items have been moved/renamed.
2023-04-20 18:09:32 +02:00
Matthias Krüger
c430d6111a
Rollup merge of #110599 - WaffleLapkin:bonk_tygenericarg_transmutes, r=compiler-errors
Remove an unused `&[Ty]` <-> `&[GenericArg]`

Missed this one in #110496, oops.

r? `@compiler-errors`
2023-04-20 17:59:55 +02:00
Matthias Krüger
462461699a
Rollup merge of #110558 - spastorino:smir-call-terminator, r=oli-obk
Add Call terminator to SMIR

This adds internal MIR `TerminatorKind::Call` to SMIR `Terminator::Call` conversion.

r? `@oli-obk`
2023-04-20 17:59:54 +02:00
Matthias Krüger
7dc211f5ce
Rollup merge of #108795 - thomcc:x86_64h-target, r=wesleywiser
Add support for the x86_64h-apple-darwin target

See https://github.com/rust-lang/compiler-team/issues/599 for MCP.

r? compiler-team

CC `@BlackHoleFox` who recently overhauled the apple target code in `rustc-target`.

## Target Support Checklist

> - A tier 3 target must have a designated developer or developers (the "target
>   maintainers") on record to be CCed when issues arise regarding the target.
>   (The mechanism to track and CC such developers may evolve over time.)

I'm the designated developer.

> - Targets must use naming consistent with any existing targets; for instance, a
>   target for the same CPU or OS as an existing Rust target should use the same
>   name for that CPU or OS. Targets should normally use the same names and
>   naming conventions as used elsewhere in the broader ecosystem beyond Rust
>   (such as in other toolchains), unless they have a very good reason to
>   diverge. Changing the name of a target can be highly disruptive, especially
>   once the target reaches a higher tier, so getting the name right is important
>   even for a tier 3 target.

This uses the same naming conventions used for the other macOS targets (`-apple-darwin`), combined with the convention used by LLVM for the `x86_64h` targets. LLVM's convention matches the architecture name used when invoking various tools such as `lipo`, `arch`, and (IMO) there's not really a compelling reason to depart from it.

> - Target names should not introduce undue confusion or ambiguity unless
>   absolutely necessary to maintain ecosystem compatibility. For example, if
>   the name of the target makes people extremely likely to form incorrect
>   beliefs about what it targets, the name should be changed or augmented to
>   disambiguate it.

I don't think this is especially likely, although I suppose someone could mistake it for `x86_64-apple-darwin`.

> - If possible, use only letters, numbers, dashes and underscores for the name.
>   Periods (`.`) are known to cause issues in Cargo.

👍

> - Tier 3 targets may have unusual requirements to build or use, but must not
>   create legal issues or impose onerous legal terms for the Rust project or for
>   Rust developers or users.
>   - The target must not introduce license incompatibilities.

It does not.

> - Anything added to the Rust repository must be under the standard Rust
>   license (`MIT OR Apache-2.0`).

It is.

> - The target must not cause the Rust tools or libraries built for any other
>   host (even when supporting cross-compilation to the target) to depend
>   on any new dependency less permissive than the Rust licensing policy. This
>   applies whether the dependency is a Rust crate that would require adding
>   new license exceptions (as specified by the `tidy` tool in the
>   rust-lang/rust repository), or whether the dependency is a native library
>   or binary. In other words, the introduction of the target must not cause a
>   user installing or running a version of Rust or the Rust tools to be
>   subject to any new license requirements.

There are no new dependencies that don't also apply to `x86_64-apple-darwin`.

> - Compiling, linking, and emitting functional binaries, libraries, or other
>   code for the target (whether hosted on the target itself or cross-compiling
>   from another target) must not depend on proprietary (non-FOSS) libraries.
>   Host tools built for the target itself may depend on the ordinary runtime
>   libraries supplied by the platform and commonly used by other applications
>   built for the target, but those libraries must not be required for code
>   generation for the target; cross-compilation to the target must not require
>   such libraries at all. For instance, `rustc` built for the target may
>   depend on a common proprietary C runtime library or console output library,
>   but must not depend on a proprietary code generation library or code
>   optimization library. Rust's license permits such combinations, but the
>   Rust project has no interest in maintaining such combinations within the
>   scope of Rust itself, even at tier 3.

This has the same requirements as the other macOS targets (e.g. `x86_64-apple-darwin` and similar).

> - "onerous" here is an intentionally subjective term. At a minimum, "onerous"
>   legal/licensing terms include but are *not* limited to: non-disclosure
>   requirements, non-compete requirements, contributor license agreements
>   (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms,
>   requirements conditional on the employer or employment of any particular
>   Rust developers, revocable terms, any requirements that create liability
>   for the Rust project or its developers or users, or any requirements that
>   adversely affect the livelihood or prospects of the Rust project or its
>   developers or users.

No change here.

> - Neither this policy nor any decisions made regarding targets shall create any
>   binding agreement or estoppel by any party. If any member of an approving
>   Rust team serves as one of the maintainers of a target, or has any legal or
>   employment requirement (explicit or implicit) that might affect their
>   decisions regarding a target, they must recuse themselves from any approval
>   decisions regarding the target's tier status, though they may otherwise
>   participate in discussions.

👍

> - This requirement does not prevent part or all of this policy from being
>   cited in an explicit contract or work agreement (e.g. to implement or
>   maintain support for a target). This requirement exists to ensure that a
>   developer or team responsible for reviewing and approving a target does not
>   face any legal threats or obligations that would prevent them from freely
>   exercising their judgment in such approval, even if such judgment involves
>   subjective matters or goes beyond the letter of these requirements.

👍

> - Tier 3 targets should attempt to implement as much of the standard libraries
>   as possible and appropriate (`core` for most targets, `alloc` for targets
>   that can support dynamic memory allocation, `std` for targets with an
>   operating system or equivalent layer of system-provided functionality), but
>   may leave some code unimplemented (either unavailable or stubbed out as
>   appropriate), whether because the target makes it impossible to implement or
>   challenging to implement. The authors of pull requests are not obligated to
>   avoid calling any portions of the standard library on the basis of a tier 3
>   target not implementing those portions.

The standard library tests seem to pass.

> - The target must provide documentation for the Rust community explaining how
>   to build for the target, using cross-compilation if possible. If the target
>   supports running binaries, or running tests (even if they do not pass), the
>   documentation must explain how to run such binaries or tests for the target,
>   using emulation if possible or dedicated hardware if necessary.

Documentation is provided.

> - Tier 3 targets must not impose burden on the authors of pull requests, or
>   other developers in the community, to maintain the target. In particular,
>   do not post comments (automated or manual) on a PR that derail or suggest a
>   block on the PR based on a tier 3 target. Do not send automated messages or
>   notifications (via any medium, including via ``@`)` to a PR author or others
>   involved with a PR regarding a tier 3 target, unless they have opted into
>   such messages.

Noted. This target is nearly identical to `x86_64-apple-darwin`, so this is
unlikely to cause issues anyway.

> - Backlinks such as those generated by the issue/PR tracker when linking to
>   an issue or PR are not considered a violation of this policy, within
>   reason. However, such messages (even on a separate repository) must not
>   generate notifications to anyone involved with a PR who has not requested
>   such notifications.

👍

> - Patches adding or updating tier 3 targets must not break any existing tier 2
>   or tier 1 target, and must not knowingly break another tier 3 target without
>   approval of either the compiler team or the maintainers of the other tier 3
>   target.
>   - In particular, this may come up when working on closely related targets,
>     such as variations of the same architecture with different features. Avoid
>     introducing unconditional uses of features that another variation of the
>     target may not have; use conditional compilation or runtime detection, as
>     appropriate, to let each target run code supported by that target.

👍
2023-04-20 17:59:53 +02:00
Santiago Pastorino
2f503345b4
Add Call terminator to SMIR 2023-04-20 12:00:41 -03:00
bors
791a7f22e3 Auto merge of #110598 - matthiaskrgr:rollup-0ybd9i3, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #110240 (Add `indent_style = tab` for `Makefile`s to `.editorconfig`)
 - #110545 (Add `GenericArgKind::as_{type,const,region}`)
 - #110574 ( fix out-of-date comment about rpath in bootstrap)
 - #110581 (Style fix for loongarch-linux.md)
 - #110584 (Allow overwriting the sysroot compile flag in compile tests)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-20 13:03:31 +00:00
Maybe Waffle
6d4b7fe9ed Remove an unused &[Ty] <-> &[GenericArg] 2023-04-20 12:41:46 +00:00
Matthias Krüger
17f6763a14
Rollup merge of #110545 - WaffleLapkin:generic_arg_as_x, r=cjgillot
Add `GenericArgKind::as_{type,const,region}`

This allows to make code nicer in some cases
2023-04-20 14:36:54 +02:00
lcnr
82cb8a2933 more msg removal 2023-04-20 14:17:52 +02:00
lcnr
4f757af176 remove unused message 2023-04-20 14:09:41 +02:00
bors
7e23d180c1 Auto merge of #109993 - scottmcm:transmute-niches, r=oli-obk
`assume` value ranges in `transmute`

Fixes #109958
2023-04-20 10:46:13 +00:00
bors
13fc33e3f2 Auto merge of #110585 - JohnTitor:rollup-gfffoiv, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #102341 (Implement `Neg` for signed non-zero integers.)
 - #110424 (Spelling misc)
 - #110448 (cmp doc examples improvements)
 - #110516 (bootstrap: Update linux-raw-sys to 0.3.2)
 - #110548 (Make `impl Debug for Span` not panic on not having session globals.)
 - #110554 (`deny(unsafe_op_in_unsafe_fn)` in `rustc_data_structures`)
 - #110575 (fix lint regression in `non_upper_case_globals`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-20 08:33:33 +00:00
Yuki Okushi
a2826dc4d4
Rollup merge of #110575 - Ezrashaw:fix-regression-110573, r=compiler-errors
fix lint regression in `non_upper_case_globals`

Fixes #110573

The issue also exists for inherent associated types (where I copied my impl from). `EarlyContext` is more involved to fix in this way, so I'll leave it be for now (note it's unstable so that's not urgent).

r? `@compiler-errors`
2023-04-20 17:03:26 +09:00
Yuki Okushi
a496ae6ac3
Rollup merge of #110554 - WaffleLapkin:rustc_data_structures_unsafe_op_in_unsafe_fn, r=Nilstrieb
`deny(unsafe_op_in_unsafe_fn)` in `rustc_data_structures`

r? `@Nilstrieb`

I couldn't bring myself to document the safety in big `unsafe` functions but ehh
2023-04-20 17:03:26 +09:00
Yuki Okushi
615669dbb2
Rollup merge of #110548 - kpreid:span, r=WaffleLapkin
Make `impl Debug for Span` not panic on not having session globals.

I hit the panic that this patch avoids while messing with the early lints in `rustc_session::config::build_session_options()`. The rest of that project is not finished, but this seemed like a self-contained improvement.

(Should changes like this add tests? I don't see similar unit tests.)
2023-04-20 17:03:25 +09:00
Scott McMurray
baf98e7515 Add transmute optimization tests and some extra comments 2023-04-19 23:17:35 -07:00
bors
23a76a8ab5 Auto merge of #110527 - nnethercote:lazy-graph, r=lqd
In `LexicalResolver`, don't construct graph unless necessary.

A small but easy perf win.

r? `@jackh726`
2023-04-20 06:14:55 +00:00
Ezra Shaw
8cad917e68
reimpl make non_upper_case_globals lint not report trait impls 2023-04-20 16:28:49 +12:00
bors
7fde08365c Auto merge of #110399 - cjgillot:infer-variance, r=aliemjay
Account for opaque variance in outlives

Fixes https://github.com/rust-lang/rust/issues/108591
Fixes https://github.com/rust-lang/rust/issues/108592
cc `@aliemjay`
2023-04-20 04:08:03 +00:00
Qiu Chaofan
1a44694713 Remove deprecated LLVM any_isa 2023-04-20 10:44:41 +08:00
John Bobbo
8a7a020a2a
Remove a few uses of dynamic dispatch during
monomorphization/partitioning with the use of
an enum.
2023-04-19 18:21:40 -07:00
bors
b9fd498fa7 Auto merge of #110061 - WaffleLapkin:duality_of_myself_and_this, r=cjgillot
Add suggestion to use closure argument instead of a capture on borrowck error

Fixes #109271
r? `@compiler-errors`

This should probably be refined a bit, but opening a PR so that I don't forget anything.
2023-04-19 23:39:03 +00:00
Michael Goulet
f362f6e9e6 Format missing GATs correctly 2023-04-19 23:37:41 +00:00
bors
39c6804b92 Auto merge of #106704 - ecnelises:big_archive, r=bjorn3
Support AIX-style archive type

Reading facility of AIX big archive has been supported by `object` since 0.30.0.

Writing facility of AIX big archive has already been supported by `ar_archive_writer`, but we need to bump the version to support the new archive type enum.
2023-04-19 21:21:17 +00:00
Maybe Waffle
cac143f0e3 Extend and use hir::Node::body_id 2023-04-19 19:13:45 +00:00
Maybe Waffle
102c0af5a7 Add suggestion to use a closure arg instead of a capture on bck error 2023-04-19 19:13:35 +00:00
bors
9c51cf7e7f Auto merge of #110546 - matthiaskrgr:rollup-346kik6, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #110123 ('./configure' now checks if 'config.toml' exists before writing to that destination)
 - #110429 (Spelling src bootstrap)
 - #110430 (Spelling src ci)
 - #110515 (Don't special-case download-rustc in `maybe_install_llvm`)
 - #110521 (Fix `x test lint-docs linkchecker` when download-rustc is enabled)
 - #110525 (Fix `tests/run-make-translation` when download-rustc is enabled)
 - #110531 (small type system cleanup)
 - #110533 (Missing blanket impl trait not public)
 - #110540 (Fix wrong comment in rustc_hir/src/hir.rs)
 - #110541 (Fix various configure bugs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-19 19:11:05 +00:00
Maybe Waffle
cfe5c3ca6c Add #[track_caller] to struct_span_err_with_code (drive-by cleanup)
We use caller information to track where a diagnostic was created,
so all "helper" diagnostic functions should use `#[track_caller]`
2023-04-19 19:10:37 +00:00
Maybe Waffle
ceabcd83e6 Remove useless check (drive-by cleanup)
While it might *seem* that this does something, it actually doesn't.
`mut_borrow_of_mutable_ref` returns a `bool` that is ignored by the
let-else. This was basically
```rust
if !self.body.local_decls.get(local).is_some() {
    return
}
```
Which is pretty useless
2023-04-19 19:10:25 +00:00
Maybe Waffle
f79df7d2a4 deny(unsafe_op_in_unsafe_fn) in rustc_data_structures 2023-04-19 18:00:48 +00:00
Maybe Waffle
25b9263b34 Move GenericArgKind::as_{type,const,region} to GenericArg 2023-04-19 17:59:30 +00:00
Michael Goulet
73038d3a64 Make missing impl item suggestions more obvious that they're missing 2023-04-19 17:57:37 +00:00
Michael Goulet
204c516293 Substitute missing item suggestion correctly 2023-04-19 17:47:39 +00:00
Kevin Reid
883606f2c0 fmt fix 2023-04-19 10:06:30 -07:00
bors
df0d9b492d Auto merge of #110496 - WaffleLapkin:🏳️‍⚧️sound, r=compiler-errors
Don't transmute `&List<GenericArg>` <-> `&List<Ty>`

In #93505 we allowed safely transmuting between `&List<GenericArg<'_>>` and `&List<Ty<'_>>`. This was possible because `GenericArg` is a tagged pointer and the tag for types is `0b00`, such that a `GenericArg` with a type inside has the same layout as `Ty`.

While this was meant as an optimization, it doesn't look like it was actually any perf or max-rss win (see https://github.com/rust-lang/rust/pull/94799#issuecomment-1064340003, https://github.com/rust-lang/rust/pull/94841, https://github.com/rust-lang/rust/pull/110496#issuecomment-1513799140).

Additionally the way it was done is quite fragile — `unsafe` code was not properly documented or contained in a module, types were not marked as `repr(C)` (making the transmutes possibly unsound). All of this makes the code maintenance harder and blocks other possible optimizations (as an example I've found out about these `transmutes` when my change caused them to sigsegv compiler).

Thus, I think we can safely (pun intended) remove those transmutes, making maintenance easier, optimizations possible, code less cursed, etc.

r? `@compiler-errors`
2023-04-19 17:01:06 +00:00
Michael Goulet
b0a7d6e4b7 Suggest deref on comparison binop RHS even if type is not Copy 2023-04-19 16:47:11 +00:00
Kevin Reid
f17c805701 Make impl Debug for Span not panic on not having session globals. 2023-04-19 08:55:21 -07:00