@@ -262,7 +262,7 @@ fn test_overlap_normalize_alias_to_LocalType() {
262
262
#[ test]
263
263
fn test_overlap_alias_not_normalizable ( ) {
264
264
// `LocalTrait` has a blanket impl for all `T: Iterator`
265
- // and then an impl for `<LocalType as Mirror>::T`...
265
+ // and then an impl for `<T as Mirror>::T`...
266
266
267
267
let gen_program = |addl : & str | {
268
268
const BASE_PROGRAM : & str = "[
@@ -293,14 +293,29 @@ fn test_overlap_alias_not_normalizable() {
293
293
BASE_PROGRAM . replace ( "ADDITIONAL" , addl)
294
294
} ;
295
295
296
- // ...on its own, this is OK. Figuring this out, though, requires proving
297
- // `<LocalType as Mirror>::T: Iterator` which requires normalizing
298
- // the alias to `LocalType`...
296
+ // ...you might expect an error here, because we have an impl for all `T` and another
297
+ // impl for all `T: Iterator`, but we don't flag it as one because
298
+ // Iterator is a local trait and we can see that nobody has implemented it...
299
+ //
300
+ // FIXME: rustc DOES flag an error here. I think this is because the trait solver
301
+ // refuses to solve `?X: Iterator`; we haven't implemented that rule and I haven't
302
+ // decided how to think about it.
299
303
300
304
expect_test:: expect![ [ r#"
301
305
Ok(
302
306
(),
303
307
)
304
- "# ] ] // FIXME
308
+ "# ] ]
305
309
. assert_debug_eq ( & test_program_ok ( & gen_program ( "" ) ) ) ;
310
+
311
+ // ...as long as there is at least one Iterator impl, however, we do flag an error.
312
+
313
+ expect_test:: expect![ [ r#"
314
+ Err(
315
+ "impls may overlap: `impl <ty> LocalTrait < > for ^ty0_0 where [^ty0_0 : Iterator < >] { }` vs `impl <ty> LocalTrait < > for (alias (Mirror :: T) ^ty0_0) where [^ty0_0 : Mirror < >] { }`",
316
+ )
317
+ "# ] ] // FIXME
318
+ . assert_debug_eq ( & test_program_ok ( & gen_program (
319
+ "impl<> Iterator<> for u32 where[] {}" ,
320
+ ) ) ) ;
306
321
}
0 commit comments