Commit Graph

22 Commits

Author SHA1 Message Date
Matthias Krüger
985ea22489
Rollup merge of #111021 - c410-f3r:dqewdas, r=petrochenkov
Move some tests

r? ``@petrochenkov``
2023-05-09 20:49:31 +02:00
Caio
0285611096 Move tests 2023-05-08 17:58:01 -03:00
Michael Goulet
a9051d861c Tweak borrow suggestion 2023-05-08 03:36:30 +00:00
Matthias Krüger
bcd55cebfa
Rollup merge of #110825 - notriddle:notriddle/issue-70082, r=compiler-errors
diagnostics: add test case for already-solved issue

Fixes #70082
2023-04-26 18:51:44 +02:00
Michael Howell
1bfbac7903 diagnostics: add test case for already-solved issue
Fixes #70082
2023-04-25 13:07:09 -07:00
Michael Goulet
b0a7d6e4b7 Suggest deref on comparison binop RHS even if type is not Copy 2023-04-19 16:47:11 +00:00
ickk
30f458ed1e update tests/ui 2023-04-07 18:07:11 +10:00
Matthias Krüger
e63586f386
Rollup merge of #109957 - fmease:fix-109905, r=petrochenkov
diagnostics: account for self type when looking for source of unsolved type variable

Fixes #109905.

When searching for the source of an unsolved infer var inside of a list of generic args, we look through the `tcx.generics_of(…).own_substs(…)` which *skips* the self type if present. However, the computed `argument_index` is later[^1] used to index into `tcx.generics_of(…).params` which may still contain the self type. In such case, we are off by one when indexing into the parameters.

From now on, we account for this immediately after calling `own_substs` which keeps things local.

This also fixes the wrong output in the preexisting UI test `inference/need_type_info/concrete-impl.rs` which was overlooked. It used to claim that the *type of type parameter `Self`* couldn't be inferred in `<Struct as Ambiguous<_>>::method()` which of course isn't true: `Self` equals `Struct` here, `A` couldn't be inferred.

`@rustbot` label A-diagnostics

[^1]: f98a271814/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs (L471)
2023-04-07 00:00:24 +02:00
León Orell Valerian Liehr
b904ce94a2
account for self type when looking for source of unsolved ty var 2023-04-05 20:28:18 +02:00
Yuki Okushi
2df3f490dd
Add regression test for #80409
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2023-04-05 21:20:07 +09:00
Lukas Markeffsky
08f3deb3d5 fix type suggestions in match arms 2023-03-25 22:27:24 +01:00
Michael Howell
3f374128ee diagnostics: update test cases to refer to assoc fn with self as method 2023-02-22 08:40:47 -07:00
clubby789
903ca873f7 Suggest the correct array length on mismatch 2023-02-12 02:15:41 +00:00
Matthias Krüger
dc7559b599
Rollup merge of #107789 - jieyouxu:issue-107745, r=lcnr
Avoid exposing type parameters and implementation details sourced from macro expansions

Fixes #107745.

~~I would like to **request some guidance** for this issue, because I don't think this is a good fix (a band-aid at best).~~

### The Problem

The code

```rust
fn main() {
    println!("{:?}", []);
}
```

gets desugared into (`rustc +nightly --edition=2018 issue-107745.rs -Z unpretty=hir`):

```rust
#[prelude_import]
use std::prelude::rust_2018::*;
#[macro_use]
extern crate std;
fn main() {
        {
                ::std::io::_print(<#[lang = "format_arguments"]>::new_v1(&["",
                                    "\n"], &[<#[lang = "format_argument"]>::new_debug(&[])]));
            };
    }
```

so the diagnostics code tries to be as specific and helpful as possible, and I think it finds that `[]` needs a type parameter and so does `new_debug`. But since `[]` doesn't have an origin for the type parameter definition, it points to `new_debug` instead and leaks the internal implementation detail since all `[]` has is an type inference variable.

### ~~The Bad Fix~~

~~This PR currently tries to fix the problem by bypassing the generated function `<#[lang = "format_argument"]>::new_debug` to avoid its generic parameter (I think it is auto-generated from the argument `[_; 0]`?) from getting collected as an `InsertableGenericArg`. This is problematic because it also prevents the help from getting displayed.~~

~~I think this fix is not ideal and hard-codes the format generated code pattern, but I can't think of a better fix. I have tried asking on Zulip but no responses there yet.~~
2023-02-10 15:28:47 +01:00
Esteban Küber
30cf7a3f51 Introduce ReError
CC #69314
2023-02-09 10:26:49 +00:00
许杰友 Jieyou Xu (Joe)
b58347a9c6
Don't expose type parameters and implementation details from macro expansion 2023-02-09 15:15:15 +08: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
yukang
81efdab3f8 add tests for 107090 2023-01-18 22:53:27 +08:00
Boxy
4ca5368a12 defer array len printing to const arg printing 2023-01-18 04:07:39 +00:00
Mara Bos
6821adb651 Deprioritize fulfillment errors that come from expansions. 2023-01-14 14:05:26 +01:00
Michael Goulet
9a39d7e441 Note predicate span on ImplDerivedObligation 2023-01-11 19:46:45 +00:00
Albert Larsan
cf2dff2b1e
Move /src/test to /tests 2023-01-11 09:32:08 +00:00