Commit Graph

24 Commits

Author SHA1 Message Date
bors
519d892f95 Auto merge of #121387 - oli-obk:eager_const_failures_regression, r=lcnr
Avoid some unnecessary query invocations.

Specifically this inlines `const_eval_poly` and avoids computing the generic params, the param env, normalizing the param env and erasing lifetimes on everything.

should fix the perf regression from https://github.com/rust-lang/rust/pull/121087
2024-03-26 10:52:11 +00:00
Matthias Krüger
877f29363d
Rollup merge of #122988 - matthiaskrgr:icetests, r=petrochenkov
add even more tests!

Fixes https://github.com/rust-lang/rust/issues/109869
Fixes https://github.com/rust-lang/rust/issues/110453
Fixes https://github.com/rust-lang/rust/issues/109020
Fixes https://github.com/rust-lang/rust/issues/108580
Fixes https://github.com/rust-lang/rust/issues/108220
Fixes https://github.com/rust-lang/rust/issues/113045
Fixes https://github.com/rust-lang/rust/issues/113133
Fixes https://github.com/rust-lang/rust/issues/114464
Fixes https://github.com/rust-lang/rust/issues/116599
Fixes https://github.com/rust-lang/rust/issues/119731
2024-03-25 17:05:34 +01:00
Matthias Krüger
6203ebe274 add test for ICE with associated_const_equality #108220
Fixes #108220
2024-03-24 10:28:25 +01:00
Esteban Küber
6b24fdf811 Provide structured suggestion for unconstrained generic constant
```
error: unconstrained generic constant
  --> $DIR/const-argument-if-length.rs:18:10
   |
LL |     pad: [u8; is_zst::<T>()],
   |          ^^^^^^^^^^^^^^^^^^^
   |
help: try adding a `where` bound
   |
LL | pub struct AtLeastByte<T: ?Sized> where [(); is_zst::<T>()]: {
   |                                   ++++++++++++++++++++++++++
```

Detect when the constant expression isn't `usize` and suggest casting:

```
error: unconstrained generic constant
 --> f300.rs:6:10
  |
6 |     bb::<{!N}>();
  |          ^^^^
-Ztrack-diagnostics: created at compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs:3539:36
  |
help: try adding a `where` bound
  |
5 | fn b<const N: bool>() where [(); {!N} as usize]: {
  |                       ++++++++++++++++++++++++++
```

Fix #122395.
2024-03-21 00:03:59 +00:00
Oli Scherer
3ec5042cf9 Avoid computing generic params or a param env for free const items 2024-03-19 17:30:08 +00:00
Esteban Küber
6c31f6ce12 Provide structured suggestion for #![feature(foo)]
```
error: `S2<'_>` is forbidden as the type of a const generic parameter
  --> $DIR/lifetime-in-const-param.rs:5:23
   |
LL | struct S<'a, const N: S2>(&'a ());
   |                       ^^
   |
   = note: the only supported types are integers, `bool` and `char`
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
   |
LL + #![feature(adt_const_params)]
   |
```

Fix #55941.
2024-03-18 16:08:58 +00:00
Jubilee
a4503390ba
Rollup merge of #119385 - fmease:assoc-const-eq-fixes-2, r=oli-obk,cjgillot
Fix type resolution of associated const equality bounds (take 2)

Instead of trying to re-resolve the type of assoc const bindings inside the `type_of` query impl in an incomplete manner, transfer the already (correctly) resolved type from `add_predicates_for_ast_type_binding` to `type_of`/`anon_type_of` through query feeding.

---

Together with #118668 (merged) and #121258, this supersedes #118360.
Fixes #118040.

r? ``@ghost``
2024-03-11 09:29:33 -07:00
Oli Scherer
9062697917 Always evaluate free constants and statics, even if previous errors occurred 2024-02-19 22:11:13 +00:00
León Orell Valerian Liehr
8bb49e22b5
Propagate the resolved type of assoc const bindings via query feeding 2024-02-18 10:29:22 +01:00
许杰友 Jieyou Xu (Joe)
ec2cc761bc
[AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
Oli Scherer
28f250d6a6 Remove a has_errors check that does not prevent follow up error noise 2024-01-31 16:51:42 +00:00
George-lewis
d56cdd48cb Bless tests
Update tests
2024-01-13 12:46:58 -05:00
Oli Scherer
0978f6e010 Avoid silencing relevant follow-up errors 2024-01-09 21:08:16 +00:00
León Orell Valerian Liehr
3eb48a35c8
Introduce const Trait (always-const trait bounds) 2023-12-27 12:51:32 +01:00
Deadbeef
e4f237d39e bless ui tests 2023-12-19 04:28:21 +00:00
Nilstrieb
41e8d152dc Show number in error message even for one error
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24 19:15:52 +01:00
León Orell Valerian Liehr
8ce5d784a6
Deny more ~const trait bounds 2023-11-12 00:00:12 +01:00
Esteban Küber
91b9ffeab0 Reorder fullfillment errors to keep more interesting ones first
In `report_fullfillment_errors` push back `T: Sized`, `T: WellFormed`
and coercion errors to the end of the list. The pre-existing
deduplication logic eliminates redundant errors better that way, keeping
the resulting output with fewer errors than before, while also having
more detail.
2023-10-04 02:04:14 +00:00
Michael Goulet
07851679cd Point out the actual mismatch error 2023-10-02 23:14:29 +00:00
asquared31415
b53a1b3808 make adt_const_params feature suggestion more consistent with others and only suggest it when the type can probably work 2023-09-28 23:10:04 +00:00
Michael Goulet
055452864e Walk through full path in point_at_path_if_possible 2023-08-25 19:05:38 +00:00
León Orell Valerian Liehr
1a18158891
Don't crash when reporting nice region errors for generic const items 2023-08-12 15:34:28 +02:00
Deadbeef
4fec845c3f Remove constness from TraitPredicate 2023-08-02 15:38:00 +00:00
León Orell Valerian Liehr
6636916b66
Add UI tests for generic const items 2023-07-28 22:23:20 +02:00