Skip to content

Where bounds with associated types equality cause overflow. #89503

@mixal-iirec

Description

@mixal-iirec

Code

I tried this code:

trait Assoc { type B; } struct Test<U, T> where U: Assoc, T: Assoc<B = <U as Assoc>::B>, { a: U, c: T, } impl<U, T> Assoc for Test<U, T> where U: Assoc, T: Assoc<B = <U as Assoc>::B>, { type B = <U as Assoc>::B; } trait TestTrait: Assoc {} impl<U, T> TestTrait for Test<U, T> where U: Assoc, T: Assoc<B = <Self as Assoc>::B>, { }

It used to compile but now it doesn't because:

error[E0275]: overflow evaluating the requirement `<T as Assoc>::B == <U as Assoc>::B` --> src/main.rs:20:1 | 20 | / impl<U: Assoc, T> TestTrait for Test<U, T> 21 | | where 22 | | U: Assoc, 23 | | T: Assoc<B = <Self as Assoc>::B>, 24 | | { 25 | | } | |_^ | note: required because of the requirements on the impl of `Assoc` for `Test<U, T>` --> src/main.rs:12:12 | 12 | impl<U, T> Assoc for Test<U, T> | 

Version it worked on

It most recently worked on:
Stable: 1.55.0
Nightly: rustc 1.56.0-nightly (50171c310 2021-09-01)

Version with regression

rustc --version --verbose:

rustc 1.57.0-nightly (f03eb6bef 2021-10-02) rustc 1.56.0-beta.3 (deef86610 2021-09-17) 

(Probably all nightly versions after 2021-09-01)

@rustbot modify labels: +regression-from-stable-to-beta -regression-untriaged

Metadata

Metadata

Assignees

Labels

A-trait-systemArea: Trait systemP-highHigh priorityS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-typesRelevant to the types team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions