Skip to content

Commit c656906

Browse files
authored
Merge pull request #18944 from WaffleLapkin/trait_upcast_chalk
update chalk, fixing trait upcasting
2 parents 7d337c7 + dde6ab4 commit c656906

File tree

3 files changed

+43
-12
lines changed

3 files changed

+43
-12
lines changed

Cargo.lock

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ arrayvec = "0.7.4"
106106
bitflags = "2.4.1"
107107
cargo_metadata = "0.18.1"
108108
camino = "1.1.6"
109-
chalk-solve = { version = "0.98.0", default-features = false }
110-
chalk-ir = "0.98.0"
111-
chalk-recursive = { version = "0.98.0", default-features = false }
112-
chalk-derive = "0.98.0"
109+
chalk-solve = { version = "0.99.0", default-features = false }
110+
chalk-ir = "0.99.0"
111+
chalk-recursive = { version = "0.99.0", default-features = false }
112+
chalk-derive = "0.99.0"
113113
crossbeam-channel = "0.5.8"
114114
dissimilar = "1.0.7"
115115
dot = "0.1.4"

crates/ide-diagnostics/src/handlers/type_mismatch.rs

+31
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,37 @@ struct Bar {
11631163
);
11641164
}
11651165

1166+
#[test]
1167+
fn trait_upcast_ok() {
1168+
check_diagnostics(
1169+
r#"
1170+
//- minicore: coerce_unsized
1171+
trait A: B {}
1172+
trait B {}
1173+
1174+
fn test(a: &dyn A) -> &dyn B {
1175+
a
1176+
}
1177+
"#,
1178+
);
1179+
}
1180+
1181+
#[test]
1182+
fn trait_upcast_err() {
1183+
check_diagnostics(
1184+
r#"
1185+
//- minicore: coerce_unsized
1186+
trait A {} // `A` does not have `B` as a supertrait, so no upcast :c
1187+
trait B {}
1188+
1189+
fn test(a: &dyn A) -> &dyn B {
1190+
a
1191+
//^ error: expected &dyn B, found &dyn A
1192+
}
1193+
"#,
1194+
);
1195+
}
1196+
11661197
#[test]
11671198
fn return_no_value() {
11681199
check_diagnostics_with_disabled(

0 commit comments

Comments
 (0)