Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PredicateBoolean doesn't implement Predicate<T> for T: ?Sized #83

Closed
asomers opened this issue Nov 18, 2019 · 0 comments · Fixed by #84
Closed

PredicateBoolean doesn't implement Predicate<T> for T: ?Sized #83

asomers opened this issue Nov 18, 2019 · 0 comments · Fixed by #84

Comments

@asomers
Copy link
Contributor

asomers commented Nov 18, 2019

I tried this code:

let p: Box<dyn Predicate<str>> = Box::new(always());

I expected to see this happen: It should compile fine

Instead this happened: Build fails with this error:

error[E0277]: the size for values of type `str` cannot be known at compilation time
  --> src/constant.rs:86:38
   |
86 |     let p: Box<dyn Predicate<str>> = Box::new(always());
   |                                      ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
   |
   = help: the trait `std::marker::Sized` is not implemented for `str`
   = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
   = note: required because of the requirements on the impl of `predicates_core::core::Predicate<str>` for `constant::BooleanPredicate`
   = note: required for the cast to the object type `dyn predicates_core::core::Predicate<str>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.

Meta

predicates-rs version: 1.0.1
rustc --version --verbose:

> rustc --version --verbose
rustc 1.41.0-nightly (1bd30ce2a 2019-11-15)
binary: rustc
commit-hash: 1bd30ce2aac40c7698aa4a1b9520aa649ff2d1c5
commit-date: 2019-11-15
host: x86_64-unknown-freebsd
release: 1.41.0-nightly
LLVM version: 9.0

Originally reported at asomers/mockall#78

asomers added a commit to asomers/predicates-rs that referenced this issue Nov 18, 2019
asomers added a commit to asomers/predicates-rs that referenced this issue Nov 18, 2019
impl Predicate<T> for PredicateBoolean even if T: ?Sized
Fixes assert-rs#83
asomers added a commit to asomers/predicates-rs that referenced this issue Nov 18, 2019
impl Predicate<T> for PredicateBoolean even if T: ?Sized
Fixes assert-rs#83
@epage epage closed this as completed in #84 Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant