Skip to content

Commit e0cfe10

Browse files
committed
Include import name in import shadowing error messages.
This partially alleviates the confusing behavior in issue #16597
1 parent eaf810a commit e0cfe10

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/librustc/middle/resolve.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2820,9 +2820,10 @@ impl<'a> Resolver<'a> {
28202820
.contains_key(&name) {
28212821
match import_resolution.type_target {
28222822
Some(ref target) if !target.shadowable => {
2823-
self.session.span_err(import_span,
2824-
"import conflicts with imported \
2825-
crate in this module");
2823+
let msg = format!("import `{}` conflicts with imported \
2824+
crate in this module",
2825+
token::get_name(name).get());
2826+
self.session.span_err(import_span, msg.as_slice());
28262827
}
28272828
Some(_) | None => {}
28282829
}
@@ -2843,9 +2844,10 @@ impl<'a> Resolver<'a> {
28432844
match *name_bindings.value_def.borrow() {
28442845
None => {}
28452846
Some(ref value) => {
2846-
self.session.span_err(import_span,
2847-
"import conflicts with value \
2848-
in this module");
2847+
let msg = format!("import `{}` conflicts with value \
2848+
in this module",
2849+
token::get_name(name).get());
2850+
self.session.span_err(import_span, msg.as_slice());
28492851
match value.value_span {
28502852
None => {}
28512853
Some(span) => {
@@ -2865,9 +2867,10 @@ impl<'a> Resolver<'a> {
28652867
match *name_bindings.type_def.borrow() {
28662868
None => {}
28672869
Some(ref ty) => {
2868-
self.session.span_err(import_span,
2869-
"import conflicts with type in \
2870-
this module");
2870+
let msg = format!("import `{}` conflicts with type in \
2871+
this module",
2872+
token::get_name(name).get());
2873+
self.session.span_err(import_span, msg.as_slice());
28712874
match ty.type_span {
28722875
None => {}
28732876
Some(span) => {

0 commit comments

Comments
 (0)