rollup merge of #18868: nikomatsakis/issue-17388-unbound-path-assoc-type

This fixes #17388.

Note that we don't check type parameters in trait-references and so on, so we accept some nonsense (I opened https://github.com/rust-lang/rust/issues/18865). (It may be easier to just add support for `T::Foo` and deprecate the qpath code until we can implement it more robustly using the trait lookup infrastructure, not sure.)
This commit is contained in:
Jakub Bukaj 2014-11-19 22:37:02 +01:00
commit 655eb44df3
16 changed files with 119 additions and 187 deletions

View file

@ -20,12 +20,12 @@ fn get<T:Get,U:Get>(x: T, y: U) -> Get::Value {}
trait Other {
fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
//~^ ERROR this associated type is not allowed in this context
//~^ ERROR no suitable bound on `Self`
}
impl<T:Get> Other for T {
fn uhoh<U:Get>(&self, foo: U, bar: <(T, U) as Get>::Value) {}
//~^ ERROR this associated type is not allowed in this context
//~^ ERROR currently unsupported
}
trait Grab {

View file

@ -16,7 +16,7 @@ trait Get {
}
fn get(x: int) -> <int as Get>::Value {}
//~^ ERROR this associated type is not allowed in this context
//~^ ERROR unsupported
struct Struct {
x: int,
@ -24,7 +24,7 @@ struct Struct {
impl Struct {
fn uhoh<T>(foo: <T as Get>::Value) {}
//~^ ERROR this associated type is not allowed in this context
//~^ ERROR no suitable bound on `T`
}
fn main() {

View file

@ -0,0 +1,18 @@
// Copyright 2014 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.
#![feature(associated_types)]
trait Foo<T> {
type Bar;
fn get_bar() -> <Self as Foo<T>>::Bar;
}
fn main() { }