Only keep predicates on Self
when checking dyn TraitAlias
.
This commit is contained in:
parent
bb6b433958
commit
cca981661a
@ -1334,8 +1334,9 @@ fn conv_object_ty_poly_trait_ref(
|
||||
// is used and no 'maybe' bounds are used.
|
||||
let expanded_traits =
|
||||
traits::expand_trait_aliases(tcx, bounds.trait_bounds.iter().map(|&(a, b, _)| (a, b)));
|
||||
let (mut auto_traits, regular_traits): (Vec<_>, Vec<_>) =
|
||||
expanded_traits.partition(|i| tcx.trait_is_auto(i.trait_ref().def_id()));
|
||||
let (mut auto_traits, regular_traits): (Vec<_>, Vec<_>) = expanded_traits
|
||||
.filter(|i| i.trait_ref().self_ty().skip_binder() == dummy_self)
|
||||
.partition(|i| tcx.trait_is_auto(i.trait_ref().def_id()));
|
||||
if regular_traits.len() > 1 {
|
||||
let first_trait = ®ular_traits[0];
|
||||
let additional_trait = ®ular_traits[1];
|
||||
|
@ -7,6 +7,6 @@ trait WithType {
|
||||
|
||||
impl<T> WithType for T {
|
||||
type Ctx = dyn Alias<T>;
|
||||
//~^ ERROR the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time
|
||||
//~^ ERROR at least one trait is required for an object type [E0224]
|
||||
}
|
||||
fn main() {}
|
||||
|
@ -1,16 +1,9 @@
|
||||
error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time
|
||||
error[E0224]: at least one trait is required for an object type
|
||||
--> $DIR/issue-65673.rs:9:16
|
||||
|
|
||||
LL | type Ctx = dyn Alias<T>;
|
||||
| ^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `(dyn Trait + 'static)`
|
||||
note: required by a bound in `WithType::Ctx`
|
||||
--> $DIR/issue-65673.rs:4:5
|
||||
|
|
||||
LL | type Ctx;
|
||||
| ^^^^^^^^^ required by this bound in `WithType::Ctx`
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
For more information about this error, try `rustc --explain E0224`.
|
||||
|
16
src/test/ui/traits/issue-96664.rs
Normal file
16
src/test/ui/traits/issue-96664.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// check-pass
|
||||
|
||||
#![feature(trait_alias)]
|
||||
|
||||
pub trait State = Clone + Send + Sync + PartialOrd + PartialEq + std::fmt::Display;
|
||||
pub trait RandState<S: State> = FnMut() -> S + Send;
|
||||
|
||||
pub trait Evaluator {
|
||||
type State;
|
||||
}
|
||||
|
||||
pub struct Evolver<E: Evaluator> {
|
||||
rand_state: Box<dyn RandState<E::State>>,
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user