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
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
ambiguous_type_parameter.stderr
cannot-infer-async.rs
cannot-infer-async.stderr
cannot-infer-closure-circular.rs
cannot-infer-closure-circular.stderr
cannot-infer-closure.rs
cannot-infer-closure.stderr
cannot-infer-partial-try-return.rs
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
char-as-str-multi.stderr
char-as-str-single.fixed
char-as-str-single.rs
char-as-str-single.stderr
deref-suggestion.rs
deref-suggestion.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
erase-type-params-in-label.rs
erase-type-params-in-label.stderr
infer-binary-operand-behind-reference.rs
inference_unstable_featured.rs
inference_unstable_featured.stderr
inference_unstable_forced.rs
inference_unstable_forced.stderr
inference_unstable.rs
inference_unstable.stderr
inference-variable-behind-raw-pointer.rs
inference-variable-behind-raw-pointer.stderr
issue-28935.rs
issue-36053.rs
issue-70703.rs
issue-71309.rs
issue-71309.stderr
issue-71732.rs
issue-71732.stderr
issue-72616.rs
issue-72616.stderr
issue-72690.rs
issue-72690.stderr
issue-80816.rs
issue-80816.stderr
issue-81522.rs
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
issue-86162-1.stderr
issue-86162-2.rs
issue-86162-2.stderr
issue-103587.rs
issue-103587.stderr
issue-104649.rs
issue-104649.stderr
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
newlambdas-ret-infer2.rs
newlambdas-ret-infer.rs
question-mark-type-infer.rs
question-mark-type-infer.stderr Deprioritize fulfillment errors that come from expansions. 2023-01-14 14:05:26 +01:00
range-type-infer.rs
simple-infer.rs
str-as-char.fixed
str-as-char.rs
str-as-char.stderr
tutorial-suffix-inference-test.rs
tutorial-suffix-inference-test.stderr
type-infer-generalize-ty-var.rs