diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2017-11-07 18:01:35 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2017-11-08 10:36:14 -0800 |
| commit | d0339c7e44ea145acdc779f0ecd078b11d212dc2 (patch) | |
| tree | 6cca05f64a9705a4c17035eabd580b7d365ac0e4 /src/test | |
| parent | 7f6417e9b72de63666fd92caf1a6b96a778b60ed (diff) | |
| download | rust-d0339c7e44ea145acdc779f0ecd078b11d212dc2.tar.gz rust-d0339c7e44ea145acdc779f0ecd078b11d212dc2.zip | |
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.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/E0259.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/suggestions/auxiliary/m1.rs | 11 | ||||
| -rw-r--r-- | src/test/ui/suggestions/auxiliary/m2.rs | 11 | ||||
| -rw-r--r-- | src/test/ui/suggestions/extern-crate-rename.rs | 18 | ||||
| -rw-r--r-- | src/test/ui/suggestions/extern-crate-rename.stderr | 15 |
5 files changed, 56 insertions, 0 deletions
diff --git a/src/test/compile-fail/E0259.rs b/src/test/compile-fail/E0259.rs index c285c4d9e00..e125cc0c19c 100644 --- a/src/test/compile-fail/E0259.rs +++ b/src/test/compile-fail/E0259.rs @@ -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() {} diff --git a/src/test/ui/suggestions/auxiliary/m1.rs b/src/test/ui/suggestions/auxiliary/m1.rs new file mode 100644 index 00000000000..b61667cfd88 --- /dev/null +++ b/src/test/ui/suggestions/auxiliary/m1.rs @@ -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() {} diff --git a/src/test/ui/suggestions/auxiliary/m2.rs b/src/test/ui/suggestions/auxiliary/m2.rs new file mode 100644 index 00000000000..94ff5e4497f --- /dev/null +++ b/src/test/ui/suggestions/auxiliary/m2.rs @@ -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() {} diff --git a/src/test/ui/suggestions/extern-crate-rename.rs b/src/test/ui/suggestions/extern-crate-rename.rs new file mode 100644 index 00000000000..b3fa5871a82 --- /dev/null +++ b/src/test/ui/suggestions/extern-crate-rename.rs @@ -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() {} diff --git a/src/test/ui/suggestions/extern-crate-rename.stderr b/src/test/ui/suggestions/extern-crate-rename.stderr new file mode 100644 index 00000000000..c15e238e8b0 --- /dev/null +++ b/src/test/ui/suggestions/extern-crate-rename.stderr @@ -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 + |
