librustc: Disallow use from reaching into impls or traits.
This can perhaps be restored in the future. For now this is a precursor to making typedefs work as expected.
This commit is contained in:
parent
291518712f
commit
ca9bb2d9ac
5 changed files with 187 additions and 65 deletions
10
src/test/auxiliary/use_from_trait_xc.rs
Normal file
10
src/test/auxiliary/use_from_trait_xc.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
pub trait Trait {
|
||||
fn foo();
|
||||
}
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl Foo {
|
||||
pub fn new() {}
|
||||
}
|
||||
|
||||
12
src/test/compile-fail/use-from-trait-xc.rs
Normal file
12
src/test/compile-fail/use-from-trait-xc.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// aux-build:use_from_trait_xc.rs
|
||||
|
||||
extern mod use_from_trait_xc;
|
||||
|
||||
use use_from_trait_xc::Trait::foo; //~ ERROR cannot import from a trait or type implementation
|
||||
//~^ ERROR failed to resolve import
|
||||
use use_from_trait_xc::Foo::new; //~ ERROR cannot import from a trait or type implementation
|
||||
//~^ ERROR failed to resolve import
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
||||
17
src/test/compile-fail/use-from-trait.rs
Normal file
17
src/test/compile-fail/use-from-trait.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
use Trait::foo; //~ ERROR cannot import from a trait or type implementation
|
||||
//~^ ERROR failed to resolve import
|
||||
use Foo::new; //~ ERROR cannot import from a trait or type implementation
|
||||
//~^ ERROR failed to resolve import
|
||||
|
||||
pub trait Trait {
|
||||
fn foo();
|
||||
}
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl Foo {
|
||||
fn new() {}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue