Implement new mod import sugar

Implements RFC #168.
This commit is contained in:
Jakub Wieczorek 2014-07-18 00:56:56 +02:00
parent 50481f5503
commit 4b9bc2e8f2
17 changed files with 268 additions and 80 deletions

View file

@ -0,0 +1,19 @@
// 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.
mod foo {
use self::{mod};
//~^ ERROR unresolved import `self`. There is no `self` in `???`
use super::{mod};
//~^ ERROR unresolved import `super`. There is no `super` in `???`
}
fn main() {}

View file

@ -0,0 +1,24 @@
// 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.
use foo::bar::{
mod //~ ERROR module `bar` is private
};
use foo::bar::{
Bar, //~ ERROR type `Bar` is inaccessible
//~^ NOTE module `bar` is private
mod //~ ERROR module `bar` is private
};
mod foo {
mod bar { pub type Bar = int; }
}
fn main() {}

View file

@ -0,0 +1,32 @@
// 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.
use foo::bar::{
mod,
//~^ ERROR `mod` import can only appear once in the list
Bar,
mod
//~^ NOTE another `mod` import appears here
};
use {mod};
//~^ ERROR `mod` import can only appear in an import list with a non-empty prefix
use foo::mod;
//~^ ERROR `mod` imports are only allowed within a { } list
mod foo {
pub mod bar {
pub struct Bar;
pub struct Baz;
}
}
fn main() {}