rust/compiler
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
..
rustc Add a new rustc_driver dylib to rexport rustc_driver_impl 2023-02-02 07:34:41 +01:00
rustc_abi also do not add noalias on not-Unpin Box 2023-02-06 12:17:41 +01:00
rustc_apfloat
rustc_arena
rustc_ast Rollup merge of #107544 - nnethercote:improve-TokenCursor, r=petrochenkov 2023-02-03 23:04:51 +05:30
rustc_ast_lowering remove unused imports 2023-02-06 17:40:18 +03:00
rustc_ast_passes
rustc_ast_pretty Expand const-if-const trait bounds correctly 2023-02-07 21:00:12 +00:00
rustc_attr
rustc_baked_icu_data
rustc_borrowck Auto merge of #107652 - estebank:re_error, r=oli-obk 2023-02-10 10:10:12 +00:00
rustc_builtin_macros Extend BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE. 2023-02-09 11:47:12 +11:00
rustc_codegen_cranelift Merge commit '7d53619064ab7045c383644cb445052d2a3d46db' into sync_cg_clif-2023-02-09 2023-02-09 12:38:16 +01:00
rustc_codegen_gcc session: diagnostic migration lint on more fns 2023-01-30 17:11:35 +00:00
rustc_codegen_llvm Auto merge of #102963 - ilammy:xray-basic, r=estebank 2023-02-10 00:02:43 +00:00
rustc_codegen_ssa remove unused imports 2023-02-06 17:40:18 +03:00
rustc_const_eval Avoid some tls::with calls. 2023-02-09 15:28:04 +11:00
rustc_data_structures Make an optimal cold path for query_cache_hit 2023-02-06 15:22:12 +01:00
rustc_driver Remove unneeded extern crate 2023-02-02 07:47:39 +01:00
rustc_driver_impl Rollup merge of #107761 - oli-obk:miri_🪵, r=TaKO8Ki 2023-02-08 20:01:25 -08:00
rustc_error_codes Add extended error message for E0523 2023-02-06 06:58:30 -05:00
rustc_error_messages Auto merge of #102963 - ilammy:xray-basic, r=estebank 2023-02-10 00:02:43 +00:00
rustc_errors test: snapshot for derive suggestion in diff files 2023-02-09 22:28:53 +08:00
rustc_expand Add ~const bounds trait bounds when using derive_const 2023-02-07 21:00:12 +00:00
rustc_feature Auto merge of #107297 - Mark-Simulacrum:bump-bootstrap, r=pietroalbini 2023-01-31 19:24:29 +00:00
rustc_fs_util
rustc_graphviz
rustc_hir Rename PointerSized to PointerLike 2023-02-07 19:05:53 +00:00
rustc_hir_analysis Use ErrorGuaranteed more in ReError 2023-02-09 10:38:45 +00:00
rustc_hir_pretty Use Mutability::{is_mut, is_not} 2023-01-30 12:26:26 +00:00
rustc_hir_typeck Rollup merge of #107803 - eggyal:do_not_bring_trait_alias_supertraits_into_scope, r=compiler-errors 2023-02-09 23:18:36 +05:30
rustc_incremental incremental: migrate diagnostics 2023-01-30 17:11:35 +00:00
rustc_index
rustc_infer Rollup merge of #107789 - jieyouxu:issue-107745, r=lcnr 2023-02-10 15:28:47 +01:00
rustc_interface Rollup merge of #107831 - nnethercote:query-refactoring, r=oli-obk 2023-02-10 06:09:57 +01:00
rustc_lexer
rustc_lint Auto merge of #103761 - chenyukang:yukang/fix-103320-must-use, r=compiler-errors 2023-02-06 12:57:37 +00:00
rustc_lint_defs Extend BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE. 2023-02-09 11:47:12 +11:00
rustc_llvm llvm-16: Use Triple.h from new header location. 2023-02-07 06:51:58 -08:00
rustc_log Replace a command line flag with an env var to allow tools to initialize the tracing loggers at their own discretion 2023-02-07 16:33:03 +00:00
rustc_macros Forbid #[suggestion_*(...)] on Vecs 2023-02-01 21:49:45 +01:00
rustc_metadata Rollup merge of #100599 - MatthewPeterKelly:add-E0523-description-and-test, r=compiler-errors,GuillaumeGomez 2023-02-07 17:57:13 +01:00
rustc_middle Auto merge of #107652 - estebank:re_error, r=oli-obk 2023-02-10 10:10:12 +00:00
rustc_mir_build remove unused imports 2023-02-06 17:40:18 +03:00
rustc_mir_dataflow Rollup merge of #107271 - Zeegomo:drop-rmw, r=oli-obk 2023-02-08 18:32:41 +01:00
rustc_mir_transform Rollup merge of #107271 - Zeegomo:drop-rmw, r=oli-obk 2023-02-08 18:32:41 +01:00
rustc_monomorphize Auto merge of #100754 - davidtwco:translation-incremental, r=compiler-errors 2023-01-31 10:20:58 +00:00
rustc_parse Rollup merge of #107446 - clubby789:rustc-parse-diag-migrate, r=compiler-errors 2023-02-09 11:21:57 +01:00
rustc_parse_format Rollup merge of #106805 - madsravn:master, r=compiler-errors 2023-02-03 06:30:23 +01:00
rustc_passes rustc_passes: remove huge error imports 2023-02-05 03:47:58 +01:00
rustc_plugin_impl
rustc_privacy remove unused imports 2023-02-06 17:40:18 +03:00
rustc_query_impl Simplify tls::enter_context. 2023-02-09 15:25:45 +11:00
rustc_query_system Auto merge of #107644 - Zoxc:query-cache-tweak, r=cjgillot 2023-02-08 16:59:18 +00:00
rustc_resolve Auto merge of #107652 - estebank:re_error, r=oli-obk 2023-02-10 10:10:12 +00:00
rustc_save_analysis Review changes 2023-01-31 07:54:01 +00:00
rustc_serialize
rustc_session Rollup merge of #107043 - Nilstrieb:true-and-false-is-false, r=wesleywiser 2023-02-10 06:09:56 +01:00
rustc_smir
rustc_span Rollup merge of #107769 - compiler-errors:pointer-like, r=eholk 2023-02-08 07:13:26 +01:00
rustc_symbol_mangling Change to ReError(ErrorGuaranteed) 2023-02-09 10:26:49 +00:00
rustc_target XRay support flag in TargetOptions 2023-02-09 12:28:01 +09:00
rustc_trait_selection Rollup merge of #107863 - compiler-errors:new-solver-multiple-candidates, r=jackh726 2023-02-10 06:09:59 +01:00
rustc_traits Auto merge of #107652 - estebank:re_error, r=oli-obk 2023-02-10 10:10:12 +00:00
rustc_transmute
rustc_ty_utils Auto merge of #106180 - RalfJung:dereferenceable-generators, r=nbdd0121 2023-02-07 03:35:10 +00:00
rustc_type_ir Fix RegionKind: PartialEq to account for ReError 2023-02-09 10:26:50 +00:00