Commit Graph

99 Commits

Author SHA1 Message Date
bors
f0038a7c8f Auto merge of #124227 - compiler-errors:hack-check-method-res, r=estebank
Make sure that the method resolution matches in `note_source_of_type_mismatch_constraint`

`note_source_of_type_mismatch_constraint` is a pile of hacks that I implemented to cover up another pile of hacks.

It does a bunch of re-confirming methods, but it wasn't previously checking that the methods it was looking (back) up were equal to the methods we previously had. This PR adds those checks.

Fixes #118185
2024-05-22 10:57:59 +00:00
Matthias Krüger
734e216b35 crashes: add more 2024-05-18 23:56:57 +02:00
Michael Goulet
c697ec41f4 Propagate errors rather than using return_if_err 2024-05-12 12:50:18 -04:00
bohan
f70f900036 ignore generics args in attribute paths 2024-05-11 00:13:27 +08:00
lcnr
feff7520df update crashes 2024-05-09 17:51:05 +00:00
Matthias Krüger
812fb24e79
Rollup merge of #124775 - matthiaskrgr:boom, r=jieyouxu
crashes: add lastest batch of crash tests
2024-05-08 23:33:25 +02:00
Matthias Krüger
e997508ecb
Rollup merge of #124548 - gurry:113272-ice-failed-to-normalize, r=compiler-errors
Handle normalization failure in `struct_tail_erasing_lifetimes`

Fixes #113272

The ICE occurred because the struct being normalized had an error. This PR adds some defensive code to guard against that.
2024-05-08 17:03:08 +02:00
bors
faefc618cf Auto merge of #124219 - gurry:122989-ice-unexpected-anon-const, r=compiler-errors
Do not ICE on `AnonConst`s in `diagnostic_hir_wf_check`

Fixes #122989

Below is the snippet from #122989 that ICEs:
```rust
trait Traitor<const N: N<2> = 1, const N: N<2> = N> {
    fn N(&N) -> N<2> {
        M
    }
}

trait N<const N: Traitor<2> = 12> {}
```

The `AnonConst` that triggers the ICE is the `2` in the param `const N: N<2> = 1`. The currently existing code in `diagnostic_hir_wf_check` deals only with `AnonConst`s that are default values of some param, but  the `2` is not a default value. It is just an `AnonConst` HIR node inside a `TraitRef` HIR node corresponding to `N<2>`. Therefore the existing code cannot handle it and this PR ensures that it does.
2024-05-07 20:01:18 +00:00
Matthias Krüger
397a35d081 crashes: add lastest batch of crash tests 2024-05-05 23:41:08 +02:00
Nadrieril
57e8aebb6c Lower never patterns to Unreachable in mir 2024-05-04 16:30:01 +02:00
bors
d2d24e395a Auto merge of #123602 - cjgillot:gvn-borrowed, r=oli-obk
Account for immutably borrowed locals in MIR copy-prop and GVN

For the most part, we consider that immutably borrowed `Freeze` locals still fulfill SSA conditions. As the borrow is immutable, any use of the local will have the value given by the single assignment, and there can be no surprise.

This allows copy-prop to merge a non-borrowed local with a borrowed local. We chose to keep copy-classes heads unborrowed, as those may be easier to optimize in later passes.

This also allows to GVN the value behind an immutable borrow. If a SSA local is borrowed, dereferencing that borrow is equivalent to copying the local's value: re-executing the assignment between the borrow and the dereference would be UB.

r? `@ghost` for perf
2024-05-03 21:50:13 +00:00
Gurinder Singh
0c71c9d74b Handle normalization failure in struct_tail_erasing_lifetimes
Fixes an ICE that occurred when the struct in question has an error
2024-05-01 09:29:33 +05:30
许杰友 Jieyou Xu (Joe)
43265f5721
Rollup merge of #124504 - gurry:123710-union-ICE, r=oli-obk
Mark unions non-const-propagatable in `KnownPanicsLint` without calling layout

Fixes #123710

The ICE occurs during the layout calculation of the union `InvalidTag` in #123710 because the following assert fails:5fe8b697e7/compiler/rustc_abi/src/layout.rs (L289-L292)

The layout calculation is invoked by `KnownPanicsLint` when it is trying to figure out which locals it can const prop. Since `KnownPanicsLint` is never actually going to const props unions thanks to PR https://github.com/rust-lang/rust/pull/121628 there's no point calling layout to check if it can. So in this fix I skip the call to layout and just mark the local non-const propagatable if it is a union.
2024-04-29 18:03:24 +01:00
Gurinder Singh
254a9fbe86 Prohibit const prop of unions in KnownPanicsLint
as they have a potential to ICE during layout calculation
2024-04-29 08:16:26 +05:30
Matthias Krüger
c32e2fe179 add test for https://github.com/rust-lang/rust/issues/109812 2024-04-28 10:23:10 +02:00
Matthias Krüger
aeb4c0413c
Rollup merge of #124394 - gurry:123863-ice-unexpected-region, r=lcnr
Fix ICE on invalid const param types

Fixes ICE #123863 which occurs because the const param has a type which is not a `bool`, `char` or an integral type.

The ICEing code path begins here in `typeck_with_fallback`: cb3752d20e/compiler/rustc_hir_typeck/src/lib.rs (L167)

The `fallback` invokes the `type_of` query and that eventually ends up calling `ct_infer` from the lowering code over here:
cb3752d20e/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs (L561) and `ct_infer` ICEs at this location: cb3752d20e/compiler/rustc_hir_analysis/src/collect.rs (L392)

To fix the ICE it I'm triggering a `span_delayed_bug` before we hit `ct_infer` if the type of the const param is not one of the supported types

### Edit
On `@lcnr's` suggestion I've changed the approach to not let `ReStatic` region hit the `bug!` in `ct_infer` instead of triggering a `span_delayed_bug`.
2024-04-27 20:46:08 +02:00
Gurinder Singh
c62bc31b16 Fix ICE on invalid const param types 2024-04-27 09:36:38 +05:30
Matthias Krüger
60c0fa1285 crashes: add more tests 2024-04-26 17:20:16 +02:00
Michael Goulet
870ed4bfa2 Add test 2024-04-25 10:51:54 -04:00
León Orell Valerian Liehr
e15d6f9d85
Rollup merge of #123993 - compiler-errors:coroutine-obl, r=lcnr
Do `check_coroutine_obligations` once per typeck root

We only need to do `check_coroutine_obligations` once per typeck root, especially since the new solver can't really (easily) associate which obligations correspond to which coroutines.

This requires us to move the checks for sized coroutine fields into `mir_coroutine_witnesses`, but that's fine imo.

r? lcnr
2024-04-23 17:25:16 +02:00
Matthias Krüger
8859631b40
Rollup merge of #124057 - gurry:124031-ice-layout-errored, r=compiler-errors
Fix ICE when ADT tail has type error

Fixes #124031
2024-04-23 06:24:55 +02:00
Gurinder Singh
446f78d051 Do not ICE on AnonConsts in diagnostic_hir_wf_check 2024-04-22 10:31:32 +05:30
Gurinder Singh
06cd79bb5b Fix ICE when ADT tail has type error 2024-04-22 09:12:36 +05:30
Matthias Krüger
6774801563 crashes: add a couple more ICE tests 2024-04-21 21:04:32 +02:00
Michael Goulet
483f13ce91 Make sure that the method resolution matches in note_source_of_type_mismatch_constraint 2024-04-21 11:11:31 -04:00
Camille GILLOT
c19866f335 Remove no_core ICE test. 2024-04-20 19:28:48 +00:00
bors
f1bff1f323 Auto merge of #124176 - matthiaskrgr:tests_are_the_best, r=jieyouxu
add more known crashes tests

r? `@jieyouxu`
2024-04-20 06:36:58 +00:00
Matthias Krüger
b015f61488 add more known-crashes tests 2024-04-19 23:09:37 +02:00
Maybe Waffle
e5a6d8d0cd Remove old ICE tests that no longer ICE (yay!) 2024-04-19 11:34:37 +00:00
bors
fa0068b541 Auto merge of #124038 - matthiaskrgr:one_or_two_more_tests, r=jieyouxu
crashes: add a couple more ice tests
2024-04-19 01:02:44 +00:00
Matthias Krüger
1d45b7adaf crashes: add a couple more tests 2024-04-18 18:55:20 +02:00
Scott McMurray
20cf59549f The ICE in 121127 needs debuginfo 2024-04-18 09:42:26 -07:00
bors
b1248bc60d Auto merge of #124046 - matthiaskrgr:one_or_two_more_tests____some_on_top, r=jieyouxu
crashes: add even more tests?!?

adds more tests that were not already added with https://github.com/rust-lang/rust/pull/124038 from the past 10 months or so.
Need a couple more passes through the tracker to filter out more missing ice /fixed tests but we're slowly getting there.
2024-04-18 05:23:09 +00:00
Matthias Krüger
06335c6532 crashes: add even more tests?!? 2024-04-18 06:13:47 +02:00
Oli Scherer
8c9cba2be7 Validate nested static items 2024-04-17 09:50:15 +00:00
Guillaume Gomez
4885ddfa92
Rollup merge of #123675 - oli-obk:static_wf_ice, r=compiler-errors
Taint const qualifs if a static is referenced that didn't pass wfcheck

It is correct to only check the signature here, as the ICE is caused by `USE_WITH_ERROR` trying to allocate memory to store the result of `WITH_ERROR` before evaluating it.

fixes #123153
2024-04-17 00:00:22 +02:00
Oli Scherer
801413ecd1 Taint const qualifs if a static is referenced that didn't pass wfcheck 2024-04-16 10:43:41 +00:00
Gurinder Singh
c30e15aded Fail candidate assembly for erroneous types
Trait predicates for types which have errors may still
evaluate to OK leading to downstream ICEs. Now we return
a selection error for such types in candidate assembly and
thereby prevent such issues
2024-04-16 12:42:48 +05:30
Michael Goulet
a8c9a0bd81 crash -> test 2024-04-15 22:21:50 -04:00
Matthias Krüger
83d73e4929 crashes: readme: add reminder to add Fixes #abcde to prs to automatically close issues. 2024-04-15 21:44:04 +02:00
Matthias Krüger
2ce487c45c crashes: limit a couple tests to only run on x86_64 and/or not on windows 2024-04-14 23:53:39 +02:00
Matthias Krüger
37df49059d update README and add COMPILETEST_VERBOSE_CRASHES env var which when set print stdout, stderr and exit code of "crashes" tests, useful for debugging or adding new tests 2024-04-14 11:30:29 +02:00
Matthias Krüger
6d9175f98e crashes: fix ice detection which did not trigger if code compiled without error by accident 2024-04-14 11:21:58 +02:00
Matthias Krüger
7d826ae43e tests/crashes: add ICEs from matthiaskrgr/glacier2 2024-04-14 11:21:51 +02:00
Matthias Krüger
98dd566033 add .rs crashes from https://github.com/rust-lang/glacier 2024-04-14 11:18:23 +02:00
Matthias Krüger
7048ce7e8f tidy: add tidy check agains \.rs files inside tests/crashes that are missing "//@ known-bug: " 2024-04-14 11:16:26 +02:00
Matthias Krüger
d6e70df1a2 crashes: add another test showing that everything works fine when we need compile-flags to repro an ice and add README 2024-04-14 11:16:15 +02:00
Matthias Krüger
7b05360a1e bootstrap/compiletest: implement "crashes" tests that fail if no ice is reproduced 2024-04-14 11:14:45 +02:00
Matthias Krüger
65ca71815a add initial ice as test 2024-04-14 11:04:27 +02:00