Skip to content

Normalization of projections in trait bounds on associated types #20775

Open
@nikomatsakis

Description

@nikomatsakis

Related to #20765 we should do more normalization in order for this test to pass:

// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// Test where the bounds in the trait use projections rather than the
// canonical form.

trait Foo
{
    type T;
}

trait Bar<A:Foo<T=B>,B>
{
    type F : Baz<A::T>;
}

trait Baz<A> { }

fn foo<I:Bar<J,K>,J,K>()
{
    // Based on trait, we can conclude that
    //    I::F : Baz<J::T>
    // and
    //    J::T == K
    // hence
    //    I::F : Baz<K>
    // which is what `bar` expects.
    bar::<I::F,K>()
}

fn bar<IF, K>()
    where IF : Baz<K>
{
}

fn main ()
{
}

Metadata

Metadata

Assignees

Labels

A-associated-itemsArea: Associated items (types, constants & functions)C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions