diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-05-18 08:41:14 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-18 08:41:14 +0200 |
| commit | 04f903859a8a1b82a25b6bba7301beb06ad145d2 (patch) | |
| tree | 5880103c94f39d02c037f452e0973fddbaf7f0bb /src/test | |
| parent | 64c58a1a4ab6ba68db6d87a6a1f813679875110e (diff) | |
| parent | 58781edc5459d9835b80d819d0469a23bdfc0026 (diff) | |
| download | rust-04f903859a8a1b82a25b6bba7301beb06ad145d2.tar.gz rust-04f903859a8a1b82a25b6bba7301beb06ad145d2.zip | |
Rollup merge of #95979 - lcnr:coherence-docs, r=compiler-errors
update coherence docs, fix generator + opaque type ICE the world is confusing, this makes it slightly less so
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/coherence/coherence-with-closure.rs | 15 | ||||
| -rw-r--r-- | src/test/ui/coherence/coherence-with-closure.stderr | 24 | ||||
| -rw-r--r-- | src/test/ui/coherence/coherence-with-generator.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/coherence/coherence-with-generator.stderr | 24 |
4 files changed, 82 insertions, 0 deletions
diff --git a/src/test/ui/coherence/coherence-with-closure.rs b/src/test/ui/coherence/coherence-with-closure.rs new file mode 100644 index 00000000000..6e3281d8508 --- /dev/null +++ b/src/test/ui/coherence/coherence-with-closure.rs @@ -0,0 +1,15 @@ +// Test that encountering closures during coherence does not cause issues. +#![feature(type_alias_impl_trait)] +type OpaqueClosure = impl Sized; +fn defining_use() -> OpaqueClosure { + || () +} + +struct Wrapper<T>(T); +trait Trait {} +impl Trait for Wrapper<OpaqueClosure> {} +//~^ ERROR cannot implement trait on type alias impl trait +impl<T: Sync> Trait for Wrapper<T> {} +//~^ ERROR conflicting implementations of trait `Trait` for type `Wrapper<OpaqueClosure>` + +fn main() {} diff --git a/src/test/ui/coherence/coherence-with-closure.stderr b/src/test/ui/coherence/coherence-with-closure.stderr new file mode 100644 index 00000000000..20b986cee69 --- /dev/null +++ b/src/test/ui/coherence/coherence-with-closure.stderr @@ -0,0 +1,24 @@ +error: cannot implement trait on type alias impl trait + --> $DIR/coherence-with-closure.rs:10:24 + | +LL | impl Trait for Wrapper<OpaqueClosure> {} + | ^^^^^^^^^^^^^ + | +note: type alias impl trait defined here + --> $DIR/coherence-with-closure.rs:3:22 + | +LL | type OpaqueClosure = impl Sized; + | ^^^^^^^^^^ + +error[E0119]: conflicting implementations of trait `Trait` for type `Wrapper<OpaqueClosure>` + --> $DIR/coherence-with-closure.rs:12:1 + | +LL | impl Trait for Wrapper<OpaqueClosure> {} + | ------------------------------------- first implementation here +LL | +LL | impl<T: Sync> Trait for Wrapper<T> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Wrapper<OpaqueClosure>` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-with-generator.rs b/src/test/ui/coherence/coherence-with-generator.rs new file mode 100644 index 00000000000..d34c391db9f --- /dev/null +++ b/src/test/ui/coherence/coherence-with-generator.rs @@ -0,0 +1,19 @@ +// Test that encountering closures during coherence does not cause issues. +#![feature(type_alias_impl_trait, generators)] +type OpaqueGenerator = impl Sized; +fn defining_use() -> OpaqueGenerator { + || { + for i in 0..10 { + yield i; + } + } +} + +struct Wrapper<T>(T); +trait Trait {} +impl Trait for Wrapper<OpaqueGenerator> {} +//~^ ERROR cannot implement trait on type alias impl trait +impl<T: Sync> Trait for Wrapper<T> {} +//~^ ERROR conflicting implementations of trait `Trait` for type `Wrapper<OpaqueGenerator>` + +fn main() {} diff --git a/src/test/ui/coherence/coherence-with-generator.stderr b/src/test/ui/coherence/coherence-with-generator.stderr new file mode 100644 index 00000000000..249ad3cb9ec --- /dev/null +++ b/src/test/ui/coherence/coherence-with-generator.stderr @@ -0,0 +1,24 @@ +error: cannot implement trait on type alias impl trait + --> $DIR/coherence-with-generator.rs:14:24 + | +LL | impl Trait for Wrapper<OpaqueGenerator> {} + | ^^^^^^^^^^^^^^^ + | +note: type alias impl trait defined here + --> $DIR/coherence-with-generator.rs:3:24 + | +LL | type OpaqueGenerator = impl Sized; + | ^^^^^^^^^^ + +error[E0119]: conflicting implementations of trait `Trait` for type `Wrapper<OpaqueGenerator>` + --> $DIR/coherence-with-generator.rs:16:1 + | +LL | impl Trait for Wrapper<OpaqueGenerator> {} + | --------------------------------------- first implementation here +LL | +LL | impl<T: Sync> Trait for Wrapper<T> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Wrapper<OpaqueGenerator>` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0119`. |
