Skip to content

Commit

Permalink
Merge pull request #18944 from WaffleLapkin/trait_upcast_chalk
Browse files Browse the repository at this point in the history
update chalk, fixing trait upcasting
  • Loading branch information
lnicola authored Jan 16, 2025
2 parents 7d337c7 + dde6ab4 commit c656906
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 12 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ arrayvec = "0.7.4"
bitflags = "2.4.1"
cargo_metadata = "0.18.1"
camino = "1.1.6"
chalk-solve = { version = "0.98.0", default-features = false }
chalk-ir = "0.98.0"
chalk-recursive = { version = "0.98.0", default-features = false }
chalk-derive = "0.98.0"
chalk-solve = { version = "0.99.0", default-features = false }
chalk-ir = "0.99.0"
chalk-recursive = { version = "0.99.0", default-features = false }
chalk-derive = "0.99.0"
crossbeam-channel = "0.5.8"
dissimilar = "1.0.7"
dot = "0.1.4"
Expand Down
31 changes: 31 additions & 0 deletions crates/ide-diagnostics/src/handlers/type_mismatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,37 @@ struct Bar {
);
}

#[test]
fn trait_upcast_ok() {
check_diagnostics(
r#"
//- minicore: coerce_unsized
trait A: B {}
trait B {}
fn test(a: &dyn A) -> &dyn B {
a
}
"#,
);
}

#[test]
fn trait_upcast_err() {
check_diagnostics(
r#"
//- minicore: coerce_unsized
trait A {} // `A` does not have `B` as a supertrait, so no upcast :c
trait B {}
fn test(a: &dyn A) -> &dyn B {
a
//^ error: expected &dyn B, found &dyn A
}
"#,
);
}

#[test]
fn return_no_value() {
check_diagnostics_with_disabled(
Expand Down

0 comments on commit c656906

Please sign in to comment.