Skip to content

Commit b47b7bc

Browse files
committed
explain behavior of test changes
`test_overlap_alias_not_normalizable`
1 parent 689de45 commit b47b7bc

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

tests/coherence_overlap.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ fn test_overlap_normalize_alias_to_LocalType() {
262262
#[test]
263263
fn test_overlap_alias_not_normalizable() {
264264
// `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`...
266266

267267
let gen_program = |addl: &str| {
268268
const BASE_PROGRAM: &str = "[
@@ -293,14 +293,29 @@ fn test_overlap_alias_not_normalizable() {
293293
BASE_PROGRAM.replace("ADDITIONAL", addl)
294294
};
295295

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.
299303

300304
expect_test::expect![[r#"
301305
Ok(
302306
(),
303307
)
304-
"#]] // FIXME
308+
"#]]
305309
.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+
)));
306321
}

0 commit comments

Comments
 (0)