Rollup merge of #45856 - estebank:issue-45829, r=nikomatsakis

Fix help for duplicated names: `extern crate (...) as (...)`

On the case of duplicated names caused by an `extern crate` statement
with a rename, don't include the inline suggestion, instead using a span
label with only the text to avoid incorrect rust code output.

Fix #45829.
This commit is contained in:
kennytm 2017-11-10 17:07:05 +08:00 committed by GitHub
commit de083eb165
9 changed files with 74 additions and 8 deletions

View file

@ -18,5 +18,6 @@ extern crate libc as alloc;
//~^ ERROR E0259
//~| NOTE `alloc` reimported here
//~| NOTE `alloc` must be defined only once in the type namespace of this module
//~| NOTE You can use `as` to change the binding name of the import
fn main() {}

View file

@ -0,0 +1,11 @@
// Copyright 2017 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 fn foo() {}

View file

@ -0,0 +1,11 @@
// Copyright 2017 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 fn bar() {}

View file

@ -0,0 +1,18 @@
// Copyright 2017 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:m1.rs
// aux-build:m2.rs
extern crate m1;
extern crate m2 as m1;
fn main() {}

View file

@ -0,0 +1,15 @@
error[E0259]: the name `m1` is defined multiple times
--> $DIR/extern-crate-rename.rs:16:1
|
15 | extern crate m1;
| ---------------- previous import of the extern crate `m1` here
16 | extern crate m2 as m1;
| ^^^^^^^^^^^^^^^^^^^^^^
| |
| `m1` reimported here
| You can use `as` to change the binding name of the import
|
= note: `m1` must be defined only once in the type namespace of this module
error: aborting due to previous error