Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve expected type handling for calls #9560

Closed
flodiebold opened this issue Jul 11, 2021 · 0 comments · Fixed by #9655 or #9966
Closed

Improve expected type handling for calls #9560

flodiebold opened this issue Jul 11, 2021 · 0 comments · Fixed by #9655 or #9966
Assignees
Labels
A-ty type system / type inference / traits / method resolution E-hard S-actionable Someone could pick this issue up and work on it right now

Comments

@flodiebold
Copy link
Member

flodiebold commented Jul 11, 2021

We basically need to implement this logic from rustc to get the right coercions working in some cases, for example in this test (already added on master):

#[test]
fn coerce_unsize_expected_type_2() {
    check_no_mismatches(
        r#"
//- minicore: coerce_unsized
struct InFile<T>;
impl<T> InFile<T> {
    fn with_value<U>(self, value: U) -> InFile<U> { InFile }
}
struct RecordField;
trait AstNode {}
impl AstNode for RecordField {}

fn takes_dyn(it: InFile<&dyn AstNode>) {}

fn test() {
    let x: InFile<()> = InFile;
    let n = &RecordField;
    takes_dyn(x.with_value(n));
}
        "#,
    );
}
@flodiebold flodiebold added E-hard A-ty type system / type inference / traits / method resolution S-actionable Someone could pick this issue up and work on it right now labels Jul 11, 2021
flodiebold added a commit to flodiebold/rust-analyzer that referenced this issue Jul 11, 2021
bors bot added a commit that referenced this issue Jul 11, 2021
9572: fix: Work around older synstructure derives r=lnicola a=flodiebold

Fixes #9562, until the proper fix rust-lang/chalk#717 works which requires mystor/synstructure#47 to be released.

Also add an unrelated test, for #9560.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
@flodiebold flodiebold self-assigned this Jul 18, 2021
bors bot added a commit that referenced this issue Jul 20, 2021
9655: fix: Determine expected parameters from expected return in calls r=flodiebold a=flodiebold

Fixes #9560


Co-authored-by: Florian Diebold <flodiebold@gmail.com>
@bors bors bot closed this as completed in ae22050 Jul 20, 2021
@flodiebold flodiebold reopened this Jul 20, 2021
flodiebold added a commit to flodiebold/rust-analyzer that referenced this issue Aug 5, 2021
bors bot added a commit that referenced this issue Aug 21, 2021
9966: fix: Determine expected parameters from expected return in calls r=flodiebold a=flodiebold

Second attempt 😅 

Fixes #9560 

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
@bors bors bot closed this as completed in 1791a35 Aug 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ty type system / type inference / traits / method resolution E-hard S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
1 participant