rust/tests/ui/inference
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
..
auxiliary Move /src/test to /tests 2023-01-11 09:32:08 +00:00
need_type_info Don't expose type parameters and implementation details from macro expansion 2023-02-09 15:15:15 +08:00
ambiguous_type_parameter.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ambiguous_type_parameter.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
cannot-infer-async.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
cannot-infer-async.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
cannot-infer-closure-circular.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
cannot-infer-closure-circular.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
cannot-infer-closure.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
cannot-infer-closure.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
cannot-infer-partial-try-return.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
cannot-infer-partial-try-return.stderr Deprioritize fulfillment errors that come from expansions. 2023-01-14 14:05:26 +01:00
char-as-str-multi.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
char-as-str-multi.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
char-as-str-single.fixed Move /src/test to /tests 2023-01-11 09:32:08 +00:00
char-as-str-single.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
char-as-str-single.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
deref-suggestion.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
deref-suggestion.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
erase-type-params-in-label.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
erase-type-params-in-label.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
infer-binary-operand-behind-reference.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inference_unstable_featured.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inference_unstable_featured.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inference_unstable_forced.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inference_unstable_forced.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inference_unstable.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inference_unstable.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inference-variable-behind-raw-pointer.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inference-variable-behind-raw-pointer.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-28935.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-36053.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-70703.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-71309.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-71309.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-71732.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-71732.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-72616.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-72616.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-72690.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-72690.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-80816.rs Note predicate span on ImplDerivedObligation 2023-01-11 19:46:45 +00:00
issue-80816.stderr Note predicate span on ImplDerivedObligation 2023-01-11 19:46:45 +00:00
issue-81522.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-83606.rs defer array len printing to const arg printing 2023-01-18 04:07:39 +00:00
issue-83606.stderr defer array len printing to const arg printing 2023-01-18 04:07:39 +00:00
issue-86162-1.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-86162-1.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-86162-2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-86162-2.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-103587.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-103587.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-104649.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-104649.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-107090.rs Introduce ReError 2023-02-09 10:26:49 +00:00
issue-107090.stderr Introduce ReError 2023-02-09 10:26:49 +00:00
lub-glb-with-unbound-infer-var.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
newlambdas-ret-infer2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
newlambdas-ret-infer.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
question-mark-type-infer.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
question-mark-type-infer.stderr Deprioritize fulfillment errors that come from expansions. 2023-01-14 14:05:26 +01:00
range-type-infer.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simple-infer.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
str-as-char.fixed Move /src/test to /tests 2023-01-11 09:32:08 +00:00
str-as-char.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
str-as-char.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
tutorial-suffix-inference-test.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
tutorial-suffix-inference-test.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
type-infer-generalize-ty-var.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00