diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs index 673a2c2fcaf..a21e9f4a0a5 100644 --- a/compiler/rustc_typeck/src/astconv/mod.rs +++ b/compiler/rustc_typeck/src/astconv/mod.rs @@ -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]; diff --git a/src/test/ui/traits/issue-65673.rs b/src/test/ui/traits/issue-65673.rs index 4b47bd493a5..e5c2fccb2b5 100644 --- a/src/test/ui/traits/issue-65673.rs +++ b/src/test/ui/traits/issue-65673.rs @@ -7,6 +7,6 @@ trait WithType { impl WithType for T { type Ctx = dyn Alias; -//~^ 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() {} diff --git a/src/test/ui/traits/issue-65673.stderr b/src/test/ui/traits/issue-65673.stderr index 245c4ee525e..79f071ba302 100644 --- a/src/test/ui/traits/issue-65673.stderr +++ b/src/test/ui/traits/issue-65673.stderr @@ -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; - | ^^^^^^^^^^^^ 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`. diff --git a/src/test/ui/traits/issue-96664.rs b/src/test/ui/traits/issue-96664.rs new file mode 100644 index 00000000000..3c5314af73e --- /dev/null +++ b/src/test/ui/traits/issue-96664.rs @@ -0,0 +1,16 @@ +// check-pass + +#![feature(trait_alias)] + +pub trait State = Clone + Send + Sync + PartialOrd + PartialEq + std::fmt::Display; +pub trait RandState = FnMut() -> S + Send; + +pub trait Evaluator { + type State; +} + +pub struct Evolver { + rand_state: Box>, +} + +fn main() {}