granite-rust/compiler
Matthias Krüger dd49c39e02
Rollup merge of #117959 - estebank:issue-76086, r=compiler-errors
Better handle type errors involving `Self` literals

When encountering a type error involving a `Self` literal, point at the self type of the enclosing `impl` and suggest using the actual type name instead.

```
error[E0308]: mismatched types
  --> $DIR/struct-path-self-type-mismatch.rs:13:9
   |
LL |   impl<T> Foo<T> {
   |        -  ------ this is the type of the `Self` literal
   |        |
   |        found type parameter
LL |       fn new<U>(u: U) -> Foo<U> {
   |              -           ------ expected `Foo<U>` because of return type
   |              |
   |              expected type parameter
LL | /         Self {
LL | |
LL | |             inner: u
LL | |
LL | |         }
   | |_________^ expected `Foo<U>`, found `Foo<T>`
   |
   = note: expected struct `Foo<U>`
              found struct `Foo<T>`
   = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
   = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
help: use the type name directly
   |
LL |         Foo::<U> {
   |         ~~~~~~~~
```
Fix #76086.
2023-11-17 00:41:23 +01:00
..
rustc Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_abi Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_arena Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_ast Rollup merge of #117892 - estebank:fat-arrow-typo, r=compiler-errors 2023-11-17 00:41:22 +01:00
rustc_ast_lowering Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_ast_passes Re-format code with new rustfmt 2023-11-15 21:45:48 -05:00
rustc_ast_pretty Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_attr Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_baked_icu_data Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_borrowck Auto merge of #116097 - jackh726:higher-ranked-lifetime-error-backup, r=compiler-errors 2023-11-16 19:12:35 +00:00
rustc_builtin_macros Re-format code with new rustfmt 2023-11-15 21:45:48 -05:00
rustc_codegen_cranelift Add check-cfg to cranelift 2023-11-15 21:45:48 -05:00
rustc_codegen_gcc Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_codegen_llvm Auto merge of #117875 - Mark-Simulacrum:bootstrap-bump, r=clubby789 2023-11-16 12:45:27 +00:00
rustc_codegen_ssa Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_const_eval Re-format code with new rustfmt 2023-11-15 21:45:48 -05:00
rustc_data_structures Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_driver Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_driver_impl Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_error_codes Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_error_messages Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_errors Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_expand Re-format code with new rustfmt 2023-11-15 21:45:48 -05:00
rustc_feature Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_fluent_macro Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_fs_util Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_graphviz Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_hir Add suggestion to THIR unsafe_op_in_unsafe_fn lint 2023-11-06 16:23:09 +00:00
rustc_hir_analysis Re-format code with new rustfmt 2023-11-15 21:45:48 -05:00
rustc_hir_pretty Fix remaining uses of CaptureBy::Value 2023-11-04 19:48:44 +01:00
rustc_hir_typeck review comment: move error logic to different method 2023-11-16 21:30:26 +00:00
rustc_incremental Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_index Remove unnecessary annotation. 2023-11-13 17:09:26 +11:00
rustc_infer Re-format code with new rustfmt 2023-11-15 21:45:48 -05:00
rustc_interface Re-format code with new rustfmt 2023-11-15 21:45:48 -05:00
rustc_lexer Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_lint Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_lint_defs Auto merge of #116930 - RalfJung:raw-ptr-match, r=davidtwco 2023-11-08 20:42:32 +00:00
rustc_llvm Auto merge of #117875 - Mark-Simulacrum:bootstrap-bump, r=clubby789 2023-11-16 12:45:27 +00:00
rustc_log rustc_log: provide a way to init logging based on the values, not names, of the env vars 2023-11-11 15:24:33 +01:00
rustc_macros Re-format code with new rustfmt 2023-11-15 21:45:48 -05:00
rustc_metadata Re-format code with new rustfmt 2023-11-15 21:45:48 -05:00
rustc_middle Auto merge of #117956 - saethlin:provenance-gc-access, r=RalfJung 2023-11-16 15:15:54 +00:00
rustc_mir_build Re-format code with new rustfmt 2023-11-15 21:45:48 -05:00
rustc_mir_dataflow rename BorrowKind::Shallow to Fake 2023-11-08 22:55:28 +01:00
rustc_mir_transform Re-format code with new rustfmt 2023-11-15 21:45:48 -05:00
rustc_monomorphize Minimize pub usage in source_map.rs. 2023-11-02 19:35:00 +11:00
rustc_parse Rollup merge of #117892 - estebank:fat-arrow-typo, r=compiler-errors 2023-11-17 00:41:22 +01:00
rustc_parse_format Auto merge of #117819 - fmease:rustc_parse_format-stable-rustc, r=Nilstrieb 2023-11-15 14:55:35 +00:00
rustc_passes Re-format code with new rustfmt 2023-11-15 21:45:48 -05:00
rustc_privacy Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_query_impl Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_query_system Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_resolve Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_serialize Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_session Auto merge of #116555 - paulmenage:llvm-module-flag, r=wesleywiser 2023-11-15 16:54:31 +00:00
rustc_smir Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_span Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_symbol_mangling Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_target Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_trait_selection Re-format code with new rustfmt 2023-11-15 21:45:48 -05:00
rustc_traits Remove -Zperf-stats. 2023-11-13 09:45:20 +11:00
rustc_transmute Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_ty_utils Re-format code with new rustfmt 2023-11-15 21:45:48 -05:00
rustc_type_ir fix doc link 2023-11-15 01:24:44 +00:00
stable_mir Auto merge of #117908 - lcnr:region-kind-rename, r=BoxyUwU 2023-11-15 12:55:42 +00:00