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:
commit
de083eb165
9 changed files with 74 additions and 8 deletions
|
|
@ -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() {}
|
||||
|
|
|
|||
11
src/test/ui/suggestions/auxiliary/m1.rs
Normal file
11
src/test/ui/suggestions/auxiliary/m1.rs
Normal 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() {}
|
||||
11
src/test/ui/suggestions/auxiliary/m2.rs
Normal file
11
src/test/ui/suggestions/auxiliary/m2.rs
Normal 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() {}
|
||||
18
src/test/ui/suggestions/extern-crate-rename.rs
Normal file
18
src/test/ui/suggestions/extern-crate-rename.rs
Normal 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() {}
|
||||
15
src/test/ui/suggestions/extern-crate-rename.stderr
Normal file
15
src/test/ui/suggestions/extern-crate-rename.stderr
Normal 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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue