Skip to content

Commit

Permalink
Merge pull request #14 from dtolnay/compiletest
Browse files Browse the repository at this point in the history
Add ui test for missing DynClone supertrait
  • Loading branch information
dtolnay authored Mar 15, 2022
2 parents 358e751 + 6872508 commit 91b11c3
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ repository = "https://github.com/dtolnay/dyn-clone"
documentation = "https://docs.rs/dyn-clone"
readme = "README.md"

[dev-dependencies]
rustversion = "1.0"
trybuild = { version = "1.0.49", features = ["diff"] }

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
7 changes: 7 additions & 0 deletions tests/compiletest.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#[rustversion::attr(not(nightly), ignore)]
#[cfg_attr(miri, ignore)]
#[test]
fn ui() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/*.rs");
}
5 changes: 5 additions & 0 deletions tests/ui/missing-supertrait.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub trait MyTrait {}

dyn_clone::clone_trait_object!(MyTrait);

fn main() {}
55 changes: 55 additions & 0 deletions tests/ui/missing-supertrait.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
error[E0277]: the trait bound `dyn MyTrait: Clone` is not satisfied
--> tests/ui/missing-supertrait.rs:3:1
|
3 | dyn_clone::clone_trait_object!(MyTrait);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `dyn MyTrait`
|
= note: required because of the requirements on the impl of `DynClone` for `dyn MyTrait`
note: required by a bound in `clone_box`
--> src/lib.rs
|
| T: ?Sized + DynClone,
| ^^^^^^^^ required by this bound in `clone_box`
= note: this error originates in the macro `$crate::__internal_clone_trait_object` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `dyn MyTrait + Send: Clone` is not satisfied
--> tests/ui/missing-supertrait.rs:3:1
|
3 | dyn_clone::clone_trait_object!(MyTrait);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `dyn MyTrait + Send`
|
= note: required because of the requirements on the impl of `DynClone` for `dyn MyTrait + Send`
note: required by a bound in `clone_box`
--> src/lib.rs
|
| T: ?Sized + DynClone,
| ^^^^^^^^ required by this bound in `clone_box`
= note: this error originates in the macro `$crate::__internal_clone_trait_object` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `dyn MyTrait + Sync: Clone` is not satisfied
--> tests/ui/missing-supertrait.rs:3:1
|
3 | dyn_clone::clone_trait_object!(MyTrait);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `dyn MyTrait + Sync`
|
= note: required because of the requirements on the impl of `DynClone` for `dyn MyTrait + Sync`
note: required by a bound in `clone_box`
--> src/lib.rs
|
| T: ?Sized + DynClone,
| ^^^^^^^^ required by this bound in `clone_box`
= note: this error originates in the macro `$crate::__internal_clone_trait_object` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `dyn MyTrait + Send + Sync: Clone` is not satisfied
--> tests/ui/missing-supertrait.rs:3:1
|
3 | dyn_clone::clone_trait_object!(MyTrait);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `dyn MyTrait + Send + Sync`
|
= note: required because of the requirements on the impl of `DynClone` for `dyn MyTrait + Send + Sync`
note: required by a bound in `clone_box`
--> src/lib.rs
|
| T: ?Sized + DynClone,
| ^^^^^^^^ required by this bound in `clone_box`
= note: this error originates in the macro `$crate::__internal_clone_trait_object` (in Nightly builds, run with -Z macro-backtrace for more info)

0 comments on commit 91b11c3

Please sign in to comment.