File tree 1 file changed +33
-0
lines changed 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -224,6 +224,39 @@ fn overlapping_negative_impls() {
224
224
}
225
225
}
226
226
227
+ #[ test]
228
+ fn downstream_impl_of_fundamental_43355 ( ) {
229
+ // Regression test for issue 43355 which exposed an unsoundness in the original implementation
230
+ // with regards to how fundamental types were handled for potential downstream impls. This case
231
+ // fails exactly the way we want it to using chalk's overlap check rules.
232
+ // https://github.com/rust-lang/rust/issues/43355
233
+ lowering_error ! {
234
+ program {
235
+ #[ upstream]
236
+ #[ fundamental]
237
+ struct Box <T > { }
238
+
239
+ trait Trait1 <X > { }
240
+ trait Trait2 <X > { }
241
+
242
+ struct A { }
243
+
244
+ impl <X , T > Trait1 <X > for T where T : Trait2 <X > { }
245
+ impl <X > Trait1 <Box <X >> for A { }
246
+
247
+ // So how do these impls overlap? Consider a downstream crate that adds this code:
248
+ //
249
+ // struct B;
250
+ // impl Trait2<Box<B>> for A {}
251
+ //
252
+ // This makes the first impl now apply to A, which means that both of these impls now
253
+ // overlap for A even though they didn't overlap in the original crate where A is defined.
254
+ } error_msg {
255
+ "overlapping impls of trait \" Trait1\" "
256
+ }
257
+ }
258
+ }
259
+
227
260
#[ test]
228
261
fn orphan_check ( ) {
229
262
// These tests are largely adapted from the compile-fail coherence-*.rs tests from rustc
You can’t perform that action at this time.
0 commit comments