fix: Prevent infinite recursion of bounds formatting

This commit is contained in:
Shoyu Vanilla 2025-01-25 00:54:14 +09:00
parent 649e65ce1e
commit 3fe7415c83
3 changed files with 128 additions and 71 deletions

View file

@ -10349,40 +10349,3 @@ macro_rules! str {
"#]],
);
}
#[test]
fn regression_19007() {
check(
r#"
trait Foo {
type Assoc;
fn foo(&self) -> Self::Assoc;
}
trait Bar {
type Target;
}
trait Baz<T> {}
struct Struct<T: Foo> {
field: T,
}
impl<T> Struct<T>
where
T: Foo,
T::Assoc: Baz<<T::Assoc as Bar>::Target> + Bar,
{
fn f(&self) {
let x$0 = self.field.foo();
}
}
"#,
expect![
r#"
"#
],
);
}

View file

@ -1203,6 +1203,40 @@ fn f5<G: T<Assoc = ()>>(it: G) {
let l = it.f();
//^ ()
}
"#,
);
}
#[test]
fn regression_19007() {
check_types(
r#"
trait Foo {
type Assoc;
fn foo(&self) -> Self::Assoc;
}
trait Bar {
type Target;
}
trait Baz<T> {}
struct Struct<T: Foo> {
field: T,
}
impl<T> Struct<T>
where
T: Foo,
T::Assoc: Baz<<T::Assoc as Bar>::Target> + Bar,
{
fn f(&self) {
let x = self.field.foo();
//^ impl Baz<<<T as Foo>::Assoc as Bar>::Target> + Bar
}
}
"#,
);
}