dc7559b599
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.~~ |
||
---|---|---|
.. | ||
auxiliary | ||
need_type_info | ||
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 | ||
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 | ||
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 | ||
issue-83606.stderr | ||
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 | ||
issue-107090.stderr | ||
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 | ||
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 |