-
Notifications
You must be signed in to change notification settings - Fork 13.4k
#45829 when a renamed import conflict with a previous import #55113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
cac95ee
ad4cea4
2ba567f
4520b30
9eacd68
8fe6688
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4796,10 +4796,18 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { | |
err.span_suggestion_with_applicability( | ||
binding.span, | ||
rename_msg, | ||
if snippet.ends_with(';') { | ||
format!("{} as {};", &snippet[..snippet.len() - 1], suggested_name) | ||
if snippet.contains(" as ") { | ||
mockersf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
format!( | ||
"{} as {}", | ||
&snippet[..snippet.find(" as ").unwrap()], | ||
mockersf marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here (and above) this is not going to work if the snippet is I'm looking at |
||
suggested_name, | ||
) | ||
} else { | ||
format!("{} as {}", snippet, suggested_name) | ||
if snippet.ends_with(';') { | ||
format!("{} as {};", &snippet[..snippet.len() - 1], suggested_name) | ||
} else { | ||
format!("{} as {}", snippet, suggested_name) | ||
} | ||
mockersf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
Applicability::MachineApplicable, | ||
mockersf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// 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; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// 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; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// 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 | ||
|
||
use std; | ||
extern crate issue_45829_b as std; | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
error[E0259]: the name `std` is defined multiple times | ||
--> $DIR/rename-extern-vs-use.rs:14:1 | ||
| | ||
LL | extern crate issue_45829_b as std; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| `std` reimported here | ||
| You can use `as` to change the binding name of the import | ||
| | ||
= note: `std` must be defined only once in the type namespace of this module | ||
|
||
error[E0254]: the name `std` is defined multiple times | ||
--> $DIR/rename-extern-vs-use.rs:13:5 | ||
| | ||
LL | use 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 | ||
| | ||
LL | use std as other_std; | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors occurred: E0254, E0259. | ||
For more information about an error, try `rustc --explain E0254`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
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 | ||
| You can use `as` to change the binding name of the import | ||
mockersf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| | ||
= note: `issue_45829_a` must be defined only once in the type namespace of this module | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0259`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// 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() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
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`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// 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() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
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`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// 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; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
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`. |
Uh oh!
There was an error while loading. Please reload this page.