Add regression tests for some fixed A-ty issues

This commit is contained in:
Shoyu Vanilla 2025-10-27 02:18:52 +09:00
parent ad63c71652
commit 85b7d646cd
3 changed files with 139 additions and 0 deletions

View file

@ -472,3 +472,55 @@ where
"#,
);
}
#[test]
fn regression_16282() {
check_infer(
r#"
//- minicore: coerce_unsized, dispatch_from_dyn
trait MapLookup<Q> {
type MapValue;
}
impl<K> MapLookup<K> for K {
type MapValue = K;
}
trait Map: MapLookup<<Self as Map>::Key> {
type Key;
}
impl<K> Map for K {
type Key = K;
}
fn main() {
let _ = &()
as &dyn Map<Key=u32,MapValue=u32>;
}
"#,
expect![[r#"
210..272 '{ ...32>; }': ()
220..221 '_': &'? (dyn Map<MapValue = u32, Key = u32> + '?)
224..227 '&()': &'? ()
224..269 '&() ...e=u32>': &'? (dyn Map<MapValue = u32, Key = u32> + 'static)
225..227 '()': ()
"#]],
);
}
#[test]
fn regression_18692() {
check_no_mismatches(
r#"
//- minicore: coerce_unsized, dispatch_from_dyn, send
trait Trait: Send {}
fn f(_: *const (dyn Trait + Send)) {}
fn g(it: *const (dyn Trait)) {
f(it);
}
"#,
);
}

View file

@ -485,6 +485,29 @@ fn foo((): (), (): ()) {
foo(1);
// ^ error: expected 2 arguments, found 1
}
"#,
);
}
#[test]
fn regression_17233() {
check_diagnostics(
r#"
pub trait A {
type X: B;
}
pub trait B: A {
fn confused_name(self, _: i32);
}
pub struct Foo;
impl Foo {
pub fn confused_name(&self) {}
}
pub fn repro<T: A>() {
Foo.confused_name();
}
"#,
);
}

View file

@ -4015,4 +4015,68 @@ fn bar() {
"##,
);
}
#[test]
fn regression_20038() {
check(
r#"
//- minicore: clone, fn
struct Map<Fut, F>(Fut, F);
struct InspectFn<F>(F);
trait FnOnce1<A> {
type Output;
}
trait Future1 {
type Output;
}
trait FusedFuture1: Future1 {
fn is_terminated(&self) -> bool;
//^^^^^^^^^^^^^
}
impl<T, A, R> FnOnce1<A> for T
where
T: FnOnce(A) -> R,
{
type Output = R;
}
impl<F, A> FnOnce1<A> for InspectFn<F>
where
F: for<'a> FnOnce1<&'a A, Output = ()>,
{
type Output = A;
}
impl<Fut, F, T> Future1 for Map<Fut, F>
where
Fut: Future1,
F: FnOnce1<Fut::Output, Output = T>,
{
type Output = T;
}
impl<Fut, F, T> FusedFuture1 for Map<Fut, F>
where
Fut: Future1,
F: FnOnce1<Fut::Output, Output = T>,
{
fn is_terminated(&self) -> bool {
false
}
}
fn overflows<Fut, F>(inner: &Map<Fut, InspectFn<F>>)
where
Map<Fut, InspectFn<F>>: FusedFuture1
{
let _x = inner.is_terminated$0();
}
"#,
)
}
}