Commit Graph

245566 Commits

Author SHA1 Message Date
Ben Kimock
55fabf35b1 Add a new debug_assertions intrinsic 2024-02-08 11:49:07 -05:00
Ben Kimock
580067c76f InstSimplify rustc_nounwind calls 2024-02-08 11:49:05 -05:00
Ben Kimock
9842a5ca7f Don't lower assume in unoptimized builds 2024-02-08 11:49:04 -05:00
bors
c29082fe7d Auto merge of #120544 - BoxyUwU:enter_forall, r=lcnr
Introduce `enter_forall` to supercede `instantiate_binder_with_placeholders`

r? `@lcnr`

Long term we'd like to experiment with decrementing the universe count after "exiting" binders so that we do not end up creating infer vars in non-root universes even when they logically reside in the root universe. The fact that we dont do this currently results in a number of issues in the new trait solver where we consider goals to be ambiguous because otherwise it would require lowering the universe of an infer var. i.e. the goal  `?x.0 eq <T as Trait<?y.1>>::Assoc` where the alias is rigid would not be able to instantiate `?x` with the alias as there would be a universe error.

This PR is the first-ish sort of step towards being able to implement this as eventually we would want to decrement the universe in `enter_forall`. Unfortunately its Difficult to actually implement decrementing universes nicely so this is a separate step which moves us closer to the long term goal 
2024-02-08 16:42:56 +00:00
Carol (Nichols || Goulding)
5cb9e318c8
Add release note for new ambiguous_wide_pointer_comparisons lint 2024-02-08 11:01:33 -05:00
Michael Goulet
9322882ade Add a couple more tests 2024-02-08 15:46:07 +00:00
Michael Goulet
3bb384aad6 Prefer AsyncFn* over Fn* for coroutine-closures 2024-02-08 15:46:00 +00:00
Oli Scherer
7dc182d5d4 Fix mir pass ICE in the presence of other errors 2024-02-08 14:49:27 +00:00
Oli Scherer
6af2d3cc90 Fix span_bug! backtraces 2024-02-08 14:44:52 +00:00
Boxy
f867742be8 reviews + rebase 2024-02-08 13:19:25 +00:00
Boxy
b181a12623 rename instantiate_binder_with_placeholders 2024-02-08 13:01:08 +00:00
Boxy
ac559af98f introduce enter_forall 2024-02-08 13:01:08 +00:00
zetanumbers
da4ec6ffa7 Deduplicate tcx.instance_mir(instance) calls in try_instance_mir 2024-02-08 15:47:14 +03:00
Mark Rousskov
9a5034a20e Step all bootstrap cfgs forward
This also takes care of other bootstrap-related changes.
2024-02-08 07:44:34 -05:00
Mark Rousskov
9784a14859 Bump to newly branched stage0 compiler 2024-02-08 07:43:38 -05:00
Mark Rousskov
8043821b3a Bump version placeholders 2024-02-08 07:43:38 -05:00
Oli Scherer
d80d7ea1e3 Add some tests for associated type normalization edge cases 2024-02-08 12:28:35 +00:00
bors
1280928a99 Auto merge of #120767 - matthiaskrgr:rollup-0k8ib1c, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #119592 (resolve: Unload speculatively resolved crates before freezing cstore)
 - #120103 (Make it so that async-fn-in-trait is compatible with a concrete future in implementation)
 - #120206 (hir: Make sure all `HirId`s have corresponding HIR `Node`s)
 - #120214 (match lowering: consistently lower bindings deepest-first)
 - #120688 (GVN: also turn moves into copies with projections)
 - #120702 (docs: also check the inline stmt during redundant link check)
 - #120727 (exhaustiveness: Prefer "`0..MAX` not covered" to "`_` not covered")
 - #120734 (Add `SubdiagnosticMessageOp` as a trait alias.)
 - #120739 (improve pretty printing for associated items in trait objects)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-08 12:14:19 +00:00
joboet
c0d9776562
std: move path into sys 2024-02-08 12:51:35 +01:00
Nadrieril
4733b1bba5 Test min_exhaustive_patterns in more cases 2024-02-08 11:48:38 +01:00
Nadrieril
30793ca818 Match min_exhaustive_patterns implementation with exhaustive_patterns 2024-02-08 11:23:52 +01:00
Mara Bos
f676c3d504 Remove myself from review rotation. 2024-02-08 11:06:02 +01:00
bors
af88f7db51 Auto merge of #120550 - oli-obk:track_errors8, r=estebank
Continue to borrowck even if there were previous errors

but only from the perspective of the whole compiler. Individual items should not get borrowcked if their MIR is tainted by errors.

r? `@estebank` `@nnethercote`
2024-02-08 10:05:39 +00:00
Oli Scherer
aa6f45eb79 Use ensure when the result of the query is not needed beyond its Resultness 2024-02-08 09:30:42 +00:00
Tshepang Mbambo
0ce71f6985 make future diffs minimal 2024-02-08 11:06:51 +02:00
Amanda Stjerna
795be51dd9 Make RegionName Copy by (transitively) interning the few string variants 2024-02-08 09:43:44 +01:00
Oli Scherer
eab2adb660 Continue to borrowck even if there were previous errors 2024-02-08 08:10:43 +00:00
Matthias Krüger
a059dd88bf
Rollup merge of #120739 - lukas-code:pp-dyn-assoc, r=compiler-errors
improve pretty printing for associated items in trait objects

* Don't print a binder in front of associated items, because it's not valid syntax.
  * e.g. print `dyn for<'a> Trait<'a, Assoc = &'a u8>` instead of `dyn for<'a> Trait<'a, for<'a> Assoc = &'a u8>`.
* Don't print associated items that are implied by a supertrait bound.
  * e.g. if we have `trait Sub: Super<Assoc = u8> {}`, then just print `dyn Sub` instead of `dyn Sub<Assoc = u8>`.

I've added the test in the first commit, so you can see the diff of the compiler output in the second commit.
2024-02-08 09:06:36 +01:00
Matthias Krüger
87e1e05aa1
Rollup merge of #120734 - nnethercote:SubdiagnosticMessageOp, r=compiler-errors
Add `SubdiagnosticMessageOp` as a trait alias.

It avoids a lot of repetition.

r? matthewjasper
2024-02-08 09:06:36 +01:00
Matthias Krüger
5157190008
Rollup merge of #120727 - Nadrieril:tweak-int-reporting, r=compiler-errors
exhaustiveness: Prefer "`0..MAX` not covered" to "`_` not covered"

There was an exception when reporting integer ranges as missing, it's been there for as long as I can remember. This PR removes it. I think it's nicer to report "`0..MAX` not covered" than "`_` not covered". This also makes it consistent with enums, where we report individual enum variants in this case (as showcased in the rest of the `empty-match.rs` test).

r? ``@estebank``
2024-02-08 09:06:35 +01:00
Matthias Krüger
fec32358b5
Rollup merge of #120702 - bvanjoi:fix-120444, r=notriddle
docs: also check the inline stmt during redundant link check

Fixes #120444

This issue was brought about by querying `root::webdavfs::A`, a key that doesn't exist in `doc_link_resolutions`. To avoid a panic, I've altered the gating mechanism to allow this lint pass to be skipped.

I'm not certain if this is the best solution. An alternative approach might be to leverage other info from the name resolutions instead of `doc_link_resolutions`. After all, all we need is to get the resolution from a combination of `(module, name)`. However, I believe they would yield the same outcome, both skipping this lint.
2024-02-08 09:06:35 +01:00
Matthias Krüger
65aa9eae73
Rollup merge of #120688 - cjgillot:gvn-partial-move, r=oli-obk
GVN: also turn moves into copies with projections

Fixes https://github.com/rust-lang/rust/issues/120613
2024-02-08 09:06:34 +01:00
Matthias Krüger
7fb36f2d3b
Rollup merge of #120214 - Nadrieril:fix-120210, r=pnkfelix
match lowering: consistently lower bindings deepest-first

Currently when lowering match expressions to MIR, we do a funny little dance with the order of bindings. I attempt to explain it in the third commit: we handle refutable (i.e. needing a test) patterns differently than irrefutable ones. This leads to inconsistencies, as reported in https://github.com/rust-lang/rust/issues/120210. The reason we need a dance at all is for situations like:

```rust
fn foo1(x: NonCopyStruct) {
    let y @ NonCopyStruct { copy_field: z } = x;
    // the above should turn into
    let z = x.copy_field;
    let y = x;
}
```

Here the `y ```````@```````` binding will move out of `x`, so we need to copy the field first.

I believe that the inconsistency came about when we fixed https://github.com/rust-lang/rust/issues/69971, and didn't notice that the fix didn't extend to refutable patterns. My guess then is that ordering bindings by "deepest-first, otherwise source order" is a sound choice. This PR implements that (at least I hope, match lowering is hard to follow 🥲).

Fixes https://github.com/rust-lang/rust/issues/120210

r? ```````@oli-obk``````` since you merged the original fix to https://github.com/rust-lang/rust/issues/69971
cc ```````@matthewjasper```````
2024-02-08 09:06:33 +01:00
Matthias Krüger
bf2ba8611e
Rollup merge of #120206 - petrochenkov:somehir, r=compiler-errors
hir: Make sure all `HirId`s have corresponding HIR `Node`s

And then remove `tcx.opt_hir_node(hir_id)` in favor of `tcx.hir_node(hir_id)`.
2024-02-08 09:06:32 +01:00
Matthias Krüger
9ec5960e3d
Rollup merge of #120103 - compiler-errors:concrete-afits, r=oli-obk
Make it so that async-fn-in-trait is compatible with a concrete future in implementation

There's no technical reason why an AFIT like `async fn foo()` cannot be satisfied with an implementation signature like `fn foo() -> Pin<Box<dyn Future<Output = ()> + 'static>>`.

We rejected this previously because we were uncertain about how AFITs worked with refinement, but I don't believe this needs to be a restriction any longer.

r? oli-obk
2024-02-08 09:06:32 +01:00
Matthias Krüger
4e11d03d0e
Rollup merge of #119592 - petrochenkov:unload, r=compiler-errors
resolve: Unload speculatively resolved crates before freezing cstore

Name resolution sometimes loads additional crates to improve diagnostics (e.g. suggest imports).
Not all of these diagnostics result in errors, sometimes they are just warnings, like in #117772.

If additional crates loaded speculatively stay and gets listed by things like `query crates` then they may produce further errors like duplicated lang items, because lang items from speculatively loaded crates are as good as from non-speculatively loaded crates.
They can probably do things like adding unintended impls from speculatively loaded crates to method resolution as well.
The extra crates will also get into the crate's metadata as legitimate dependencies.

In this PR I remove the speculative crates from cstore when name resolution is finished and cstore is frozen.
This is better than e.g. filtering away speculative crates in `query crates` because things like `DefId`s referring to these crates and leaking to later compilation stages can produce ICEs much easier, allowing to detect them.

The unloading could potentially be skipped if any errors were reported (to allow using `DefId`s from speculatively loaded crates for recovery), but I didn't do it in this PR because I haven't seen such cases of recovery. We can reconsider later if any relevant ICEs are reported.

Unblocks https://github.com/rust-lang/rust/pull/117772.
2024-02-08 09:06:31 +01:00
bors
81bef0b0ba Auto merge of #120579 - GuillaumeGomez:prevent-running-unneeded-code, r=notriddle
Prevent running some code if it is already in the map

I realized that a lot of duplicates were being run through this function. Might be better to prevent them from computing all the information if it's already in the cache.

r? `@notriddle`
2024-02-08 07:55:03 +00:00
Oli Scherer
e5461de392 Taint borrowck results without running any borrowck if the MIR body was already tainted 2024-02-08 07:39:49 +00:00
Oli Scherer
1fcd04ed49 inline a function that is only used in clippy 2024-02-08 07:37:02 +00:00
Oli Scherer
8a5847f5c4 Already poison the type_of result of the anon const used in the typeof expression 2024-02-08 07:32:30 +00:00
bors
870a01a30e Auto merge of #120558 - oli-obk:missing_impl_item_ice, r=estebank
Stop bailing out from compilation just because there were incoherent traits

fixes #120343

but also has a lot of "type annotations needed" fallout. Some are fixed in the second commit.
2024-02-08 05:01:09 +00:00
Venus Xeon-Blonde
8ff1994ec0
Fix whitespace issues that tidy caught 2024-02-07 23:37:34 -05:00
Venus Xeon-Blonde
f0c6f5a7fe
Add documentation on str::starts_with
Add documentation about a current footgun of `str::starts_with`
2024-02-07 23:29:22 -05:00
bors
384b02c082 Auto merge of #120521 - reitermarkus:generic-nonzero-constructors, r=dtolnay
Make `NonZero` constructors generic.

This makes `NonZero` constructors generic, so that `NonZero::new` can be used without turbofish syntax.

Tracking issue: https://github.com/rust-lang/rust/issues/120257

~~I cannot figure out how to make this work with `const` traits. Not sure if I'm using it wrong or whether there's a bug:~~

```rust
101 |         if n == T::ZERO {
    |            ^^^^^^^^^^^^ expected `host`, found `true`
    |
    = note: expected constant `host`
               found constant `true`
```

r? `@dtolnay`
2024-02-08 03:00:34 +00:00
Nicholas Nethercote
6b175a848d Add SubdiagnosticMessageOp as a trait alias.
It avoids a lot of repetition.
2024-02-08 13:02:44 +11:00
bors
6894f435d3 Auto merge of #120381 - fee1-dead-contrib:reconstify-add, r=compiler-errors
Reconstify `Add`

r? project-const-traits

I'm not happy with the ui test changes (or failures because I did not bless them and include the diffs in this PR). There is at least some bugs I need to look and try fix:

1. A third duplicated diagnostic when a consumer crate that does not have `effects` enabled has a trait selection error for an upstream const_trait trait. See tests/ui/ufcs/ufcs-qpath-self-mismatch.rs.
2. For some reason, making `Add` a const trait would stop us from suggesting `T: Add` when we try to add two `T`s without that bound. See tests/ui/suggestions/issue-97677.rs
2024-02-08 00:04:14 +00:00
Nadrieril
9dca6be7b8 Prefer "0..MAX not covered" to "_ not covered" 2024-02-07 23:25:11 +01:00
Nadrieril
970f46c60d Add tests 2024-02-07 23:22:46 +01:00
Lukas Markeffsky
c636c7ae2c address review comments and add more tests 2024-02-07 20:58:05 +01:00
bors
8ace7ea1f7 Auto merge of #120748 - Nadrieril:rollup-dj0qwv5, r=Nadrieril
Rollup of 13 pull requests

Successful merges:

 - #110482 (Add armv8r-none-eabihf target for the Cortex-R52.)
 - #119162 (Add unstable `-Z direct-access-external-data` cmdline flag for `rustc`)
 - #120302 (various const interning cleanups)
 - #120455 ( Add FileCheck annotations to MIR-opt SROA tests)
 - #120470 (Mark "unused binding" suggestion as maybe incorrect)
 - #120479 (Suggest turning `if let` into irrefutable `let` if appropriate)
 - #120564 (coverage: Split out counter increment sites from BCB node/edge counters)
 - #120633 (pattern_analysis: gather up place-relevant info)
 - #120664 (Add parallel rustc ui tests)
 - #120726 (Don't use bashism in checktools.sh)
 - #120733 (MirPass: make name more const)
 - #120735 (Remove some `unchecked_claim_error_was_emitted` calls)
 - #120746 (Record coroutine kind in coroutine generics)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-07 19:40:25 +00:00