Commit Graph

34664 Commits

Author SHA1 Message Date
Zalathar
2d47cd77ac Check x86_64 size assertions on aarch64, too
This makes it easier for contributors on aarch64 workstations (e.g. Macs) to
notice when these assertions have been violated.
2024-04-03 16:53:03 +11:00
bors
b688d53a17 Auto merge of #123396 - jhpratt:rollup-oa54mh1, r=jhpratt
Rollup of 5 pull requests

Successful merges:

 - #122865 (Split hir ty lowerer's error reporting code in check functions to mod errors.)
 - #122935 (rename ptr::from_exposed_addr -> ptr::with_exposed_provenance)
 - #123182 (Avoid expanding to unstable internal method)
 - #123203 (Add `Context::ext`)
 - #123380 (Improve bootstrap comments)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-03 02:13:07 +00:00
Jacob Pratt
e41d7e7aaf
Rollup merge of #123182 - jhpratt:fix-decodable-derive, r=davidtwco
Avoid expanding to unstable internal method

Fixes #123156

Rather than expanding to `std::rt::begin_panic`, the expansion is now to `unreachable!()`. The resulting behavior is identical. A test that previously triggered the same error as #123156 has been added to ensure it does not regress.

r? compiler
2024-04-02 20:37:40 -04:00
Jacob Pratt
e9ef8e1efa
Rollup merge of #122935 - RalfJung:with-exposed-provenance, r=Amanieu
rename ptr::from_exposed_addr -> ptr::with_exposed_provenance

As discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/To.20expose.20or.20not.20to.20expose/near/427757066).

The old name, `from_exposed_addr`, makes little sense as it's not the address that is exposed, it's the provenance. (`ptr.expose_addr()` stays unchanged as we haven't found a better option yet. The intended interpretation is "expose the provenance and return the address".)

The new name nicely matches `ptr::without_provenance`.
2024-04-02 20:37:39 -04:00
Jacob Pratt
0697ee9af5
Rollup merge of #122865 - surechen:refactor_astconv_error_report_20240321, r=lcnr
Split hir ty lowerer's error reporting code in check functions to mod errors.

Move some error report codes to mod `astconv/errors.rs`

r? `@lcnr`
2024-04-02 20:37:39 -04:00
bors
40f743da23 Auto merge of #122791 - compiler-errors:make-coinductive-always, r=lcnr
Make inductive cycles always ambiguous

 This makes inductive cycles always result in ambiguity rather than be treated like a stack-dependent error.

This has some  interactions with specialization, and so breaks a few UI tests that I don't agree should've ever worked in the first place, and also breaks a handful of crates in a way that I don't believe is a problem.

On the bright side, it puts us in a better spot when it comes to eventually enabling coinduction everywhere.

## Results

This was cratered in https://github.com/rust-lang/rust/pull/116494#issuecomment-2008657494, which boils down to two regressions:
* `lu_packets` - This code should have never compiled in the first place. More below.
* **ALL** other regressions are due to `commit_verify@0.11.0-beta.1` (edit: and `commit_verify@0.10.x`) - This actually seems to be fixed in version `0.11.0-beta.5`, which is the *most* up to date version, but it's still prerelease on crates.io so I don't think cargo ends up picking `beta.5` when building dependent crates.

### `lu_packets`

Firstly, this crate uses specialization, so I think it's automatically worth breaking. However, I've minimized [the regression](https://crater-reports.s3.amazonaws.com/pr-116494-3/try%23d614ed876e31a5f3ad1d0fbf848fcdab3a29d1d8/gh/lcdr.lu_packets/log.txt) to:

```rust
// Upstream crate
pub trait Serialize {}
impl Serialize for &() {}
impl<S> Serialize for &[S] where for<'a> &'a S: Serialize {}

// ----------------------------------------------------------------------- //

// Downstream crate
#![feature(specialization)]
#![allow(incomplete_features, unused)]

use upstream::Serialize;

trait Replica {
    fn serialize();
}

impl<T> Replica for T {
    default fn serialize() {}
}

impl<T> Replica for Option<T>
where
    for<'a> &'a T: Serialize,
{
    fn serialize() {}
}
```

Specifically this fails when computing the specialization graph for the `downstream` crate.

The code ends up cycling on `&[?0]: Serialize` when we equate `&?0 = &[?1]` during impl matching, which ends up needing to prove `&[?1]: Serialize`, which since cycles are treated like ambiguity, ends up in a **fatal overflow**. For some reason this requires two crates, squashing them into one crate doesn't work.

Side-note: This code is subtly order dependent. When minimizing, I ended up having the code start failing on `nightly` very easily after removing and reordering impls. This seems to me all the more reason to remove this behavior altogether.

## Side-note: Item Bounds (edit: this was fixed independently in #121123)

Due to the changes in #120584 where we now consider an alias's item bounds *and* all the item bounds of the alias's nested self type aliases, I've had to add e6b64c6194 which is a hack to make sure we're not eagerly normalizing bounds that have nothing to do with the predicate we're trying to solve, and which result in.

This is fixed in a more principled way in #121123.

---

r? lcnr for an initial review
2024-04-03 00:09:44 +00:00
Jacob Pratt
0fcdf34861
Avoid expanding to unstable internal method 2024-04-02 22:21:16 +00:00
bors
88c2f4f5f5 Auto merge of #123385 - matthiaskrgr:rollup-v69vjbn, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #123198 (Add fn const BuildHasherDefault::new)
 - #123226 (De-LLVM the unchecked shifts [MCP#693])
 - #123302 (Make sure to insert `Sized` bound first into clauses list)
 - #123348 (rustdoc: add a couple of regression tests)
 - #123362 (Check that nested statics in thread locals are duplicated per thread.)
 - #123368 (CFI: Support non-general coroutines)
 - #123375 (rustdoc: synthetic auto trait impls: accept unresolved region vars for now)
 - #123378 (Update sysinfo to 0.30.8)

Failed merges:

 - #123349 (Fix capture analysis for by-move closure bodies)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-02 21:23:53 +00:00
Matthias Krüger
9372948889
Rollup merge of #123368 - maurer:cfi-non-general-coroutines, r=compiler-errors
CFI: Support non-general coroutines

Previously, we assumed all `ty::Coroutine` were general coroutines and attempted to generalize them through the `Coroutine` trait. Select appropriate traits for each kind of coroutine.

I have this marked as a draft because it currently only fixes async coroutines, and I think it make sense to try to fix gen/async gen coroutines before this is merged.

If the issue [mentioned](https://github.com/rust-lang/rust/pull/123106#issuecomment-2030794213) in the original PR is actually affecting someone, we can land this as is to remedy it.
2024-04-02 21:22:03 +02:00
Matthias Krüger
5b717684ff
Rollup merge of #123362 - oli-obk:thread_local_nested_statics, r=estebank
Check that nested statics in thread locals are duplicated per thread.

follow-up to #123310

cc ``@compiler-errors`` ``@RalfJung``

fwiw: I have no idea how thread local statics make that work under LLVM, and miri fails on this example, which I would have expected to be the correct behaviour.

Since the `#[thread_local]` attribute is just an internal implementation detail, I'm just going to start hard erroring on nested mutable statics in thread locals.
2024-04-02 21:22:03 +02:00
Matthias Krüger
a38dde9289
Rollup merge of #123302 - compiler-errors:sized-bound-first, r=estebank
Make sure to insert `Sized` bound first into clauses list

#120323 made it so that we don't insert an implicit `Sized` bound whenever we see an *explicit* `Sized` bound. However, since the code that inserts implicit sized bounds puts the bound as the *first* in the list, that means that it had the **side-effect** of possibly meaning we check `Sized` *after* checking other trait bounds.

If those trait bounds result in ambiguity or overflow or something, it may change how we winnow candidates. (**edit: SEE** #123303) This is likely the cause for the regression in https://github.com/rust-lang/rust/issues/123279#issuecomment-2028899598, since the impl...

```rust
impl<T: Job + Sized> AsJob for T { // <----- changing this to `Sized + Job` or just `Job` (which turns into `Sized + Job`) will FIX the issue.
}
```

...looks incredibly suspicious.

Fixes [after beta-backport] #123279.

Alternative is to revert #120323. I don't have a strong opinion about this, but think it may be nice to keep the diagnostic changes around.
2024-04-02 21:22:01 +02:00
Matthias Krüger
1b0e46f8a0
Rollup merge of #123226 - scottmcm:u32-shifts, r=WaffleLapkin
De-LLVM the unchecked shifts [MCP#693]

This is just one part of the MCP (https://github.com/rust-lang/compiler-team/issues/693), but it's the one that IMHO removes the most noise from the standard library code.

Seems net simpler this way, since MIR already supported heterogeneous shifts anyway, and thus it's not more work for backends than before.

r? WaffleLapkin
2024-04-02 21:22:01 +02:00
bors
a77322c16f Auto merge of #118310 - scottmcm:three-way-compare, r=davidtwco
Add `Ord::cmp` for primitives as a `BinOp` in MIR

Update: most of this OP was written months ago.  See https://github.com/rust-lang/rust/pull/118310#issuecomment-2016940014 below for where we got to recently that made it ready for review.

---

There are dozens of reasonable ways to implement `Ord::cmp` for integers using comparison, bit-ops, and branches.  Those differences are irrelevant at the rust level, however, so we can make things better by adding `BinOp::Cmp` at the MIR level:

1. Exactly how to implement it is left up to the backends, so LLVM can use whatever pattern its optimizer best recognizes and cranelift can use whichever pattern codegens the fastest.
2. By not inlining those details for every use of `cmp`, we drastically reduce the amount of MIR generated for `derive`d `PartialOrd`, while also making it more amenable to MIR-level optimizations.

Having extremely careful `if` ordering to μoptimize resource usage on broadwell (#63767) is great, but it really feels to me like libcore is the wrong place to put that logic.  Similarly, using subtraction [tricks](https://graphics.stanford.edu/~seander/bithacks.html#CopyIntegerSign) (#105840) is arguably even nicer, but depends on the optimizer understanding it (https://github.com/llvm/llvm-project/issues/73417) to be practical.  Or maybe [bitor is better than add](https://discourse.llvm.org/t/representing-in-ir/67369/2?u=scottmcm)?  But maybe only on a future version that [has `or disjoint` support](https://discourse.llvm.org/t/rfc-add-or-disjoint-flag/75036?u=scottmcm)?  And just because one of those forms happens to be good for LLVM, there's no guarantee that it'd be the same form that GCC or Cranelift would rather see -- especially given their very different optimizers.  Not to mention that if LLVM gets a spaceship intrinsic -- [which it should](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Suboptimal.20inlining.20in.20std.20function.20.60binary_search.60/near/404250586) -- we'll need at least a rustc intrinsic to be able to call it.

As for simplifying it in Rust, we now regularly inline `{integer}::partial_cmp`, but it's quite a large amount of IR.  The best way to see that is with 8811efa88b (diff-d134c32d028fbe2bf835fef2df9aca9d13332dd82284ff21ee7ebf717bfa4765R113) -- I added a new pre-codegen MIR test for a simple 3-tuple struct, and this PR change it from 36 locals and 26 basic blocks down to 24 locals and 8 basic blocks.  Even better, as soon as the construct-`Some`-then-match-it-in-same-BB noise is cleaned up, this'll expose the `Cmp == 0` branches clearly in MIR, so that an InstCombine (#105808) can simplify that to just a `BinOp::Eq` and thus fix some of our generated code perf issues.  (Tracking that through today's `if a < b { Less } else if a == b { Equal } else { Greater }` would be *much* harder.)

---

r? `@ghost`
But first I should check that perf is ok with this
~~...and my true nemesis, tidy.~~
2024-04-02 19:21:44 +00:00
Matthew Maurer
a333b82d04 CFI: Support non-general coroutines
Previously, we assumed all `ty::Coroutine` were general coroutines and
attempted to generalize them through the `Coroutine` trait. Select
appropriate traits for each kind of coroutine.
2024-04-02 17:34:42 +00:00
Scott McMurray
327aa199dd Improve the build_shift_expr_rhs comment 2024-04-02 10:17:21 -07:00
Guillaume Gomez
0bf8140a5e
Rollup merge of #123366 - oli-obk:cleanups_async_closures, r=compiler-errors
Minor by_move_body impl cleanups

r? `@compiler-errors`
2024-04-02 18:18:51 +02:00
Oli Scherer
6f3cc0903c Avoid an is_empty() followed by an index op in favor of a single fallible op 2024-04-02 14:13:05 +00:00
Oli Scherer
b4993c47f2 Prefer UnordSet over FxHashSet where possible 2024-04-02 14:10:06 +00:00
Oli Scherer
64b75f736d Forbid implicit nested statics in thread local statics 2024-04-02 13:00:46 +00:00
bors
5dbaafdb93 Auto merge of #123340 - fmease:rustdoc-simplify-auto-trait-impl-synth, r=GuillaumeGomez
rustdoc: heavily simplify the synthesis of auto trait impls

`gd --numstat HEAD~2 HEAD src/librustdoc/clean/auto_trait.rs`
**+315 -705** 🟩🟥🟥🟥

---

As outlined in issue #113015, there are currently 3[^1] large separate routines that “clean” `rustc_middle::ty` data types related to generics & predicates to rustdoc data types. Every single one has their own kinds of bugs. While I've patched a lot of bugs in each of the routines in the past, it's about time to unify them. This PR is only the first in a series. It completely **yanks** the custom “bounds cleaning” of mod `auto_trait` and reuses the routines found in mod `simplify`. As alluded to, `simplify` is also flawed but it's still more complete than `auto_trait`'s routines. [See also my review comment over at `tests/rustdoc/synthetic_auto/bounds.rs`](https://github.com/rust-lang/rust/pull/123340#discussion_r1546900539).

This is preparatory work for rewriting “bounds cleaning” from scratch in follow-up PRs in order to finally [fix] #113015.

Apart from that, I've eliminated all potential sources of *instability* in the rendered output.
See also #119597. I'm pretty sure this fixes #119597.

This PR does not attempt to fix [any other issues related to synthetic auto trait impls](https://github.com/rust-lang/rust/issues?q=is%3Aissue+is%3Aopen+label%3AA-synthetic-impls%20label%3AA-auto-traits).
However, it's definitely meant to be a *stepping stone* by making `auto_trait` more contributor-friendly.

---

* Replace `FxHash{Map,Set}` with `FxIndex{Map,Set}` to guarantee a stable iteration order
  * Or as a perf opt, `UnordSet` (a thin wrapper around `FxHashSet`) in cases where we never iterate over the set.
  * Yes, we do make use of `swap_remove` but that shouldn't matter since all the callers are deterministic. It does make the output less “predictable” but it's still better than before. Ofc, I rely on `rustc_infer` being deterministic. I hope that holds.
* Utilizing `clean::simplify` over the custom “bounds cleaning” routines wipes out the last reference to `collect_referenced_late_bound_regions` in rustdoc (`simplify` uses `bound_vars`) which was a source of instability / unpredictability (cc #116388)
* Remove the types `RegionTarget` and `RegionDeps` from `librustdoc`. They were duplicates of the identical types found in `rustc`. Just import them from `rustc`. For some reason, they were duplicated when splitting `auto_trait` in two in #49711.
* Get rid of the useless “type namespace” `AutoTraitFinder` in `librustdoc`
  * The struct only held a `DocContext`, it was over-engineered
  * Turn the associated functions into free ones
    * Eliminates rightward drift; increases legibility
  * `rustc` also contains a useless `AutoTraitFinder` struct but I plan on removing that in a follow-up PR
* Rename a bunch of methods to be way more descriptive
* Eliminate `use super::*;`
  * Lead to `clean/mod.rs` accumulating a lot of unnecessary imports
  * Made `auto_traits` less modular
* Eliminate a custom `TypeFolder`: We can just use the rustc helper `fold_regions` which does that for us

I plan on adding extensive documentation to `librustdoc`'s `auto_trait` in follow-up PRs.
I don't want to do that in this PR because further refactoring & bug fix PRs may alter the overall structure of `librustdoc`'s & `rustc`'s `auto_trait` modules to a great degree. I'm slowly digging into the dark details of `rustc`'s `auto_trait` module again and once I have the full picture I will be able to provide proper docs.

---

While this PR does indeed touch `rustc`'s `auto_trait` — mostly tiny refactorings — I argue this PR doesn't need any compiler reviewers next to rustdoc ones since that module falls under the purview of rustdoc — it used to be part of `librustdoc` after all (#49711).

Sorry for not having split this into more commits. If you'd like me to I can try to split it into more atomic commits retroactively. However, I don't know if that would actually make reviewing easier. I think the best way to review this might just be to place the master version of `auto_trait` on the left of your screen and the patched one on the right, not joking.

r? `@GuillaumeGomez`

[^1]: Or even 4 depending on the way you're counting.
2024-04-02 12:13:44 +00:00
surechen
1012218ba8 t plit astconv's error report code in check functions to mod errors.
Move some error report codes to mod `astconv/errors.rs`
2024-04-02 20:10:35 +08:00
bors
0e682e9875 Auto merge of #123347 - saethlin:only-allow-upstream-llvm-calls, r=Nilstrieb
Only allow compiler_builtins to call LLVM intrinsics, not any link_name function

This is another case of accidental reliance on `inline(never)` like I rooted out in https://github.com/rust-lang/rust/pull/118770. Without this PR, attempting to build some large programs with `-Zcross-crate-inline-threshold=yes` with a sysroot also compiled with that flag will result in linker errors like this:
```
  = note: /usr/bin/ld: /tmp/cargo-installNrfN4T/x86_64-unknown-linux-gnu/release/deps/libcompiler_builtins-d2a9b69f4e45b883.rlib(compiler_builtins-d2a9b69f4e45b883.compiler_builtins.dbbc6c2ca970faa4-cgu.0.rcgu.o): in function `core::panicking::panic_fmt':
          /home/ben/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panicking.rs:72:(.text.unlikely._ZN4core9panicking9panic_fmt17ha407cc99e97c942fE+0x31): undefined reference to `rust_begin_unwind'
```
With `-Zcross-crate-inline-threshold=yes` we can inline `panic_fmt` into `compiler_builtins`. Then we end up with a call to an upstream monomorphization, but one that has a `link_name` set. But unlike LLVM's magic intrinsic names, this link name is going to make it to the linker, and then we have a problem.

This logic looks scuffed, but also we're doing this in 4 other places. Don't know if that means it's good or bad.
1684a753db/compiler/rustc_codegen_cranelift/src/abi/mod.rs (L386)
1684a753db/compiler/rustc_ast_passes/src/feature_gate.rs (L306)
1684a753db/compiler/rustc_codegen_ssa/src/codegen_attrs.rs (L609)
1684a753db/compiler/rustc_codegen_gcc/src/declare.rs (L170)
2024-04-02 09:41:27 +00:00
Michael Goulet
09ea3f93ee Fix obligation param and bless tests 2024-04-01 22:48:23 -04:00
Michael Goulet
5f59b7f763 Instantiate closure-like bounds with placeholders to deal with binders correctly 2024-04-01 22:48:23 -04:00
Michael Goulet
f2fd2d8c70 Make sure to insert Sized bound first into clauses list 2024-04-01 21:41:45 -04:00
Ben Kimock
748dba2baf Only allow upstream calls to LLVM intrinsics, not any link_name function 2024-04-01 20:31:19 -04:00
León Orell Valerian Liehr
069e7f2a76
rustdoc: heavily simplify synthesis of auto trait impls 2024-04-02 01:49:57 +02:00
bors
dd5e502d4b Auto merge of #123327 - BoxyUwU:param_env_docs_rewrite, r=compiler-errors
Update `ParamEnv` docs

There is now a wealth of information in the dev guide about `ParamEnv` so we should explicitly link to it from the doc comments. I also added a caution against using `ParamEnv` and removed the comment about it being "suitable for type checking" as you should practically never use `ParamEnv::empty` for type checking

r? `@compiler-errors`
2024-04-01 23:02:17 +00:00
bors
1684a753db Auto merge of #123320 - WaffleLapkin:fixup-never-type-options, r=compiler-errors
Fixup parsing of `rustc_never_type_options` attribute

#122843 had a copy paste error, which I did not caught when testing.

r? `@compiler-errors`
2024-04-01 21:02:53 +00:00
León Orell Valerian Liehr
cbd593ed18
rustdoc: synthetic impls: auto traits: Fx{Hash↦Index}{Map,Set} 2024-04-01 22:15:09 +02:00
Boxy
03dd329355 maybe 2024-04-01 19:59:05 +01:00
Boxy
a91f6221b9 Update ParamEnv docs 2024-04-01 17:29:34 +01:00
bors
6bb6b816bf Auto merge of #122046 - Nadrieril:integrate-or-pats2, r=matthewjasper
match lowering: handle or-patterns one layer at a time

`create_or_subcandidates` and `merge_trivial_subcandidates` both call themselves recursively to handle nested or-patterns, which is hard to follow. In this PR I avoid the need for that; we now process a single "layer" of or-patterns at a time.

By calling back into `match_candidates`, we only need to expand one layer at a time. Conversely, since we always try to simplify a layer that we just expanded (thanks to https://github.com/rust-lang/rust/pull/123067), we only have to merge one layer at a time.

r? `@matthewjasper`
2024-04-01 12:31:27 +00:00
Maybe Waffle
71077482d5 Fixup parsing of rustc_never_type_options attribute
Copy paste error strike again..
2024-04-01 10:56:33 +00:00
bors
3d5528c287 Auto merge of #123310 - compiler-errors:nested-static-codegen-attrs, r=oli-obk
Don't inherit codegen attrs from parent static

Putting this up partly for discussion and partly for review. Specifically, in #121644, `@oli-obk` designed a system that creates new static items for representing nested allocations in statics. However, in that PR, oli made it so that these statics inherited the codegen attrs from the parent.

This causes problems such as colliding symbols with `#[export_name]` and ICEs with `#[no_mangle]` since these synthetic statics have no `tcx.item_name(..)`.

So the question is, is there any case where we *do* want to inherit codegen attrs from the parent? The only one that seems a bit suspicious is the thread-local attribute. And there may be some interesting interactions with the coverage attributes as well...

Fixes (after backport) #123274. Fixes #123243. cc #121644.

r? `@oli-obk` cc `@nnethercote` `@RalfJung` (reviewers on that pr)
2024-04-01 09:22:01 +00:00
bors
7f84ede33d Auto merge of #122663 - beetrees:non-unicode-env-error, r=TaKO8Ki
Fix error message for `env!` when env var is not valid Unicode

Currently (without this PR) the `env!` macro emits an ```environment variable `name` not defined at compile time``` error when the environment variable is defined, but not a valid Unicode string. This PR introduces a separate more accurate error message, and a test to verify this behaviour.

For reference, before this PR, the new test would have outputted:
```
error: environment variable `NON_UNICODE_VAR` not defined at compile time
 --> non_unicode_env.rs:2:13
  |
2 |     let _ = env!("NON_UNICODE_VAR");
  |             ^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: use `std::env::var("NON_UNICODE_VAR")` to read the variable at run time
  = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 1 previous error
```

whereas with this PR, the test ouputs:
```
error: environment variable `NON_UNICODE_VAR` is not a valid Unicode string
 --> non_unicode_env.rs:2:13
  |
2 |     let _ = env!("NON_UNICODE_VAR");
  |             ^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 1 previous error
```
2024-04-01 05:18:51 +00:00
beetrees
0bbaa2505b
Fix error message for env! when env var is not valid Unicode 2024-04-01 05:44:45 +01:00
bors
defef8658e Auto merge of #122972 - beetrees:use-align-type, r=fee1-dead
Use the `Align` type when parsing alignment attributes

Use the `Align` type in `rustc_attr::parse_alignment`, removing the need to call `Align::from_bytes(...).unwrap()` later in the compilation process.
2024-04-01 03:16:45 +00:00
Michael Goulet
4ff8a9bd6b Don't inherit codegen attrs from parent static 2024-03-31 22:34:00 -04:00
beetrees
6e5f1dacf3
Use the Align type when parsing alignment attributes 2024-04-01 03:05:55 +01:00
Michael Goulet
88296bddf8 Remove EvaluatedToErrStackDependent 2024-03-31 20:44:30 -04:00
Michael Goulet
b8396d10c4 Always make inductive cycles as ambig during typeck 2024-03-31 20:44:30 -04:00
bors
bf71daedc2 Auto merge of #121851 - michaelwoerister:mcp-533-effective-vis, r=cjgillot
Use FxIndexMap instead FxHashMap to stabilize iteration order in EffectiveVisibilities

Part of [MCP 533](https://github.com/rust-lang/compiler-team/issues/533).
2024-03-31 16:22:38 +00:00
Matthias Krüger
f04d068adc
Rollup merge of #123242 - Nadrieril:require-contiguous-enum-indices, r=compiler-errors
pattern analysis: Require enum indices to be contiguous

We had a cfg-hack to allow rust-analyzer to use non-contiguous indices for its enum variants. Unfortunately this no longer works if r-a uses the in-tree version of the crate.

This PR removes the hack, and on the r-a side we'll have to use contiguous indices but that's not too hard.

r? `@compiler-errors`
2024-03-31 11:50:41 +02:00
Matthias Krüger
d77608b4b9
Rollup merge of #123211 - compiler-errors:V, r=estebank
Stop calling visitors `V`

Renames some visitors which currently have the unhelpful name of `V`. It's not self-documenting, and there is no situation where saving a few bytes in source code helps anyone.

Stacked on top of #123202 due to conflict.
2024-03-31 11:50:40 +02:00
bors
c93b17d6d2 Auto merge of #123236 - klensy:tracing-tree-bump, r=Mark-Simulacrum
bump tracing-tree to 0.3

Only change in `tracing-tree` is https://github.com/davidbarsky/tracing-tree/pull/76
* dedupes `tracing-log`
* dupes `nu-ansi-term`
2024-03-31 06:21:53 +00:00
bors
5baf1e13f5 Auto merge of #122459 - Nadrieril:sort-eq, r=oli-obk
match lowering: sort `Eq` candidates in the failure case too

This is a slight tweak to MIR gen of matches. Take a match like:
```rust
match (s, flag) {
    ("a", _) if foo() => 1,
    ("b", true) => 2,
    ("a", false) => 3,
    (_, true) => 4,
    _ => 5,
}
```
If we switch on `s == "a"`, the first candidate matches, and we learn almost nothing about the second candidate. So there's a choice:
1. (what we do today) stop sorting candidates, keep the "b" case grouped with everything below. This could allow us to be clever here and test on `flag == true` next.
2. (what this PR does) sort "b" into the failure case. The "b" will be alone (fewer opportunities for picking a good test), but that means the two "a" cases require a single test.

Today, we aren't clever in which tests we pick, so this is an unambiguous win. In a future where we pick tests better, idk. Grouping tests as much as possible feels like a generally good strategy.

This was proposed in https://github.com/rust-lang/rust/issues/29623 (9 years ago :D)
2024-03-31 02:12:50 +00:00
bors
70714e38f2 Auto merge of #123106 - maurer:cfi-closures, r=compiler-errors
CFI: Abstract Closures and Coroutines

This will abstract coroutines in a moment, it's just abstracting closures for now to show `@rcvalle`

This uses the same principal as the methods on traits - figure out the `dyn` type representing the fn trait, instantiate it, and attach that alias set. We're essentially just computing how we would be called in a dynamic context, and attaching that.
2024-03-30 17:56:26 +00:00
Matthew Maurer
8cc9a912d7 CFI: Rewrite closure and coroutine instances to their trait method
Similar to methods on a trait object, the most common way to indirectly
call a closure or coroutine is through the vtable on the appropriate
trait. This uses the same approach as we use for trait methods, after
backing out the trait arguments from the type.
2024-03-30 16:40:38 +00:00
Matthew Maurer
e974570c42 CFI: Only encode Coroutine Parent Args
Fixes #122705
2024-03-30 16:39:51 +00:00