Skip to content

Commit f7c1ad6

Browse files
Merge pull request rust-lang#20914 from ShoyuVanilla/next-solver-tests
Add regression tests for some fixed `A-ty` issues
2 parents f62cb38 + 85b7d64 commit f7c1ad6

File tree

3 files changed

+139
-0
lines changed

3 files changed

+139
-0
lines changed

src/tools/rust-analyzer/crates/hir-ty/src/tests/regression/new_solver.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,3 +472,55 @@ where
472472
"#,
473473
);
474474
}
475+
476+
#[test]
477+
fn regression_16282() {
478+
check_infer(
479+
r#"
480+
//- minicore: coerce_unsized, dispatch_from_dyn
481+
trait MapLookup<Q> {
482+
type MapValue;
483+
}
484+
485+
impl<K> MapLookup<K> for K {
486+
type MapValue = K;
487+
}
488+
489+
trait Map: MapLookup<<Self as Map>::Key> {
490+
type Key;
491+
}
492+
493+
impl<K> Map for K {
494+
type Key = K;
495+
}
496+
497+
498+
fn main() {
499+
let _ = &()
500+
as &dyn Map<Key=u32,MapValue=u32>;
501+
}
502+
"#,
503+
expect![[r#"
504+
210..272 '{ ...32>; }': ()
505+
220..221 '_': &'? (dyn Map<MapValue = u32, Key = u32> + '?)
506+
224..227 '&()': &'? ()
507+
224..269 '&() ...e=u32>': &'? (dyn Map<MapValue = u32, Key = u32> + 'static)
508+
225..227 '()': ()
509+
"#]],
510+
);
511+
}
512+
513+
#[test]
514+
fn regression_18692() {
515+
check_no_mismatches(
516+
r#"
517+
//- minicore: coerce_unsized, dispatch_from_dyn, send
518+
trait Trait: Send {}
519+
520+
fn f(_: *const (dyn Trait + Send)) {}
521+
fn g(it: *const (dyn Trait)) {
522+
f(it);
523+
}
524+
"#,
525+
);
526+
}

src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/mismatched_arg_count.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,29 @@ fn foo((): (), (): ()) {
485485
foo(1);
486486
// ^ error: expected 2 arguments, found 1
487487
}
488+
"#,
489+
);
490+
}
491+
492+
#[test]
493+
fn regression_17233() {
494+
check_diagnostics(
495+
r#"
496+
pub trait A {
497+
type X: B;
498+
}
499+
pub trait B: A {
500+
fn confused_name(self, _: i32);
501+
}
502+
503+
pub struct Foo;
504+
impl Foo {
505+
pub fn confused_name(&self) {}
506+
}
507+
508+
pub fn repro<T: A>() {
509+
Foo.confused_name();
510+
}
488511
"#,
489512
);
490513
}

src/tools/rust-analyzer/crates/ide/src/goto_definition.rs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4015,4 +4015,68 @@ fn bar() {
40154015
"##,
40164016
);
40174017
}
4018+
4019+
#[test]
4020+
fn regression_20038() {
4021+
check(
4022+
r#"
4023+
//- minicore: clone, fn
4024+
struct Map<Fut, F>(Fut, F);
4025+
4026+
struct InspectFn<F>(F);
4027+
4028+
trait FnOnce1<A> {
4029+
type Output;
4030+
}
4031+
4032+
trait Future1 {
4033+
type Output;
4034+
}
4035+
4036+
trait FusedFuture1: Future1 {
4037+
fn is_terminated(&self) -> bool;
4038+
//^^^^^^^^^^^^^
4039+
}
4040+
4041+
impl<T, A, R> FnOnce1<A> for T
4042+
where
4043+
T: FnOnce(A) -> R,
4044+
{
4045+
type Output = R;
4046+
}
4047+
4048+
impl<F, A> FnOnce1<A> for InspectFn<F>
4049+
where
4050+
F: for<'a> FnOnce1<&'a A, Output = ()>,
4051+
{
4052+
type Output = A;
4053+
}
4054+
4055+
impl<Fut, F, T> Future1 for Map<Fut, F>
4056+
where
4057+
Fut: Future1,
4058+
F: FnOnce1<Fut::Output, Output = T>,
4059+
{
4060+
type Output = T;
4061+
}
4062+
4063+
impl<Fut, F, T> FusedFuture1 for Map<Fut, F>
4064+
where
4065+
Fut: Future1,
4066+
F: FnOnce1<Fut::Output, Output = T>,
4067+
{
4068+
fn is_terminated(&self) -> bool {
4069+
false
4070+
}
4071+
}
4072+
4073+
fn overflows<Fut, F>(inner: &Map<Fut, InspectFn<F>>)
4074+
where
4075+
Map<Fut, InspectFn<F>>: FusedFuture1
4076+
{
4077+
let _x = inner.is_terminated$0();
4078+
}
4079+
"#,
4080+
)
4081+
}
40184082
}

0 commit comments

Comments
 (0)