rustc_resolve: don't handle impl items as if they were modules.

This commit is contained in:
Eduard Burtescu 2015-02-20 08:17:05 +02:00
parent 6700166442
commit 06f362aeb3
24 changed files with 157 additions and 385 deletions

View file

@ -43,7 +43,7 @@ fn foo<'a>() {
//~^ ERROR too many type parameters provided
let _ = S::<'a,isize>::new::<f64>(1, 1.0);
//~^ ERROR too many lifetime parameters provided
//~^ ERROR wrong number of lifetime parameters
let _: S2 = Trait::new::<isize,f64>(1, 1.0);
//~^ ERROR too many type parameters provided

View file

@ -19,5 +19,5 @@ impl<A, B, C = (A, B)> Foo<A, B, C> {
fn main() {
Foo::<isize>::new();
//~^ ERROR too few type parameters provided
//~^ ERROR wrong number of type arguments
}

View file

@ -21,5 +21,5 @@ impl<T, A = Heap> Vec<T, A> {
fn main() {
Vec::<isize, Heap, bool>::new();
//~^ ERROR too many type parameters provided
//~^ ERROR wrong number of type arguments
}

View file

@ -11,7 +11,7 @@
struct Foo;
impl Foo {
fn orange(&self){}
fn orange(&self){} //~ ERROR error: duplicate definition of value `orange`
fn orange(&self){} //~ ERROR error: duplicate method in trait impl
}
fn main() {}

View file

@ -29,7 +29,7 @@ impl Foo for *const BarTy {
baz();
//~^ ERROR: unresolved name `baz`. Did you mean to call `self.baz`?
a;
//~^ ERROR: unresolved name `a`. Did you mean to call `BarTy::a`?
//~^ ERROR: unresolved name `a`
}
}
@ -42,11 +42,11 @@ impl<'a> Foo for &'a BarTy {
y;
//~^ ERROR: unresolved name `y`. Did you mean `self.y`?
a;
//~^ ERROR: unresolved name `a`. Did you mean to call `BarTy::a`?
//~^ ERROR: unresolved name `a`
bah;
//~^ ERROR: unresolved name `bah`. Did you mean to call `Foo::bah`?
b;
//~^ ERROR: unresolved name `b`. Did you mean to call `self.b`?
//~^ ERROR: unresolved name `b`
}
}
@ -59,11 +59,11 @@ impl<'a> Foo for &'a mut BarTy {
y;
//~^ ERROR: unresolved name `y`. Did you mean `self.y`?
a;
//~^ ERROR: unresolved name `a`. Did you mean to call `BarTy::a`?
//~^ ERROR: unresolved name `a`
bah;
//~^ ERROR: unresolved name `bah`. Did you mean to call `Foo::bah`?
b;
//~^ ERROR: unresolved name `b`. Did you mean to call `self.b`?
//~^ ERROR: unresolved name `b`
}
}

View file

@ -18,7 +18,7 @@ mod B {
use crate1::A::Foo;
fn bar(f: Foo) {
Foo::foo(&f);
//~^ ERROR: function `foo` is private
//~^ ERROR: method `foo` is private
}
}

View file

@ -36,7 +36,7 @@ impl Groom for cat {
shave(4);
//~^ ERROR: unresolved name `shave`. Did you mean to call `Groom::shave`?
purr();
//~^ ERROR: unresolved name `purr`. Did you mean to call `self.purr`?
//~^ ERROR: unresolved name `purr`
}
}
@ -45,13 +45,13 @@ impl cat {
fn purr_louder() {
static_method();
//~^ ERROR: unresolved name `static_method`. Did you mean to call `cat::static_method`
//~^ ERROR: unresolved name `static_method`
purr();
//~^ ERROR: unresolved name `purr`. Did you mean to call `self.purr`?
//~^ ERROR: unresolved name `purr`
purr();
//~^ ERROR: unresolved name `purr`. Did you mean to call `self.purr`?
//~^ ERROR: unresolved name `purr`
purr();
//~^ ERROR: unresolved name `purr`. Did you mean to call `self.purr`?
//~^ ERROR: unresolved name `purr`
}
}
@ -65,7 +65,7 @@ impl cat {
fn purr(&self) {
grow_older();
//~^ ERROR: unresolved name `grow_older`. Did you mean to call `cat::grow_older`
//~^ ERROR: unresolved name `grow_older`
shave();
//~^ ERROR: unresolved name `shave`
}
@ -79,7 +79,7 @@ impl cat {
whiskers = 4;
//~^ ERROR: unresolved name `whiskers`. Did you mean `self.whiskers`?
purr_louder();
//~^ ERROR: unresolved name `purr_louder`. Did you mean to call `cat::purr_louder`
//~^ ERROR: unresolved name `purr_louder`
}
}

View file

@ -17,7 +17,7 @@ impl Foo {
Foo { baz: 0 }.bar();
}
fn bar() { //~ ERROR duplicate definition of value `bar`
fn bar() { //~ ERROR duplicate method in trait impl
}
}

View file

@ -29,7 +29,7 @@ impl S {
// Cause an error. It shouldn't have any macro backtrace frames.
fn bar(&self) { }
fn bar(&self) { } //~ ERROR duplicate definition
fn bar(&self) { } //~ ERROR duplicate method
}
fn main() { }

View file

@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// FIXME(eddyb/UFCS) This should have a nicer error, but that's not possible just yet.
impl<T> Option<T> { //~ ERROR use of undeclared type name `Option`
impl<T> Option<T> {
//~^ ERROR cannot associate methods with a type outside the crate the type is defined in
pub fn foo(&self) { }
}

View file

@ -11,7 +11,7 @@
use Trait::foo;
//~^ ERROR `foo` is not directly importable
use Foo::new;
//~^ ERROR `new` is not directly importable
//~^ ERROR unresolved import `Foo::new`. Not a module `Foo`
pub trait Trait {
fn foo();

View file

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// 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.
//
@ -8,17 +8,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test calling methods on an impl for a bare trait. This test checks trait impls
// must be in the same module as the trait.
mod Foo {
trait T {}
}
mod Bar {
impl<'a> ::Foo::T+'a { //~ERROR: inherent implementations may only be implemented in the same
fn foo(&self) {}
mod foo {
pub struct Point {
pub x: i32,
pub y: i32,
}
}
fn main() {}
impl foo::Point {
fn x(&self) -> i32 { self.x }
}
fn main() {
assert_eq!((foo::Point { x: 1, y: 3}).x(), 1);
}

View file

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// 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.
//
@ -8,17 +8,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
mod foo {
pub struct Foo {
x: isize,
y: isize,
mod Foo {
trait Trait {
fn foo(&self);
}
}
impl foo::Foo {
//~^ ERROR implementations may only be implemented in the same module
fn bar() {}
mod Bar {
impl<'a> ::Foo::Trait+'a {
fn bar(&self) { self.foo() }
}
}
fn main() {}