Skip to content

trivial_bounds doesn't see associated type as implementing a trait #51044

Closed
@kornelski

Description

@kornelski

Regression in rustc 1.27.0-nightly (2f2a11d 2018-05-16), still present in rustc 1.28.0-nightly (29ffe51 2018-05-23). Previous day's nightly, and stable, compile fine.

#![allow(dead_code)]
struct Foo<T>(T);
struct Duck;
struct Quack;

trait Hello<A> where A: Animal {
}

trait Animal {
    type Noise;
}

trait Loud<R>  {
}

impl Loud<Quack> for f32 {
}

impl Animal for Duck {
    type Noise = Quack;
}

impl Hello<Duck> for Foo<f32> where f32: Loud<<Duck as Animal>::Noise> {
}

// impl Hello<Duck> for Foo<f32> where f32: Loud<Quack> // builds fine

On rustc 1.27.0-nightly (f0fdaba 2018-05-15) it builds fine.
On rustc 1.27.0-nightly (2f2a11d 2018-05-16) it fails with:

 error[E0277]: the trait bound `f32: Loud<<Duck as Animal>::Noise>` is not satisfied
  --> src/lib.rs:23:1
   |
23 | / impl Hello<Duck> for Foo<f32> where f32: Loud<<Duck as Animal>::Noise> {
24 | | }
   | |_^ the trait `Loud<<Duck as Animal>::Noise>` is not implemented for `f32`
   |
   = help: consider adding a `where f32: Loud<<Duck as Animal>::Noise>` bound
   = help: see issue #48214
   = help: add #![feature(trivial_bounds)] to the crate attributes to enable

Metadata

Metadata

Labels

P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions