id: item.id,
parent,
imported_module: Cell::new(Some(ModuleOrUniformRoot::Module(module))),
- subclass: ImportDirectiveSubclass::ExternCrate(orig_name),
+ subclass: ImportDirectiveSubclass::ExternCrate {
+ source: orig_name,
+ target: ident,
+ },
root_span: item.span,
span: item.span,
module_path: Vec::new(),
}
}
}
- ImportDirectiveSubclass::ExternCrate(_) => {
+ ImportDirectiveSubclass::ExternCrate { .. } => {
resolver.maybe_unused_extern_crates.push((directive.id, directive.span));
}
ImportDirectiveSubclass::MacroUse => {
match self.kind {
NameBindingKind::Import {
directive: &ImportDirective {
- subclass: ImportDirectiveSubclass::ExternCrate(_), ..
+ subclass: ImportDirectiveSubclass::ExternCrate { .. }, ..
}, ..
} => true,
_ => false,
}
}
- fn is_renamed_extern_crate(&self) -> bool {
- if let NameBindingKind::Import { directive, ..} = self.kind {
- if let ImportDirectiveSubclass::ExternCrate(Some(_)) = directive.subclass {
- return true;
- }
- }
- false
- }
-
fn is_glob_import(&self) -> bool {
match self.kind {
NameBindingKind::Import { directive, .. } => directive.is_glob(),
if let NameBindingKind::Import { directive: d, .. } = binding.kind {
// Careful: we still want to rewrite paths from
// renamed extern crates.
- if let ImportDirectiveSubclass::ExternCrate(None) = d.subclass {
+ if let ImportDirectiveSubclass::ExternCrate { source: None, .. } = d.subclass {
return
}
}
};
let cm = self.session.source_map();
- let rename_msg = "You can use `as` to change the binding name of the import";
-
- if let (Ok(snippet), false) = (cm.span_to_snippet(binding.span),
- binding.is_renamed_extern_crate()) {
+ let rename_msg = "you can use `as` to change the binding name of the import";
+
+ if let (
+ Ok(snippet),
+ NameBindingKind::Import { directive, ..},
+ _dummy @ false,
+ ) = (
+ cm.span_to_snippet(binding.span),
+ binding.kind.clone(),
+ binding.span.is_dummy(),
+ ) {
let suggested_name = if name.as_str().chars().next().unwrap().is_uppercase() {
format!("Other{}", name)
} else {
err.span_suggestion_with_applicability(
binding.span,
- rename_msg,
- if snippet.ends_with(';') {
- format!("{} as {};", &snippet[..snippet.len() - 1], suggested_name)
- } else {
- format!("{} as {}", snippet, suggested_name)
+ &rename_msg,
+ match (&directive.subclass, snippet.as_ref()) {
+ (ImportDirectiveSubclass::SingleImport { .. }, "self") =>
+ format!("self as {}", suggested_name),
+ (ImportDirectiveSubclass::SingleImport { source, .. }, _) =>
+ format!(
+ "{} as {}{}",
+ &snippet[..((source.span.hi().0 - binding.span.lo().0) as usize)],
+ suggested_name,
+ if snippet.ends_with(";") {
+ ";"
+ } else {
+ ""
+ }
+ ),
+ (ImportDirectiveSubclass::ExternCrate { source, target, .. }, _) =>
+ format!(
+ "extern crate {} as {};",
+ source.unwrap_or(target.name),
+ suggested_name,
+ ),
+ (_, _) => unreachable!(),
},
- Applicability::MachineApplicable,
+ Applicability::MaybeIncorrect,
);
} else {
err.span_label(binding.span, rename_msg);
max_vis: Cell<ty::Visibility>, // The visibility of the greatest re-export.
// n.b. `max_vis` is only used in `finalize_import` to check for re-export errors.
},
- ExternCrate(Option<Name>),
+ ExternCrate {
+ source: Option<Name>,
+ target: Ident,
+ },
MacroUse,
}
match *subclass {
SingleImport { source, .. } => source.to_string(),
GlobImport { .. } => "*".to_string(),
- ExternCrate(_) => "<extern crate>".to_string(),
+ ExternCrate { .. } => "<extern crate>".to_string(),
MacroUse => "#[macro_use]".to_string(),
}
}
| ^^^^^^^^ `Bar` reimported here
|
= note: `Bar` must be defined only once in the type namespace of this block
-help: You can use `as` to change the binding name of the import
+help: you can use `as` to change the binding name of the import
|
LL | use foo::Bar as OtherBar;
| ^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^ `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
+help: you can use `as` to change the binding name of the import
|
LL | use foo::foo as other_foo;
| ^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^ `foo` reimported here
|
= note: `foo` must be defined only once in the value namespace of this module
-help: You can use `as` to change the binding name of the import
+help: you can use `as` to change the binding name of the import
|
LL | use sub2::foo as other_foo; //~ ERROR the name `foo` is defined multiple times
| ^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^ `X` reimported here
|
= note: `X` 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
+help: you can use `as` to change the binding name of the import
|
LL | use self::bar::X as OtherX;
| ^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^ `panic` redefined here
|
= note: `panic` must be defined only once in the macro namespace of this module
-help: You can use `as` to change the binding name of the import
+help: you can use `as` to change the binding name of the import
|
LL | pub use std::panic as other_panic;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^ `baz` reimported here
|
= note: `baz` 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
+help: you can use `as` to change the binding name of the import
|
LL | use bar::baz as other_baz; //~ ERROR E0252
| ^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^ `alloc` reimported here
|
= note: `alloc` 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
+help: you can use `as` to change the binding name of the import
|
LL | use foo::alloc as other_alloc;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^ `foo` redefined here
|
= note: `foo` must be defined only once in the value namespace of this module
-help: You can use `as` to change the binding name of the import
+help: you can use `as` to change the binding name of the import
|
LL | use bar::foo as other_foo;
| ^^^^^^^^^^^^^^^^^^^^^
| ------------------- previous import of the extern crate `alloc` here
LL |
LL | extern crate libc as alloc;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
- | |
- | `alloc` reimported here
- | You can use `as` to change the binding name of the import
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `alloc` reimported here
|
= note: `alloc` 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 libc as other_alloc;
+ |
error: aborting due to previous error
| ^^^^^^^^^ `alloc` redefined here
|
= note: `alloc` 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
+help: you can use `as` to change the binding name of the import
|
LL | extern crate alloc as other_alloc;
|
| previous import of the module `fmt` here
|
= note: `fmt` 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
+help: you can use `as` to change the binding name of the import
|
LL | use std::fmt::{self, self as other_fmt}; //~ ERROR E0430
| ^^^^^^^^^^^^^^^^^
LL | extern crate m1;
| ---------------- previous import of the extern crate `m1` here
LL | extern crate m2 as m1; //~ ERROR is defined multiple times
- | ^^^^^^^^^^^^^^^^^^^^^^
- | |
- | `m1` reimported here
- | You can use `as` to change the binding name of the import
+ | ^^^^^^^^^^^^^^^^^^^^^^ `m1` reimported here
|
= note: `m1` 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 m2 as other_m1; //~ ERROR is defined multiple times
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
| ^^^^^^ `foo` reimported here
|
= note: `foo` must be defined only once in the value namespace of this module
-help: You can use `as` to change the binding name of the import
+help: you can use `as` to change the binding name of the import
|
LL | use a::foo as other_foo; //~ ERROR the name `foo` is defined multiple times
| ^^^^^^^^^^^^^^^^^^^
| ^^^^^ `A` redefined 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
+help: you can use `as` to change the binding name of the import
|
LL | use self::A as OtherA;
| ^^^^^^^^^^^^^^^^^
| ^^^^^^^^^ `B` redefined here
|
= note: `B` 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
+help: you can use `as` to change the binding name of the import
|
LL | use self::B as OtherB;
| ^^^^^^^^^^^^^^^^^
| ^^^^^ `D` redefined here
|
= note: `D` 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
+help: you can use `as` to change the binding name of the import
|
LL | use C::D as OtherD;
| ^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^ `Add` redefined here
|
= note: `Add` 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
+help: you can use `as` to change the binding name of the import
|
LL | use std::ops::Add as OtherAdd;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^ `Sub` redefined here
|
= note: `Sub` 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
+help: you can use `as` to change the binding name of the import
|
LL | use std::ops::Sub as OtherSub;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^ `Mul` redefined here
|
= note: `Mul` 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
+help: you can use `as` to change the binding name of the import
|
LL | use std::ops::Mul as OtherMul;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^ `Div` redefined here
|
= note: `Div` 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
+help: you can use `as` to change the binding name of the import
|
LL | use std::ops::Div as OtherDiv;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^ `Rem` redefined here
|
= note: `Rem` 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
+help: you can use `as` to change the binding name of the import
|
LL | use std::ops::Rem as OtherRem;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^ `baz` reimported here
|
= note: `baz` 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
+help: you can use `as` to change the binding name of the import
|
LL | use bar::baz as other_baz; //~ ERROR the name `baz` is defined multiple times
| ^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^ `Quux` reimported here
|
= note: `Quux` 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
+help: you can use `as` to change the binding name of the import
|
LL | use bar::Quux as OtherQuux; //~ ERROR the name `Quux` is defined multiple times
| ^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^ `blah` reimported here
|
= note: `blah` 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
+help: you can use `as` to change the binding name of the import
|
LL | use bar::blah as other_blah; //~ ERROR the name `blah` is defined multiple times
| ^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^ `WOMP` reimported here
|
= note: `WOMP` must be defined only once in the value namespace of this module
-help: You can use `as` to change the binding name of the import
+help: you can use `as` to change the binding name of the import
|
LL | use bar::WOMP as OtherWOMP; //~ ERROR the name `WOMP` is defined multiple times
| ^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^ `Arc` reimported here
|
= note: `Arc` 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
+help: you can use `as` to change the binding name of the import
|
LL | use std::sync::Arc as OtherArc; //~ ERROR the name `Arc` is defined multiple times
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^ `sync` reimported here
|
= note: `sync` 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
+help: you can use `as` to change the binding name of the import
|
LL | use std::sync as other_sync; //~ ERROR the name `sync` is defined multiple times
| ^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ConstructorExtension` reimported here
|
= note: `ConstructorExtension` 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
+help: you can use `as` to change the binding name of the import
|
LL | use extension2::ConstructorExtension as OtherConstructorExtension; //~ ERROR is defined multiple times
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^ `std` reimported 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
+help: you can use `as` to change the binding name of the import
|
LL | extern crate std as other_std;
|
--- /dev/null
+// 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.
+
+pub const FOO: usize = *&0;
--- /dev/null
+// 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.
+
+pub const FOO: usize = *&0;
--- /dev/null
+// 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() {}
--- /dev/null
+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`.
--- /dev/null
+// 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() {}
--- /dev/null
+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`.
--- /dev/null
+// 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, B as A};
+
+fn main() {}
--- /dev/null
+error[E0252]: the name `A` is defined multiple times
+ --> $DIR/issue-45829.rs:16:14
+ |
+LL | use foo::{A, 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, B as OtherA};
+ | ^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0252`.
--- /dev/null
+// 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_b.rs
+
+mod foo {
+ pub mod bar {}
+}
+
+use foo::bar;
+extern crate issue_45829_b as bar;
+
+fn main() {}
--- /dev/null
+error[E0254]: the name `bar` is defined multiple times
+ --> $DIR/rename-extern-vs-use.rs:18:1
+ |
+LL | use foo::bar;
+ | -------- previous import of the module `bar` here
+LL | extern crate issue_45829_b as bar;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `bar` reimported here
+ |
+ = note: `bar` 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_bar;
+ |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0254`.
--- /dev/null
+// 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() {}
--- /dev/null
+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`.
--- /dev/null
+// 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() {}
--- /dev/null
+error[E0259]: the name `issue_45829_a` is defined multiple times
+ --> $DIR/rename-extern.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`.
--- /dev/null
+// 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_b.rs
+
+extern crate issue_45829_b;
+use std as issue_45829_b;
+
+fn main() {}
--- /dev/null
+error[E0254]: the name `issue_45829_b` is defined multiple times
+ --> $DIR/rename-use-vs-extern.rs:14:5
+ |
+LL | extern crate issue_45829_b;
+ | --------------------------- previous import of the extern crate `issue_45829_b` here
+LL | use std as issue_45829_b;
+ | ^^^^^^^^^^^^^^^^^^^^ `issue_45829_b` reimported here
+ |
+ = note: `issue_45829_b` 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 std as other_issue_45829_b;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0254`.
--- /dev/null
+// 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() {}
--- /dev/null
+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`.
--- /dev/null
+// 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.
+
+use std::{collections::HashMap as A, sync::Arc as A};
+
+fn main() {}
--- /dev/null
+error[E0252]: the name `A` is defined multiple times
+ --> $DIR/rename-with-path.rs:11:38
+ |
+LL | use std::{collections::HashMap as A, sync::Arc 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 std::{collections::HashMap as A, sync::Arc as OtherA};
+ | ^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0252`.
--- /dev/null
+// 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.
+
+use core;
+use std as core;
+
+fn main() {
+ 1 + 1;
+}
--- /dev/null
+error[E0252]: the name `core` is defined multiple times
+ --> $DIR/rename.rs:12:5
+ |
+LL | use core;
+ | ---- previous import of the module `core` here
+LL | use std as core;
+ | ^^^^^^^^^^^ `core` reimported here
+ |
+ = note: `core` 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 std as other_core;
+ | ^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0252`.
| ^^^^^^^ `bar` redefined here
|
= note: `bar` 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
+help: you can use `as` to change the binding name of the import
|
LL | use baz::bar as other_bar;
| ^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^ `core` reimported here
|
= note: `core` 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
+help: you can use `as` to change the binding name of the import
|
LL | extern crate core as other_core; //~ ERROR: the name `core` is defined multiple times
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^ `std` reimported 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
+help: you can use `as` to change the binding name of the import
|
LL | extern crate std as other_std;
|
| ^^^^^^^^^^^^^^^^^ `std` reimported 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
+help: you can use `as` to change the binding name of the import
|
-LL | use std::slice as std as other_std; //~ ERROR the name `std` is defined multiple times
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | use std::slice as other_std; //~ ERROR the name `std` is defined multiple times
+ | ^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
| ^^^^^^^^^^^^^^^^^^^ `transmute` reimported here
|
= note: `transmute` must be defined only once in the value namespace of this module
-help: You can use `as` to change the binding name of the import
+help: you can use `as` to change the binding name of the import
|
LL | use std::mem::transmute as other_transmute;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^ `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
| ^^^^^^^^^^^^^^ `transmute` redefined here
|
= note: `transmute` must be defined only once in the value namespace of this module
-help: You can use `as` to change the binding name of the import
+help: you can use `as` to change the binding name of the import
|
LL | use std::mem::transmute as other_transmute;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^ `Iter` redefined here
|
= note: `Iter` 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
+help: you can use `as` to change the binding name of the import
|
LL | use std::slice::Iter as OtherIter;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^ `core` reimported here
|
= note: `core` 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
+help: you can use `as` to change the binding name of the import
|
LL | use core as other_core;
| ^^^^^^^^^^^^^^^^^^
| ^^^^ `bar` reimported here
|
= note: `bar` 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
+help: you can use `as` to change the binding name of the import
|
LL | self as other_bar
|
| ^^^^^^^^ `mem` reimported here
|
= note: `mem` 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
+help: you can use `as` to change the binding name of the import
|
LL | use std::mem as other_mem; //~ ERROR the name `mem` is defined multiple times
| ^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^ `XStruct` reimported here
|
= note: `XStruct` 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
+help: you can use `as` to change the binding name of the import
|
LL | pub use variant_namespacing::XE::{XStruct as OtherXStruct, XTuple, XUnit};
| ^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^ `XTuple` reimported here
|
= note: `XTuple` 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
+help: you can use `as` to change the binding name of the import
|
LL | pub use variant_namespacing::XE::{XStruct, XTuple as OtherXTuple, XUnit};
| ^^^^^^^^^^^^^^^^^^^^^
| ^^^^^ `XUnit` reimported here
|
= note: `XUnit` 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
+help: you can use `as` to change the binding name of the import
|
LL | pub use variant_namespacing::XE::{XStruct, XTuple, XUnit as OtherXUnit};
| ^^^^^^^^^^^^^^^^^^^
| ^^^^^^ `Struct` reimported here
|
= note: `Struct` 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
+help: you can use `as` to change the binding name of the import
|
LL | pub use E::{Struct as OtherStruct, Tuple, Unit};
| ^^^^^^^^^^^^^^^^^^^^^
| ^^^^^ `Tuple` reimported here
|
= note: `Tuple` 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
+help: you can use `as` to change the binding name of the import
|
LL | pub use E::{Struct, Tuple as OtherTuple, Unit};
| ^^^^^^^^^^^^^^^^^^^
| ^^^^ `Unit` reimported here
|
= note: `Unit` 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
+help: you can use `as` to change the binding name of the import
|
LL | pub use E::{Struct, Tuple, Unit as OtherUnit};
| ^^^^^^^^^^^^^^^^^