Commit Graph

40 Commits

Author SHA1 Message Date
Shoyu Vanilla d5bbeb978e Revert "Auto merge of #151380 - ShoyuVanilla:shallow-resolve-to-root-var, r=lcnr"
This reverts commit 75b9d89c68, reversing
changes made to 7bee525095.
2026-03-24 22:31:37 +09:00
Esteban Küber 87d8f5885b Provide more context on type errors in const context
- On `const` and `static` point at the type (like we do for let bindings)
- On fn calls, point at const parameter in fn definition
- On type, point at const parameter in type definition
- On array type lengths, explain that array length is always `usize`
- On enum variant discriminant, mention `repr`
2026-03-14 20:13:43 +00:00
lapla 0bb020ace9 Make const_lit_matches_ty check literal suffixes for exact type match 2026-03-01 12:47:52 +09:00
bors 75b9d89c68 Auto merge of #151380 - ShoyuVanilla:shallow-resolve-to-root-var, r=lcnr
Shallow resolve ty and const vars to their root vars

Continuation of https://github.com/rust-lang/rust/pull/147193
2026-02-15 03:04:28 +00:00
reddevilmidzy b4ee9953d8 modify error comment and bless test, delete tests/ui/const-generics/generic_const_exprs/lit_type_mismatch.rs 2026-02-14 04:12:46 +00:00
reddevilmidzy 8af02e230a mGCA: Validate const literal against expected type
Co-authored-by: Boxy <rust@boxyuwu.dev>
2026-02-14 04:12:40 +00:00
Shoyu Vanilla 8062bee9e3 Bless tests 2026-02-11 18:08:18 +09:00
andjsrk d848437814 add more information in comment 2026-01-07 12:09:07 +09:00
andjsrk c73b64b8c5 update expected output as well 2026-01-07 02:02:26 +09:00
andjsrk f805d1b210 format 2026-01-07 01:08:19 +09:00
andjsrk 61ca012d4b rename test 2026-01-07 00:55:58 +09:00
andjsrk 021a551d5d add test for repeats 2026-01-07 00:51:54 +09:00
xiaolinny d1d1181789 chore: fix some minor issues in the comments
Signed-off-by: xiaolinny <xiaolincode@outlook.com>
2025-12-09 17:07:18 +08:00
James Barford-Evans 43f7eaa0ba Fix; correct placement of type inference error for method calls 2025-10-07 09:51:16 +01:00
lcnr 6b379b560d use try_structurally_resolve_type for method receiver
We'll still error due to the `opt_bad_ty` of `method_autoderef_steps`.
This slightly worsens the span of `infer_var.method()` which is now the
same as for `Box::new(infer_var).method()`.

Unlike `structurally_resolve_type`, `probe_op` does not check whether
the infcx is already tainted, so this results in 2 previously not emitted
errors.
2025-09-26 16:33:15 +02:00
Esteban Küber 0674eca2f0 Make Diag::multipart_suggestions always verbose 2025-07-10 17:23:29 +00:00
Boxy fe04ae7faf stabilize gai 2025-06-11 15:30:15 +01:00
Esteban Küber ac980cace8 Make obligation cause code suggestions verbose
```
error[E0277]: `()` is not a future
  --> $DIR/unnecessary-await.rs:28:10
   |
LL |     e!().await;
   |          ^^^^^ `()` is not a future
   |
   = help: the trait `Future` is not implemented for `()`
   = note: () must be a future or must implement `IntoFuture` to be awaited
   = note: required for `()` to implement `IntoFuture`
help: remove the `.await`
   |
LL -     e!().await;
LL +     e!();
   |
```
```
error[E0277]: the trait bound `String: Copy` is not satisfied
  --> $DIR/const-fn-in-vec.rs:1:47
   |
LL | static _MAYBE_STRINGS: [Option<String>; 5] = [None; 5];
   |                                               ^^^^ the trait `Copy` is not implemented for `String`
   |
   = note: required for `Option<String>` to implement `Copy`
   = note: the `Copy` trait is required because this value will be copied for each element of the array
help: create an inline `const` block
   |
LL | static _MAYBE_STRINGS: [Option<String>; 5] = [const { None }; 5];
   |                                               +++++++      +
```
2025-06-06 20:12:11 +00:00
Boxy c27aff35ca Add test 2025-05-26 16:35:36 +01:00
Boxy cc10370fc8 Reviews 2025-05-22 11:39:49 +01:00
Boxy 508a9f0853 Check for element being const before resolving repeat count 2025-05-21 20:38:49 +01:00
Boxy 77a2fc60a1 GAI logic on stable too 2025-05-21 20:38:49 +01:00
Boxy 52f2c45dee Properly test whether repeat expr checks are pre/post integer fallback 2025-05-21 20:38:49 +01:00
Boxy f60bab475e Don't allow repeat expr count inference side effects to propagate 2025-05-21 20:38:49 +01:00
Vadim Petrochenkov 20faf8532b compiletest: Make diagnostic kind mandatory on line annotations 2025-04-30 10:44:24 +03:00
Boxy 6c3243f008 Bless 2025-02-27 20:02:25 +00:00
Boxy cdd8895d72 Add inference constraining Copy impl test 2025-02-27 20:02:25 +00:00
Esteban Küber f0845adb0c Show diff suggestion format on verbose replacement
```
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
  --> $DIR/attempted-access-non-fatal.rs:7:15
   |
LL |     let _ = 2.l;
   |               ^
   |
help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix
   |
LL -     let _ = 2.l;
LL +     let _ = 2.0f64;
   |
```
2025-02-10 20:21:39 +00:00
Oli Scherer 07fcead073 Always take the Ok path in lit_to_const and produce error constants instead 2025-01-09 08:48:00 +00:00
Veera 98cc3457af Suggest Semicolon in Incorrect Repeat Expressions 2024-12-21 02:30:50 +00:00
Veera 872aa75867 Add Tests 2024-12-21 00:19:18 +00:00
Esteban Küber cbe75486f7 Account for let foo = expr; to suggest const foo: Ty = expr; 2024-07-11 20:39:24 +00:00
Esteban Küber b56dc8ee90 Use verbose style when suggesting changing const with let 2024-07-11 20:39:24 +00:00
许杰友 Jieyou Xu (Joe) ec2cc761bc [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
est31 9676e18868 Remove extra # from url 2024-01-24 00:41:45 +01:00
yukang 3ed96e35c4 Suggest arry::from_fn for array initialization 2024-01-21 09:57:26 +08: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
Esteban Küber 5b40aa5eb4 Tweak output for 'add line' suggestion 2023-04-12 22:50:10 +00:00
Esteban Küber 62ba3e70a1 Modify primary span label for E0308
The previous output was unintuitive to users.
2023-01-30 20:12:19 +00:00
Albert Larsan cf2dff2b1e Move /src/test to /tests 2023-01-11 09:32:08 +00:00