rust/compiler
Matthias Krüger fd92d88c28
Rollup merge of #119389 - estebank:issue-116925, r=TaKO8Ki
Provide more context on recursive `impl` evaluation overflow

When an associated type `Self::Assoc` is part of a `where` clause, we end up unable to evaluate the requirement and emit a E0275.

We now point at the associated type if specified in the `impl`. If so, we also suggest using that type instead of `Self::Assoc`. Otherwise, we explain that these are not allowed.

```
error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
  --> $DIR/impl-wf-cycle-1.rs:15:1
   |
LL | / impl<T: Grault> Grault for (T,)
LL | |
LL | | where
LL | |     Self::A: Baz,
LL | |     Self::B: Fiz,
   | |_________________^
LL |   {
LL |       type A = ();
   |       ------ associated type `<(T,) as Grault>::A` is specified here
   |
note: required for `(T,)` to implement `Grault`
  --> $DIR/impl-wf-cycle-1.rs:15:17
   |
LL | impl<T: Grault> Grault for (T,)
   |                 ^^^^^^     ^^^^
...
LL |     Self::A: Baz,
   |              --- unsatisfied trait bound introduced here
   = note: 1 redundant requirement hidden
   = note: required for `(T,)` to implement `Grault`
help: associated type for the current `impl` cannot be restricted in `where` clauses, remove this bound
   |
LL -     Self::A: Baz,
   |
```
```
error[E0275]: overflow evaluating the requirement `<T as B>::Type == <T as B>::Type`
  --> $DIR/impl-wf-cycle-3.rs:7:1
   |
LL | / impl<T> B for T
LL | | where
LL | |     T: A<Self::Type>,
   | |_____________________^
LL |   {
LL |       type Type = bool;
   |       --------- associated type `<T as B>::Type` is specified here
   |
note: required for `T` to implement `B`
  --> $DIR/impl-wf-cycle-3.rs:7:9
   |
LL | impl<T> B for T
   |         ^     ^
LL | where
LL |     T: A<Self::Type>,
   |        ------------- unsatisfied trait bound introduced here
help: replace the associated type with the type specified in this `impl`
   |
LL |     T: A<bool>,
   |          ~~~~
```
```
error[E0275]: overflow evaluating the requirement `<T as Filter>::ToMatch == <T as Filter>::ToMatch`
  --> $DIR/impl-wf-cycle-4.rs:5:1
   |
LL | / impl<T> Filter for T
LL | | where
LL | |     T: Fn(Self::ToMatch),
   | |_________________________^
   |
note: required for `T` to implement `Filter`
  --> $DIR/impl-wf-cycle-4.rs:5:9
   |
LL | impl<T> Filter for T
   |         ^^^^^^     ^
LL | where
LL |     T: Fn(Self::ToMatch),
   |        ----------------- unsatisfied trait bound introduced here
note: associated types for the current `impl` cannot be restricted in `where` clauses
  --> $DIR/impl-wf-cycle-4.rs:7:11
   |
LL |     T: Fn(Self::ToMatch),
   |           ^^^^^^^^^^^^^
```

Fix #116925
2024-01-25 08:39:41 +01:00
..
rustc Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_abi Fix rustc_abi build on stable 2024-01-16 21:15:31 +01:00
rustc_arena Fix Stable trait and its impls to work with the new with_tables 2024-01-19 09:42:51 +00:00
rustc_ast Pack the u128 in LitKind::Int 2024-01-19 20:10:39 -08:00
rustc_ast_lowering Pack the u128 in LitKind::Int 2024-01-19 20:10:39 -08:00
rustc_ast_passes add help message for exclusive_range_pattern error 2024-01-19 13:38:24 -05:00
rustc_ast_pretty Add PatKind::Err 2024-01-17 03:14:16 +01:00
rustc_attr Pack the u128 in LitKind::Int 2024-01-19 20:10:39 -08:00
rustc_baked_icu_data Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_borrowck Auto merge of #116152 - cjgillot:unchunck, r=nnethercote 2024-01-23 11:56:30 +00:00
rustc_builtin_macros Rollup merge of #120183 - Zalathar:test-closure, r=compiler-errors 2024-01-23 21:53:58 +01:00
rustc_codegen_cranelift Auto merge of #119911 - NCGThompson:is-statically-known, r=oli-obk 2024-01-25 05:16:53 +00:00
rustc_codegen_gcc Auto merge of #119911 - NCGThompson:is-statically-known, r=oli-obk 2024-01-25 05:16:53 +00:00
rustc_codegen_llvm Auto merge of #119911 - NCGThompson:is-statically-known, r=oli-obk 2024-01-25 05:16:53 +00:00
rustc_codegen_ssa Rollup merge of #120139 - compiler-errors:fnonce-shim, r=BoxyUwU 2024-01-23 21:53:56 +01:00
rustc_const_eval Auto merge of #119911 - NCGThompson:is-statically-known, r=oli-obk 2024-01-25 05:16:53 +00:00
rustc_data_structures Auto merge of #120080 - cuviper:128-align-packed, r=nikic 2024-01-22 13:08:19 +00:00
rustc_driver Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_driver_impl Replace TrimmedDefPaths with a bool. 2024-01-15 09:16:14 +11:00
rustc_error_codes Stabilize simple offset_of 2024-01-19 20:38:51 +00:00
rustc_error_messages Remove rustc_error_messages/messages.ftl. 2023-11-26 08:37:27 +11:00
rustc_errors add list of characters to uncommon codepoints lint 2024-01-23 10:56:33 +08:00
rustc_expand Pack the u128 in LitKind::Int 2024-01-19 20:10:39 -08:00
rustc_feature Revert "Auto merge of #118133 - Urgau:stabilize_trait_upcasting, r=WaffleLapkin" 2024-01-22 14:24:31 +00:00
rustc_fluent_macro annotate-snippets: update to 0.10 2024-01-07 16:53:32 +03:00
rustc_fs_util Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_graphviz remove unused pub fn 2023-11-23 14:11:02 +03:00
rustc_hir Rollup merge of #119305 - compiler-errors:async-fn-traits, r=oli-obk 2024-01-25 08:39:41 +01:00
rustc_hir_analysis Auto merge of #119911 - NCGThompson:is-statically-known, r=oli-obk 2024-01-25 05:16:53 +00:00
rustc_hir_pretty Add PatKind::Err 2024-01-17 03:14:16 +01:00
rustc_hir_typeck Rollup merge of #119305 - compiler-errors:async-fn-traits, r=oli-obk 2024-01-25 08:39:41 +01:00
rustc_incremental Tweak error counting. 2024-01-22 10:14:01 +11:00
rustc_index Remove uses of HybridBitSet. 2024-01-22 22:53:20 +00:00
rustc_index_macros Restrict access to the private field of newtype indexes 2024-01-19 15:38:47 +00:00
rustc_infer Rollup merge of #120261 - estebank:issue-102629, r=wesleywiser 2024-01-23 21:53:59 +01:00
rustc_interface Rollup merge of #120159 - jyn514:track-verbose, r=wesleywiser 2024-01-22 22:12:09 +01:00
rustc_lexer Rollup merge of #118639 - fmease:deny-features-in-stable-rustc-crates, r=WaffleLapkin 2024-01-22 16:54:56 +01:00
rustc_lint tidy 2024-01-23 21:17:06 +08:00
rustc_lint_defs Rollup merge of #119948 - asquared31415:unsafe_op_in_unsafe_fn_fix, r=TaKO8Ki 2024-01-22 16:13:28 +01:00
rustc_llvm Revert "Auto merge of #113923 - DianQK:restore-no-builtins-lto, r=pnkfelix" 2024-01-12 18:23:04 +08: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 Rename LintContext::struct_span_lint as LintContext::span_lint. 2024-01-23 07:59:45 +11:00
rustc_metadata Rollup merge of #119815 - nagisa:nagisa/polishes-libloading-use-somewhat, r=bjorn3 2024-01-19 19:27:00 +01:00
rustc_middle Auto merge of #119627 - oli-obk:const_prop_lint_n̵o̵n̵sense, r=cjgillot 2024-01-25 03:16:07 +00:00
rustc_mir_build Rollup merge of #120171 - cjgillot:jump-threading-assume-assert, r=tmiasko 2024-01-23 21:53:57 +01:00
rustc_mir_dataflow Use a plain bitset for liveness analyses. 2024-01-22 23:18:45 +00:00
rustc_mir_transform Auto merge of #119627 - oli-obk:const_prop_lint_n̵o̵n̵sense, r=cjgillot 2024-01-25 03:16:07 +00:00
rustc_monomorphize Rollup merge of #120139 - compiler-errors:fnonce-shim, r=BoxyUwU 2024-01-23 21:53:56 +01:00
rustc_next_trait_solver Remove movability from TyKind::Coroutine 2023-12-28 16:35:01 +00:00
rustc_parse Rollup merge of #120063 - clubby789:remove-box-handling, r=Nilstrieb 2024-01-20 20:06:34 +01:00
rustc_parse_format Rollup merge of #118639 - fmease:deny-features-in-stable-rustc-crates, r=WaffleLapkin 2024-01-22 16:54:56 +01:00
rustc_passes Rename TyCtxt::emit_spanned_lint as TyCtxt::emit_node_span_lint. 2024-01-23 08:09:05 +11:00
rustc_pattern_analysis Rename TyCtxt::emit_spanned_lint as TyCtxt::emit_node_span_lint. 2024-01-23 08:09:05 +11:00
rustc_privacy privacy: Refactor top-level visiting in TypePrivacyVisitor 2024-01-24 00:42:01 +03:00
rustc_query_impl Update measureme crate to version 11 2024-01-13 16:32:03 +01:00
rustc_query_system Tweak error counting. 2024-01-22 10:14:01 +11:00
rustc_resolve Rollup merge of #119369 - bvanjoi:fix-119301, r=petrochenkov 2024-01-22 16:13:25 +01:00
rustc_serialize Rollup merge of #117561 - tgross35:split-array, r=scottmcm 2024-01-19 19:26:59 +01:00
rustc_session Auto merge of #120017 - nnethercote:lint-api, r=oli-obk 2024-01-23 00:06:57 +00:00
rustc_smir Do not normalize closure signature when building FnOnce shim 2024-01-22 16:50:30 +00:00
rustc_span Rollup merge of #119305 - compiler-errors:async-fn-traits, r=oli-obk 2024-01-25 08:39:41 +01:00
rustc_symbol_mangling Rename consuming chaining methods on DiagnosticBuilder. 2024-01-10 07:40:00 +11:00
rustc_target Rollup merge of #119616 - rylev:wasm32-wasi-preview2, r=petrochenkov,m-ou-se 2024-01-24 15:43:12 +01:00
rustc_trait_selection Rollup merge of #119389 - estebank:issue-116925, r=TaKO8Ki 2024-01-25 08:39:41 +01:00
rustc_traits Correctly handle normalization in implied bounds 2024-01-17 21:27:34 -05:00
rustc_transmute Fix an ICE that occurs after an error has already been reported 2024-01-09 16:09:30 +00:00
rustc_ty_utils Rollup merge of #120139 - compiler-errors:fnonce-shim, r=BoxyUwU 2024-01-23 21:53:56 +01:00
rustc_type_ir Restrict access to the private field of newtype indexes 2024-01-19 15:38:47 +00:00
stable_mir Make the remaining "private" fields actually private 2024-01-19 16:37:50 +00:00