manage cases with tabs or other whitespaces

This commit is contained in:
François Mockers 2018-10-21 00:23:29 +02:00
parent 4520b305ec
commit 9eacd68a49
13 changed files with 204 additions and 29 deletions

View file

@ -0,0 +1,22 @@
// Copyright 2018 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 {
pub struct A;
pub struct B;
}
use foo::{self};
use foo as self;
use foo::self;
fn main() {}

View file

@ -0,0 +1,31 @@
error: expected identifier, found keyword `self`
--> $DIR/import-self.rs:18:12
|
LL | use foo as self;
| ^^^^ expected identifier, found keyword
error[E0429]: `self` imports are only allowed within a { } list
--> $DIR/import-self.rs:20:5
|
LL | use foo::self;
| ^^^^^^^^^
error[E0255]: the name `foo` is defined multiple times
--> $DIR/import-self.rs:16:11
|
LL | mod foo {
| ------- previous definition of the module `foo` here
...
LL | use foo::{self};
| ^^^^ `foo` reimported here
|
= note: `foo` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
|
LL | use foo::{self as other_foo};
| ^^^^^^^^^^^^^^^^^
error: aborting due to 3 previous errors
Some errors occurred: E0255, E0429.
For more information about an error, try `rustc --explain E0255`.

View file

@ -0,0 +1,18 @@
// Copyright 2018 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 {
pub struct A;
pub struct B;
}
use foo::{A, A};
fn main() {}

View file

@ -0,0 +1,17 @@
error[E0252]: the name `A` is defined multiple times
--> $DIR/import-twice.rs:16:14
|
LL | use foo::{A, A};
| - ^ `A` reimported here
| |
| previous import of the type `A` here
|
= note: `A` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
|
LL | use foo::{A, A as OtherA};
| ^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0252`.

View file

@ -0,0 +1,17 @@
// Copyright 2018 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.
// aux-build:issue_45829_a.rs
// aux-build:issue_45829_b.rs
extern crate issue_45829_a;
extern crate issue_45829_b as issue_45829_a;
fn main() {}

View file

@ -0,0 +1,17 @@
error[E0259]: the name `issue_45829_a` is defined multiple times
--> $DIR/rename-extern-with-tab.rs:15:1
|
LL | extern crate issue_45829_a;
| --------------------------- previous import of the extern crate `issue_45829_a` here
LL | extern crate issue_45829_b as issue_45829_a;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `issue_45829_a` reimported here
|
= note: `issue_45829_a` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
|
LL | extern crate issue_45829_b as other_issue_45829_a;
|
error: aborting due to previous error
For more information about this error, try `rustc --explain E0259`.

View file

@ -0,0 +1,21 @@
// Copyright 2018 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 {
pub struct A;
pub mod bar {
pub struct B;
}
}
use foo::{A, bar::B as A};
fn main() {}

View file

@ -0,0 +1,17 @@
error[E0252]: the name `A` is defined multiple times
--> $DIR/rename-use-with-tabs.rs:19:14
|
LL | use foo::{A, bar::B as A};
| - ^^^^^^^^^^^^^^^^^ `A` reimported here
| |
| previous import of the type `A` here
|
= note: `A` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
|
LL | use foo::{A, bar::B as OtherA};
| ^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0252`.

View file

@ -5,10 +5,6 @@ LL | mod std {} //~ ERROR the name `std` is defined multiple times
| ^^^^^^^ `std` redefined here
|
= note: `std` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
|
LL | as other_std// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
| ^^^^^^^^^^^^
error: aborting due to previous error