]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #16598 : bkoropoff/rust/import-shadow-name, r=alexcrichton
authorbors <bors@rust-lang.org>
Sat, 30 Aug 2014 12:41:22 +0000 (12:41 +0000)
committerbors <bors@rust-lang.org>
Sat, 30 Aug 2014 12:41:22 +0000 (12:41 +0000)
This partially alleviates the confusing behavior in issue #16597

src/librustc/middle/resolve.rs
src/test/compile-fail/resolve-conflict-import-vs-extern-crate.rs
src/test/compile-fail/resolve-conflict-item-vs-import.rs
src/test/compile-fail/resolve-conflict-type-vs-import.rs [new file with mode: 0644]

index ed2f1db2aa80a5174e78ee6e91520c05e8ca0143..0c8697d31f3c98dd2023d1013d9578b96344b004 100644 (file)
@@ -2822,9 +2822,10 @@ fn check_for_conflicts_between_imports_and_items(&mut self,
                  .contains_key(&name) {
             match import_resolution.type_target {
                 Some(ref target) if !target.shadowable => {
-                    self.session.span_err(import_span,
-                                          "import conflicts with imported \
-                                           crate in this module");
+                    let msg = format!("import `{}` conflicts with imported \
+                                       crate in this module",
+                                      token::get_name(name).get());
+                    self.session.span_err(import_span, msg.as_slice());
                 }
                 Some(_) | None => {}
             }
@@ -2845,9 +2846,10 @@ fn check_for_conflicts_between_imports_and_items(&mut self,
                 match *name_bindings.value_def.borrow() {
                     None => {}
                     Some(ref value) => {
-                        self.session.span_err(import_span,
-                                              "import conflicts with value \
-                                               in this module");
+                        let msg = format!("import `{}` conflicts with value \
+                                           in this module",
+                                          token::get_name(name).get());
+                        self.session.span_err(import_span, msg.as_slice());
                         match value.value_span {
                             None => {}
                             Some(span) => {
@@ -2867,9 +2869,10 @@ fn check_for_conflicts_between_imports_and_items(&mut self,
                 match *name_bindings.type_def.borrow() {
                     None => {}
                     Some(ref ty) => {
-                        self.session.span_err(import_span,
-                                              "import conflicts with type in \
-                                               this module");
+                        let msg = format!("import `{}` conflicts with type in \
+                                           this module",
+                                          token::get_name(name).get());
+                        self.session.span_err(import_span, msg.as_slice());
                         match ty.type_span {
                             None => {}
                             Some(span) => {
index d13503b23fb16a6c88594cdfb513b4543cc7231d..f27b11d5411c9589b417d9acf0bc93a92b92e812 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::slice as std; //~ ERROR import conflicts with imported crate
+use std::slice as std; //~ ERROR import `std` conflicts with imported crate
 
 fn main() {
 }
index 3834007f5ffe95343c8a178628180094af11bb5b..96800918351c139becbaac93aac5efdb58d746e0 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use std::mem::transmute;
-//~^ ERROR import conflicts with value in this module
+//~^ ERROR import `transmute` conflicts with value in this module
 
 fn transmute() {}
 
diff --git a/src/test/compile-fail/resolve-conflict-type-vs-import.rs b/src/test/compile-fail/resolve-conflict-type-vs-import.rs
new file mode 100644 (file)
index 0000000..fa072fa
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright 2014 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::slice::Items;
+//~^ ERROR import `Items` conflicts with type in this module
+
+struct Items;
+
+fn main() {
+}
+